I had all my controls created on WM_CREATE, its a non-dialog app. Then i started thinking on using a Tab Control in order to gain some space in the client area. I know it would be easier to do ever4ything on a dialog based app using a rc file, but then id have to rewrite this to transpose all the controls to the rc file, and believe me, there are lots of them :)
And this at main.h:
TC_ITEM tie;
tie.mask = TCIF_TEXT | TCIF_IMAGE;
And woohoo, i can see the tab control with two tabs. My only question now is how do i get to attach some controls to one of the pages and some to the other, i mean, when im at tab 1 i should see some controls, when i click at tab two, i should stop seeing those controls and see others. Im starting to feel like creating the rc file maybe wouldnt be such a bad idea lol.
Any help would be great!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dont tell me i have to monitor the messages for when the user clicks a specific tab and send a message to each control i want to show/hide, is that really it?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Use a dialog box resource. Then, for each tab use another dialog box. When you get a notification of the tab changing, hide the other dialogs and show the main one. You will need to use the tab control as your parent window. Note that if you change the current tab through code, you will have to generate the notification manually. =)
Kip
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
And later at WM_NOTIFY:
case WM_NOTIFY:
switch (HIWORD(wParam)) {
case ID_TAB1:
MessageBox (NULL, TEXT ("Tab 1 clicked"), "Tab1", MB_ICONERROR);
return 0;
case 601:
MessageBox (NULL, TEXT ("Tab 2 clickeed"), "Tab2", MB_ICONERROR);
return 0;
I had all my controls created on WM_CREATE, its a non-dialog app. Then i started thinking on using a Tab Control in order to gain some space in the client area. I know it would be easier to do ever4ything on a dialog based app using a rc file, but then id have to rewrite this to transpose all the controls to the rc file, and believe me, there are lots of them :)
So i added this as the first thing at wm_create:
hwndTab = CreateWindow(WC_TABCONTROL, "",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE,
0, 148, 349, 245, mainWindow, (HMENU) 9, ((LPCREATESTRUCT) lParam)->hInstance, NULL);
TabCtrl_InsertItem(hwndTab, "Oranges", &tie);
TabCtrl_InsertItem(hwndTab, "Bananas", &tie);
And this at main.h:
TC_ITEM tie;
tie.mask = TCIF_TEXT | TCIF_IMAGE;
And woohoo, i can see the tab control with two tabs. My only question now is how do i get to attach some controls to one of the pages and some to the other, i mean, when im at tab 1 i should see some controls, when i click at tab two, i should stop seeing those controls and see others. Im starting to feel like creating the rc file maybe wouldnt be such a bad idea lol.
Any help would be great!
Dont tell me i have to monitor the messages for when the user clicks a specific tab and send a message to each control i want to show/hide, is that really it?
*hint*
Use a dialog box resource. Then, for each tab use another dialog box. When you get a notification of the tab changing, hide the other dialogs and show the main one. You will need to use the tab control as your parent window. Note that if you change the current tab through code, you will have to generate the notification manually. =)
Kip
Hey Kip, i guess youre right, i better go with dialogs and a rc file.
But maybe you can tell me why this doesnt work:
at WM_CREATE:
hwndTab = CreateWindow(WC_TABCONTROL, "",
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE,
0, 148, 349, 245, mainWindow, (HMENU) 9, ((LPCREATESTRUCT) lParam)->hInstance, NULL);
TabCtrl_InsertItem(hwndTab, 600, &tie);
TabCtrl_InsertItem(hwndTab, 601, &tie);
And later at WM_NOTIFY:
case WM_NOTIFY:
switch (HIWORD(wParam)) {
case ID_TAB1:
MessageBox (NULL, TEXT ("Tab 1 clicked"), "Tab1", MB_ICONERROR);
return 0;
case 601:
MessageBox (NULL, TEXT ("Tab 2 clickeed"), "Tab2", MB_ICONERROR);
return 0;
default:
return DefWindowProc (mainWindow, messages, wParam, lParam);
return 0;
}
I see the tabs but clicking them results on nothing... any idea?
Im sorry i was beeing lame, i need to get some sleep:
The correct way to deal with WM_NOTIFY is doing something like this:
case WM_NOTIFY:
switch (((NMHDR *)lParam)->code) {
case TCN_SELCHANGE:
MessageBox (NULL, TEXT ("TCN_SELCHANGE"), "Message", MB_ICONERROR);
break;
case TCN_SELCHANGING:
MessageBox (NULL, TEXT ("TCN_SELCHANGING"), "Message", MB_ICONERROR);
break;
}
break;