Tabbing through dynamic controls
Markus Sveinn Markusson -- markus@throun.is Monday, September 23, 1996 Environment: VC++ 4.2 / NT 3.51 Fellow programmers: I have a dialog form which consists of dynamically loaded CEdit controls. These controls are loaded into a dynamically created window. Simply put, these controls are CHILD windows in a dialog CHILD window. I create a special CMyDialog::MyWndProc() function to grab all user events from these controls. OK. When I press Tab in control A I use SetFocus() to set focus to control B. OK. I press Tab in control B but nothing happens. Switching focus (mouse) back to A and then back to B again I notice that the cursor in control A reflects the correct position in control B! It's almost as if controls receiving focus this way seem to lose their ability to route messages to CMyWndProc, WM_KEYDOWN for example. This is probably due to a glitch somewhere in my code but any comments or help would be appreciated. Roughly stated this is what I do: - Dynamically create CMyWnd in CMyDialog. - Dynamically create CMyEdit controls in CMyWnd. - Call SetWindowLong() to hook CMyEdit to CMyDialog::MyWndProc() - In CMyDialog::MyWndProc() call SetFocus() to next control on Tabs. - Return from CMyDialog::MyWndProc() using ::CallWindowProc( [WndProc returned from SetWindowLong()] ) Thank you, Markus ------------------------------------- Markus Sveinn Markusson, Eng. Throun Ltd. Hofdabakka 9, 112 Reykjavik, Iceland Tel. +354 587-6788 Fax +354 567-4265 e-mail: markus@throun.is
John Bundgaard -- johnb@image.dk Thursday, September 26, 1996 Hi Markus. If I understand you correctly, then you do not need to do all what you are doing. Simply by setting the 'control' flag of the child-dialog window in the resource editor, should do the trick. I use this in a program, where i have a CFormView containing a tree- control in the right side. When the user changes the selection in the tree, I dynamicly changes a child dialog on the right side. John Bundgaard johnb@image.dk ---------- > I have a dialog form which consists of dynamically loaded CEdit > controls. These controls are loaded into a dynamically created > window. Simply put, these controls are CHILD windows in a dialog > CHILD window. > > I create a special CMyDialog::MyWndProc() function to grab all > user events from these controls. OK. When I press Tab in control > A I use SetFocus() to set focus to control B. OK. I press Tab in > control B but nothing happens. Switching focus (mouse) back to A > and then back to B again I notice that the cursor in control A > reflects the correct position in control B! It's almost as if > controls receiving focus this way seem to lose their ability > to route messages to CMyWndProc, WM_KEYDOWN for example. > > This is probably due to a glitch somewhere in my code but any > comments or help would be appreciated. > > Roughly stated this is what I do: > > - Dynamically create CMyWnd in CMyDialog. > - Dynamically create CMyEdit controls in CMyWnd. > - Call SetWindowLong() to hook CMyEdit to CMyDialog::MyWndProc() > - In CMyDialog::MyWndProc() call SetFocus() to next control on Tabs. > - Return from CMyDialog::MyWndProc() using > ::CallWindowProc( [WndProc returned from SetWindowLong()] )
| Вернуться в корень Архива |