News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Message Loop

Started by cobold, March 19, 2008, 12:12:48 AM

Previous topic - Next topic

cobold

Hello all,

I'm afraid to be a bit off topic with my question, because it's more about how the OS handles the message loop than masm. Yet I hope there's some helpful person out there, able to help me.
My program creates and displays a main window in the WinMain quite the normal way. In WndProc, I invoke CreateDialogParam (ADDR DlgProc). Unfortunately (for me) DlgProc never receives any WM_CHAR or WM_KEYDOWN-Messages. So I began to handle these messages in WndProc.

The problem now is, that whenever the main windows looses the focus again no WM_KEYDOWN and WM_CHAR message is processed.
But I need this because I want to have control over certain edit-fields. F.ex. I want that an edit-field only responds to keys 0-9.
But how can I achieve this without being able to handle WM_KEYDOWN when edit-control has focus?

Any hint is welcome, thanks in advance.

rgds

raymond

QuoteThe ES_NUMBER style (available in version 4.0 or later) restricts input to the edit control to digits only.

Add this to that EDIT control style and you wont have to process any WM_KEYDOWN and WM_CHAR message.

Raymond
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

cobold

Raymond,
Thanks for your reply, but it doesn't help me that much because the ES_NUMBER style is too restrictive for my purpose (e.g. it even doesn't allow the user to enter decimal-point and sign) it really only accepts digits 0-9
That's why I came on the idea to process keyboard-messages by "hand". Also I want to be able to change between edit-fields using not only TAB but ENTER.
[Something like that
.if uMsg == WM_KEYDOWN
  .if wParam == 13
      invoke SetFocus, {next edit-field}
  .endif
]


Is there no way to do these things in a dialog-box?

Thanks and regards
cobold

Draakie

You would need to Subclass the edit control and then use your
filtering routine to get exact user input - as you require - or take action on input-completion.

also see....
http://msdn2.microsoft.com/en-us/library/ms997565.aspx
http://www.pluralsight.com/articlecontent/cpprep0797.htm
http://www.codeguru.com/cpp/controls/combobox/article.php/c1813/
http://www.minigui.org/docs/mpg-2.0-6.shtml
http://www.dotnetheaven.com/Uploadfile/railjonrogut/example1404202005012314AM/example14.aspx (see download example)

Hutch also had an example somewhere.....hmmmmm.. ok .... here -> http://www.masm32.com/board/index.php?topic=4424.0
bottom of the page.

Hope it helps and I'am not way off - as to what you wanted.
Draakie
Does this code make me look bloated ? (wink)

hutch--

cobold,

For more control over the key input of an edit control, you write a "subclass" for the control using its handle, then you process the WM_CHAR message to control what you allow and what you disallow. There is a tool in the masm32 project for creating a basic subclass. In most instances you use the "wParam" of the WM_CHAR message as it is the same as the character's ANSI/ASCII value so you are just fiddling numbers within the ANSI/ASCII range to get what you want.

For a numbers only filter, you allow the 10 digits, backspace and perhaps the period.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

cobold

Draakie, Hutch - thanks a lot for the useful information. I'm going to study all the links and the example now!

best regards
cobold