Looking for advice on filtering DialogBox Edit controls

Started by iaNac, October 25, 2006, 02:54:26 AM

Previous topic - Next topic

iaNac

Hi - I'm writing a win32 app that has a dozen or so controls on it.  Three of them are edit controls.  Initially I programmed the controls on a window and subclassed the edit controls but I couldn't figure out how to set the font and make my tab order work right, plus it seemed like a lot of code.  So I re-wrote it all as a dialog box which I like much better but I can't figure out how to filter the edit controls.  I want to limit data entry to real numbers, not just integers.  All three controls can be filtered exactly the same.  I've now superclassed the edits but I'm back to the font and tab dilemma.  Seems like 2 steps forward and 1.9 steps backwards!

Is there a way to filter dialog box controls? 
If not, is superclassing the way to go or revert back to subclassing?
    if so... What's the best way to manage tab-order when super/subclassed?

Thanks, iaNac

MichaelW

Iczelion's Superclassing Tutorial manages the tab order by processing VK_TAB and VK_SHIFT+VK_TAB directly.

eschew obfuscation

iaNac

MichaelW - After sleeping on it, I figured I could test for the edit control id in the new message interpreter and respond accordingly.  I will revisit Iczelion's tut though.

but back to the DialogBox...  how about using EN_CHANGE or EN_UPDATE to catch each keystroke.  I tried sending WM_CHAR from here to a filter but I wasn't passing the right wParam or lParam.  I also tried using EM_GETLINE then reading the buffer but I couldn't get data out (I may have done that with EN_UPDATE so maybe there was no data).  Am I wasting my time trying to filter from a dialog box?

MichaelW

I don't have time to test right now, but I think in a dialog the tabbing between controls should be handled for you, as long as the appropriate messages are passed to the original window procedure for the edit controls. The Superclassing Tutorial implements a filter that converts lower-case letters to upper case, but it could be modified it to restrict the input to real numbers.
eschew obfuscation

PBrennick

Michael is definitely correct here. You can control the start position of the tab order by using SetFocus and then it will tab through all the other controls that are able to gain focus. An editbox set to read only cannot gain focus nor can labels.

The following are able to gain focus:
-------------------------------------------------
editbox (that allows input)
radio control
checkbox
buttons (because they are actionable)

They will all be included in the tab order.

I know that Visual Basic allows you to set the tab order but it is not a standard type dialog box.

Paul
The GeneSys Project is available from:
The Repository or My crappy website