PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Rick McNeely on November 09, 2010, 12:05:36 AM

Title: Tabbing to a button on a child form
Post by: Rick McNeely on November 09, 2010, 12:05:36 AM
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
Title: Re: Tabbing to a button on a child form
Post by: Paul Squires on November 09, 2010, 09:44:49 AM
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.
Title: Re: Tabbing to a button on a child form
Post by: Roger Garstang on November 09, 2010, 04:21:13 PM
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.
Title: Re: Tabbing to a button on a child form
Post by: Paul Squires on November 10, 2010, 10:57:59 AM
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.).
Title: Re: Tabbing to a button on a child form
Post by: Roger Garstang on November 11, 2010, 11:27:31 AM
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.