The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Arash on April 11, 2008, 03:12:19 PM

Title: problem on using WM_CHAR
Post by: Arash on April 11, 2008, 03:12:19 PM
Hi

i want to use WM_CHAR message in my program, i am newbie in assembly
this is part of my Dialog Procedure that use WM_CHAR, but i don't know why doesn't work


CalcProc PROC hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
...
...
.elseif uMsg == WM_CHAR
;push wParam
;pop InChar
invoke MessageBox, hWnd, addr szTest, addr szTest, MB_OKĀ  ; this is just for debugging
;invoke UpdateNumber, hWnd, wParam
...
...
CalcProc ENDP


sorry for my bad English, if i mistake
thx
Title: Re: problem on using WM_CHAR
Post by: hutch-- on April 11, 2008, 03:30:52 PM
Hi Arash,

Sorry about deleting your previous membership but unless you post we must do this to ensure the forum is not spammed.

Tell us what you want to do with the WM_CHAR message. Normally it is used in what is called a "subclass" of a control like an edit control so you can filter the characters being entered.

Let us know what you are trying to do and we can probably help you.
Title: Re: problem on using WM_CHAR
Post by: Arash on April 11, 2008, 09:19:08 PM
Hi hutch--

it doesn't matterĀ  :wink

I wish to create a simple calculator same as windows calculator
and i would like to limiting entered figures by user by counting WM_CHAR message.
could you please tell me how can i do that

Title: Re: problem on using WM_CHAR
Post by: hutch-- on April 12, 2008, 02:13:47 AM
Arash,

Here is a simple example on how to subclass an edit control and filter the input characters so you only can enter numbers.

In the WM_CREATE message in the WndProc the edit control is created and the following lines subclass the edit control. The subclass procedure is at the end of the file and it shows how to filter the WM_CHAR message.

[attachment deleted by admin]
Title: Re: problem on using WM_CHAR
Post by: Arash on April 12, 2008, 08:00:59 AM
Thanks hutch for your example, it's help me a lot