Control parent/child relationship
This program is only my second foray into GUI programming. The first was a homework assignment with FLTK. This one is a personal project in Win32. This is raw Win32, no visual this, visual that, .net this, .net that, etc. This is hand written code in Code::Blocks. So I'm learning Win32 as I go. Admittedly, this is a bit of a large project to be doing as a second jump into GUI and first jump into Win32. But I couldn't help it, and I'm having fun.
Anyway, when I need to look something up or ask a question about something, I've been googling. Sometimes I come across MSDN pages describing the components, sometimes I end up somewhere else like stackoverflow or a forum. Microsoft's own site, MSDN, may as well be encrypted in some English version of Navajo code talk half the time whenever I end up there. Win32 info elsewhere is, for some reason, actually kind of hard to come across. Definitely hard to get good explanations of certain things.
So what I'd like is some help explaining the parent/child relationship, and how a sort of tree of these relationships affects tab-key behavior and other things like focusing, etc. I'm finding the information online hard to decipher and sift through. Can anyone explain this stuff very simply? I think part of the reason for the confusion is the whole Window vs window thing, so can we just call buttons, boxes, etc controls instead for this discussion?
I have the following window.
The parent/child hierarchy is as follows:
Code:
main window
main window wndproc (handles the tab switching, acts by hiding the main static control on each tab, which hides all controls for that tab
tab control
tab1 (static control; wndproc for this tab is tied to this control - (SetWindowLongPtr(tab1, blahblah) )
all controls being shown on this tab
tab2 (static control; wndproc for this tab is tied to this control - (SetWindowLongPtr(tab2, blahblah) )
all controls being shown on this tab
tab3 etc...
So the tab control is a child of the main window (the whole entire window itself). Each tab has a static control with nothing displayed (the tutorial I read said this was one of the ways to get a tabbed interface to work), where each control being shown on that tab's visual space is a child of that static control. So clicking one one of the tabs is handled in the main windows wndproc, and it acts by hiding that static control, and with it, all of it's children seem to automatically get hidden. So going between the interface tabs is fine. Each tab also has it's own wndproc to handle messages from all of the controls shown on it's space. This in the SetWindowLongPtr function used to swap out a wndproc, the first parameter is the static control on that tab.
First of all, I'd like to know if this is fine so far with the parent/child relationship tree.
Second, I'm having a problem trying to get the tab key to work right. I've googled around and tried all that I found (and could make sense of). I have the IsDialogMessage in the message loop, and all of the controls have WS_TABSTOP. But depending on what I try, the tab key either only cycles through all of the controls on a tab's area, or it cycles through all of the tabs themselves in the interface at the top. I can't get it to do both. Like, go through all of the controls on a tab, then at the end, jump up to the tabs, then when going to the next tab, jump from IT, down to that tab's controls. Is this even possible? Does it make sense to do this?
Third, when I switch between the tabs, I'd like any control on the tab being switched away from to lose focus. Because even though that tab is now hidden because it was switched away from, if something has focus, keyboard presses are still acting on the hidden controls. I couldn't really find a way to do this, even after lots of googling. There's a set focus, but it seems that the kill focus isn't something that was supposed to be used manually? I don't know, but I couldn't get this to work without doing something hokey like just manually changing the focus to the first control on the new tab being shown.
I know this is long, but I hope it makes sense and I appreciate any help.