Hi everybody,
Sorry for not stating the problem clearly yesterday.
I want to use tabcontrol in my win32 cpp project. Please check the code:
-------------------------------------------------------------------------------
BOOL OnInitTabControlDialog(HWND hWnd, HWND hWndFocus, LPARAM lParam)
{
INITCOMMONCONTROLSEX iccx;
iccx.dwSize = sizeof(INITCOMMONCONTROLSEX);
iccx.dwICC = ICC_TAB_CLASSES;
if (!InitCommonControlsEx(&iccx))
return FALSE;
RECT rect;
GetClientRect(hWnd, &rect);
hTab = CreateWindowEx(0, WC_TABCONTROL, 0,
TCS_FIXEDWIDTH | WS_CHILD | WS_VISIBLE,
rect.left + 2, (rect.bottom-rect.top)/3*2 , rect.right - 4, rect.bottom - 4,
hWnd, (HMENU)IDC_TAB, hInst, 0);
SendMessage(hTab, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
InsertTabItem(hTab, "First Page", 0);
InsertTabItem(hTab, "Second Page", 1);
MoveWindow(hTab, 2, (rect.bottom-rect.top)/3*2, rect.right-rect.left,(rect.bottom-rect.top)/3, TRUE);
RECT TabRect; GetClientRect(hTab,&TabRect);
h_TabDlg1=CreateDialog(hInst,MAKEINTRESOURCE(IDD_TabDIALOG1),hTab, TabDlgProc1);
h_TabDlg2=CreateDialog(hInst,MAKEINTRESOURCE(IDD_TabDIALOG2),hTab, TabDlgProc2);
MoveWindow(h_TabDlg1,TabRect.left+4,TabRect.top+4,TabRect.right -10,TabRect.bottom-15,true);
MoveWindow(h_TabDlg2,TabRect.left+4,TabRect.top+4,TabRect.right -10,TabRect.bottom-15,true);
ShowWindow(h_TabDlg1,SW_SHOW);
return TRUE;
}
-------------------------------------------------------------------------------
No matter how hard I try, h_TabDlg1 and h_TabDlg2 display on the top left conner of the screen.
Can somebody tell me what's wrong with my code ?
ps: win7, vs2010
Sincerely,
Zhishang.