hi !
i've tried a test using tab controls but have problems , don't know why !

it's here : http://www.esnips.com/doc/ba2638d5-e4be-4541-b34d-6209aed5080a/tabcontroltest

summary :
i create a dialog1 as main dialog , dialog2 and dialog3 as child and will be used in tab controls , in dialog2 has a button name btn , problem is when i click btn , my program is like stop responding , all windows not repaint and become white


HWND current_tab;
DLGPROC tabproc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
current_tab = hWnd;
break;
case WM_CLOSE:
EndDialog(hWnd,0);
break;
default:
return (DLGPROC)0;
}
return (DLGPROC)1;
}
DLGPROC DlgProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
TC_ITEM tc;
HWND ha;
tc.cchTextMax = 128;
tc.pszText = L"this is tab1";
tc.mask = TCIF_TEXT;
SendDlgItemMessage(hWnd,IDC_TAB1,TCM_INSERTITEM,0,(long)&tc);
tc.pszText = L"this is tab2";
SendDlgItemMessage(hWnd,IDC_TAB1,TCM_INSERTITEM,1,(long)&tc);
ha = CreateDialogParam(GetModuleHandle(NULL),(LPCWSTR)102,GetDlgItem(hWnd,IDC_TAB1),(DLGPROC)tabproc,NULL);
RECT rect;
GetClientRect(GetDlgItem(hWnd,IDC_TAB1),&rect);
rect.bottom -=20;
MoveWindow(current_tab,0,20,rect.right,rect.bottom,true);
ShowWindow(ha,SW_SHOW);
break;
case WM_NOTIFY:
LPNMHDR p;
p = (LPNMHDR)lParam;
if(p->code==TCN_SELCHANGE)
{
DestroyWindow(current_tab);
long id = SendDlgItemMessage(hWnd,IDC_TAB1,TCM_GETCURSEL,0,0)+102;
HWND ha;
HWND tabtrip;
tabtrip = GetDlgItem(hWnd,IDC_TAB1);
ha = CreateDialogParam(GetModuleHandle(NULL),(LPCWSTR)id,tabtrip,(DLGPROC)tabproc,NULL);
RECT rect;
GetClientRect(GetDlgItem(hWnd,IDC_TAB1),&rect);
rect.bottom -=20;
MoveWindow(current_tab,0,20,rect.right,rect.bottom,true);
ShowWindow(ha,SW_SHOW);
}
break;
case WM_CLOSE:
EndDialog(hWnd,0);
break;
default:
return (DLGPROC)0;
}
return (DLGPROC)1;
}

int APIENTRY WinMain(HINSTANCE hinst,HINSTANCE hpre,LPSTR cmd,int show)
{
InitCommonControls();
DialogBoxParam(hinst,(LPCWSTR)IDD_DIALOG1,NULL,(DLGPROC)DlgProc,NULL);
return 1;
}


please help me ?
thanks.
Posted on 2007-05-05 05:40:34 by secmask