How could I make a tab control and put different controls (listbox) in each section (i want 3). Im guessing you can use CreateWindow for the tab. But how would I add things to different tabs? Thanks :cool:
Printable View
How could I make a tab control and put different controls (listbox) in each section (i want 3). Im guessing you can use CreateWindow for the tab. But how would I add things to different tabs? Thanks :cool:
4 and a half hours being posted and only 4 views including mine!?!?!?!? sheesh. :rolleyes:
To create the tab control, use the CreateWindowEx function, and specify the WC_TABCONTROL constant as the window name. Since this is a common control, you need to link it with comctrl32.lib (I think that's the name) and call the InitCommonControls() function upon starting your App.
Next off, Tab control is not a parent window, hence you need to toggle each window's visibility when a tab is clicked. To tell when the tab is clicked, you need to process the TCN_SELCHANGING notification message (sent in the form of WM_NOTIFY).
The TabCtrl_GetCurSel macro or the TCM_GETCURSEL message tells the currently selected tab. You need to check which tab is selected, and toggle the visibility of your controls accordingly.
If you didn't understand this, let me know, and I'll write an example up for you.
Thanks megatron. One problem, I get this error
error C2065: 'InitCommonControls' : undeclared identifier
I've added the library file, InitComControls() didn't work either....
thanks :D
Did you remember to include the header file?
comctrl32.h isn't on my computer....so what iis the name of it?
commctrl.h, InitCommonControlsEx I think...but tab controls probably don't need loading.
InitCommonControlsEx() doesn't take 0 parameters it says. What goes in it? (the little tooltip mean nothing:p )and if I comment that out it says it can't open comctrl32.lib
:confused:
when I say InitCommonControls() it says comctrl32.lib can't be opened. :confused:
In order to user common controls library, you need to do two things. First add the header "commctrl.h" at the top of your file, and then add the lib file "comctl32.lib" in your project library list.
oh I entered comctrl32.lib not comctl32.lib thanks, now it runs....but how would I now show the tab control? like what should I enter into CreateWindow?
You use "WC_TABCONTROL" with CreateWindow. Here is a little example:Quote:
Originally posted by SteveCRM
oh I entered comctrl32.lib not comctl32.lib thanks, now it runs....but how would I now show the tab control? like what should I enter into CreateWindow?
I suggest that you read all about tab controls from here; it'll help you a lot:PHP Code:CreateWindow(
WC_TABCONTROL, "",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE,
0, 0, 100, 100,
hwndDlg, NULL, g_hinst, NULL
);
http://msdn.microsoft.com/library/de...Tab/Styles.asp
I have never used tab control because I always use propertysheet (which uses tab control itself) and I make different dialog box for each tab control.