I have a tricky situation in my program. I have a dialog (implemented with a CFormView-derived class) with some normal controls on it as well as a special embedded property sheet (implemented with a CPropertySheet-derived class and a set of CPropertyPage-derived classes).
I have to do it this way because I dynamically change the pages in the property sheet throughout the life of the dialog and it is much easier to use a property sheet embedded as a child window to an invisible static control on the dialog and add and remove pages on it than it would be to manually implement a tab control and dynamically add and remove controls individually. It would be a lot more code to maintain too.
The embedded property sheet method was relatively straight-forward to implement and I have it all working just how I would like, except for the tab stops. I have a couple of problems with the tabstops.
The main thing is that the dynamic addition of the property sheet OnInitialUpdate of the dialog in which it is embedded leaves it in a state such that there are two separate tabstop chains: one for the dialog, and one for the property sheet and its pages. If I tab-around on the dialog, it just skips past the property sheet, its pages, and its controls. If I tab-around the property sheet, it never moves the focus away back to the dialog controls. Everything that I want to have a tabstop has one and they pretty much work, but there are these two separate chains of tabstops. How can I merge these chains? I am willing to consider any and all options.
My other problem with the tabstops is minor in comparison: I have a text edit control (implemented with a CEdit-derived class) which captures the tab character as text. I overrode the PreTranslateMessage function in my CEdit-derived class so that it inserts the tab character '\t' into the text of the control instead of changing the input focus. This "tab capturing" feature may be turned on and off, but when it is off it doesn't function correctly as the input focus changing mechanism that I would expect. It doesn't appear to do anything. Below is my code (for this feature only - not for the rest of the tabstop stuff above) please tell me what I can do to change it so that if the feature is turned off, the tab key will move the input focus instead of doing nothing. I considered calling SetFocus directly from here, but I couldn't figure out how to tell what the next control is in the tab order, other than by hard-coding it to a specific control, but that would make it harder to update and maintain so I'd rather not do that.
class CCodeEdit : public CEdit;
BOOL CCodeEdit::PreTranslateMessage(MSG* pMsg)
//allow tab characters to fall through to the edit text
if ((pMsg->message == WM_KEYDOWN) &&
(pMsg->wParam == VK_TAB) &&
//add the TAB character to the control
//no need to do a msg translation, so quit.
//that way no further processing of this message will be done
} //end if (inserting tab)
} //end PreTranslateMessage()