WM_INITDIALOG
我以这种方式创建一个选项卡控件:
INITCOMMONCONTROLSEX icex = {0};
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_TAB_CLASSES;
InitCommonControlsEx(&icex);
TCITEM tie;
LPSTR text = "my tab";
tie.mask = TCIF_TEXT|TCIF_IMAGE;
tie.iImage = -1;
tie.pszText = text;
hTab = CreateWindow(WC_TABCONTROL, "", WS_CHILD |WS_CLIPSIBLINGS| WS_VISIBLE,
0,0, 400, 350, hWnd,NULL, g_hInstance, NULL);
TabCtrl_InsertItem(hTab,0,&tie);
TabCtrl_InsertItem(hTab,1,&tie);
TabCtrl_InsertItem(hTab,2,&tie);
我还在这里创建了两个对话框,以在每个选项卡中显示为选项卡的内容。我使用工具箱选择表单视图对话框创建它们:
hwndTabcontentDialog1 = CreateDialogParam( GetModuleHandle( NULL ),
MAKEINTRESOURCE( IDD_FORMVIEW1 ), hTab, (DLGPROC)Proc1,lParam );
hwndTabcontentDialog2 = CreateDialogParam( GetModuleHandle( NULL ),
MAKEINTRESOURCE( IDD_FORMVIEW ), hTab, (DLGPROC)Proc2,lParam );
现在WM_NOTIFY
我正在对每个选项卡的内容执行此操作:
case WM_NOTIFY:
switch (((LPNMHDR)lParam)->code)
{
case TCN_SELCHANGE:
{
if( TabCtrl_GetCurSel( ( ( LPNMHDR ) lParam) -> hwndFrom ) == 0 ) {
ShowWindow( hwndTabcontentDialog1, SW_SHOW );
ShowWindow( hwndTabcontentDialog2, SW_HIDE );
} else {
ShowWindow( hwndTabcontentDialog1, SW_HIDE );
ShowWindow( hwndTabcontentDialog2, SW_SHOW );
}
}
现在选项卡已创建并且一切正常(当前选项卡的内容不可见),但是当我单击其中一个选项卡项时,对话框覆盖了所有选项卡控件,您再也看不到选项卡了。怎么了 ?我应该修改什么?