Tabbing to a button on a child form

Started by Rick McNeely, November 09, 2010, 12:05:36 AM

Previous topic - Next topic

Rick McNeely

I have a program with several child forms.  Each child form has text boxes and buttons.  I can tab to the text boxes fine, but tabbing to any button causes the form to close instantly.  Only one of the child forms (out of five) behaves correctly.   I can't see what I have done differently on that form.  I'm sure that someone else has run into this.

Thanks for any input.

Rick

Paul Squires

Hi Rick, you may need to post an example or email me your project because I don't know what would cause this off the top of my head.
Paul Squires
PlanetSquires Software

Roger Garstang

An example of the code where your message loop is and/or the function(s) for the buttons would help.  Do you use the Custom message and write your own message handler there or each control event function?  It sounds like the message loop is missing a check for click events or something and processing all events to do with the button.  Sometimes I accidentally do this since I use the Custom function a lot and make my own message loop processing it is easy to leave out a check for the type of button notification.  This causes the Focus of a button to behave like you clicked it...or actually any event to the button to behave like a click since the check for the type of event is missing, but focus is an event and usually the first.

Paul Squires

It turns out that this was just an oversight by Rick in the filtering of notifications received through the WM_COMMAND handler for the Form. He has since moved his BN_CLICKED code to the those dedicated handlers for the Command Button rather than going through WM_COMMAND for the Form. By not filtering the incoming notifications for the button in WM_COMMAND, he was closing the form whenever a notification for the button arrived (such as gotfocus, killfocus, etc.).
Paul Squires
PlanetSquires Software

Roger Garstang

Yep, thought it sounded like that.  I do that all the time, but using the Custom handler which is even more complicated.  I've started processing my buttons in their own handler too and everything else in Custom lately.  Makes it more VB-Like with some more advanced functionality in Custom.