0

I create a tab control in WM_INITDIALOG this way:

 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);

and also I create two dialog here to show in each tab as content of the tab. I create them with toolbox selecting formview dialog:

hwndTabcontentDialog1  = CreateDialogParam( GetModuleHandle( NULL ),
            MAKEINTRESOURCE( IDD_FORMVIEW1 ), hTab, (DLGPROC)Proc1,lParam );
hwndTabcontentDialog2  = CreateDialogParam( GetModuleHandle( NULL ),
        MAKEINTRESOURCE( IDD_FORMVIEW ), hTab, (DLGPROC)Proc2,lParam );

now in WM_NOTIFY I am doing this to content of each tab when its clicked:

 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 );
            }
              }

now the tab is created and everything is fine(content of current tab is not visible), but when I click on one of the tab items the dialog cover all the tab control and you cant see the tabs anymore. what is wrong ? what should I modify ?

user667222
  • 179
  • 3
  • 16
  • 1
    It sounds like you are setting the size of the child window to the size of the tab control. If so that won't work as the tabs are drawn in the client area instead of the non-client area. Get the height of the tabs, subtract from the height of the tab control and there is the size you should use (offset from the top of course). Alternatively the size might be correct but you are not giving it an offset to display below the actual tabs. – Captain Obvlious May 15 '13 at 02:52
  • you are right, when i change the X pos and Y pos of the child dialogs the parent tab control shows up but just when I change the positions from visual toolbar's properties. from inside of the code i couldn't change it using Getclientrect and setwindowpos functions. i used them either inside `wm_paint` and `wm_size` – user667222 May 15 '13 at 04:33

1 Answers1

0

Immediately after you create the dialogs reposition/resize them with MoveWindow. The TCM_ADJUSTRECT tab control message can help you figure out the proper position/size to make the dialogs.

ScottMcP-MVP
  • 10,337
  • 2
  • 15
  • 15