News:

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

message loop modification

Started by Mr Earl, March 06, 2005, 05:49:36 PM

Previous topic - Next topic

Mr Earl

In a dialog I want to use TranslateAccelerator to intercept carriage returns for one of the fields. For another field (a multi-line edit control) I want to put the CR's in the data.  I seem to have all the statements I need to get it done:  WM_KEYDOWN, VK_RETURN,
GetFocus, ES_WANTRETURN, but it just isn't working. Is there a timing consideration with the message loop?  How much fiddling can you do inside the loop?  If someone could point me to a detailed description of message handling I'd appreciate it. Thanks.

Mark Jones

Hello Mr. Earl, have you tried setting the ES_WANTRETURN (0x01000h) style flag for the edit control? I have no idea if this will work with your existing code.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Mr Earl

Thanks Mark.  Yes, I do have ES_WANTRETURN in the style for the multiline control.  That's what bothers me, it looks to me that I have all the right settings, but I lack a detailed understanding of the message loop and I can't find any info on message handling, other than code examples, and they're never exactly what you want.  I can get each of the things I need working one at a time, but when I put them all together one or the other doesn't work.  I'm still in my first year with masm & the API, so I know I have a long way to go.  Thanks for taking the time to reply.

raymond

QuoteIn a dialog I want to use TranslateAccelerator to intercept carriage returns for one of the fields.

If the window handle you use with the TranslateAccelerator is that of the dialog box, then ALL the CRs for ALL the controls of that dialog box will be treated as an accelerator key.

If you did use the handle of that one field window, I would think that you would then have to set up a separate message loop for that specific window.

Without knowing the reason(s) why you would ever want to treat the CR as an accelerator key, it's difficult to help you otherwise.

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

donkey

In a dialog box, of any kind, the CR key is returned as WM_COMMAND with an ID of 1, the ESC key is returned as ID 0.You can change the ID returned by CR by setting another control as the "default" control. Ofcourse if an editable control has the focus, it will intercept the CR before the dialog can process it. You can always subclass any control to change how it handles characters.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Mr Earl

Thank you all for your input.  You've given me new ways to approach my problem.  How does WM_GETDLGCODE fit into the message handling process?  Does anyone ever use it?  I can't find any examples.  Thanks

pbrennick

Mr Earl,
I have never used WM_GETDLGCODE, but the way I read it in the API, it will do exactly what you want because it supercedes all control messages.  It is pretty cool, actually, I never realized that something like that could be done.

Paul

Mr Earl

Hi pb,
WM_GETDLGCODE looked like it might be a solution, but I didn't fully understand how to use it, so I tried using 2 message loops and that solved the problem.  It's not a very elegant solution, so I'll experiment later when I feel I can handle more severe frustration.