How开发者_高级运维 do i set another dialogbox visible inside the tab thats currently open in the Tab Control object?
I'm creating the Tab Control in the Visual Studio 2008 resource editor (or how its called?), i created IDD_FORMVIEW
dialogbox for the tab control.
I know how to initialize the tab texts, handle the currently selected tab with WM_NOTIFY
message, etc, but what im missing is: how to send the handle of my other dialogbox to the tab control page to display the dialogbox there?
All the 'tab pages' which are dialogues should be set as children to the tab that is created. When a tab is changed you will get a notify message which you can handle in your DialogProc like this:
case WM_NOTIFY: {
switch( ( ( LPNMHDR ) lParam) -> code ) {
case TCN_SELCHANGE: {
if( TabCtrl_GetCurSel( ( ( LPNMHDR ) lParam) -> hwndFrom ) == 0 ) {
ShowWindow( hwndPathSettings, SW_SHOW );
ShowWindow( hwndStartSettings, SW_HIDE );
} else {
ShowWindow( hwndPathSettings, SW_HIDE );
ShowWindow( hwndStartSettings, SW_SHOW );
}
break;
}
As you can see when the user changes the tab, the code shows the new tab child and hides the old ones. hwndPathSettings and hwndStartSettings in this case are the window handles to the child dialogues.
To put it in context, in your WM_INITDIALOG you would probably have some code similar to this to set up the tab:
HWND hwndTab = GetDlgItem( hwndDlg, IDC_TAB );
TCITEM tci = {0};
tci.mask = TCIF_TEXT;
tci.pszText = _T("Path");
TabCtrl_InsertItem( hwndTab, 0, &tci );
tci.pszText = _T("Run on Start");
TabCtrl_InsertItem( hwndTab, 1, &tci );
hwndPathSettings = CreateDialogParam( GetModuleHandle( NULL ),
MAKEINTRESOURCE( IDD_PATHSETTINGS ), hwndTab, PathSettingsProc, lParam );
hwndStartSettings = CreateDialog( GetModuleHandle( NULL ),
MAKEINTRESOURCE( IDD_STARTSETTINGS ), hwndTab, StartSettingsProc );
break;
精彩评论