create window in tab c++
I create tab with createwindow. I have 2 tab item and I want to create some static window in 2 tab item. I have use createwindow with parent is the handle to tab. But the child window is present in both tab1 and tab2. I want 2 tab item have a different content. So How can I do that.
Is there another way to create a Static control belong to the specific tab1 or tab 2 ... Not hwnd of tab from create window. I don't know how to do that so this is my solution
I use win api
Thanks
Here some of my code
TabCtrl_InsertItem(hwndTab,0,&tcitem);
TabCtrl_InsertItem(hwndTab,1,&tcitem);
hwndTab_1_1_1 = CreateWindow(L"BUTTON",L"sample",WS_CHILD|WS_VISIBLE,0,29,100,50,hwndTab,(HMENU)4,hInstance,NULL);
hwndTab_1_2_1 = CreateWindow(L"BUTTON",L"sample2",WS_CHILD|BS_AUTOCHECKBOX,20,80,100,50,hwndTab,(HMENU)4,hInstance,NULL);
and I'm using this:
case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == TCN_SELCHANGE) {
switch(TabCtrl_GetCurSel(hwndTab)) {
case 0:
ShowWindow(hwndTab_1_1_1,SW_SHOW);
ShowWindow(hwndTab_1_2_1,SW_HIDE);
break;
case 1: //
ShowWindow(hwndTab_1_1_1,SW_HIDE);
ShowWindow(hwndTab_1_2_1,SW_SHOW);
break;
default: return DefWindowProc(hwnd, Message, wParam, lParam);
}
}
else {
return DefWindowProc(hwnd, Message, wParam, lParam);
}
break;
I need the code to the same thing with these code. I don't want to use to much show and hide too many time if we have many child window.
you can try like this:
assume you have 3 tab pages.
T *pTabPage[3]; point to your 3 tab pages;
int nCurrentPage; to save your current tab page.
and when you want to change the tab page,
1.hide the "current page" that saved in the nCurrentPage: ShowWindow(pTabPage[nCurrentPage], SW_HIDE);
2.Get the really current page: nCurrentPage = GetCurSelect();
3.Show the really current page: ShowWindow(pTabPage[nCurrentPage], SW_SHOW);
the code is incorrect, just to explain the method
Hope to help you!
链接地址: http://www.djcxy.com/p/41200.html上一篇: 隐藏/显示选项卡控件Win32的子窗口
下一篇: 在选项卡c ++中创建窗口