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.
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.
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.
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
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.
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
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
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.