//宿主对话框的初始化过程
BOOL FormMain_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) { //这里定义了几个TabControl的标签
static LPSTR tabnames[]= {"Tab Page 1", "Tab Page 2", "Tab Page 3", "Tab Page 4", 0}; //然后是每个属性页的内容对话框名称
static LPSTR dlgnames[]= {MAKEINTRESOURCE(TAB_CONTROL_1_PAGE_1), MAKEINTRESOURCE(TAB_CONTROL_1_PAGE_2), MAKEINTRESOURCE(TAB_CONTROL_1_PAGE_3), MAKEINTRESOURCE(TAB_CONTROL_1_PAGE_4),0};
//同上面
static LPSTR tab2names[]= {"Page 1", "Page 2", "Page 3", "Page 4", 0}; static LPSTR dlg2names[]= {MAKEINTRESOURCE(TAB_CONTROL_2_PAGE_1), MAKEINTRESOURCE(TAB_CONTROL_2_PAGE_2), MAKEINTRESOURCE(TAB_CONTROL_2_PAGE_3), MAKEINTRESOURCE(TAB_CONTROL_2_PAGE_4),0}; //用作最小矩形的存储区域
RECT rc; //这个函数就是把宿主窗体的句柄和主菜单句柄存放到全局变量中
InitHandles (hwnd); //调用封装好的函数来创建(New)一个TabControl
New_TabControl( &TabCtrl_1,// address of TabControl struct
GetDlgItem(hwnd, TAB_CONTROL_1), // handle to tab control
tabnames, // text for each tab
dlgnames, // dialog id's of each tab page dialog
&FormMain_DlgProc, // address of main windows proc
&TabCtrl1_TabPages_OnSize, // optional address of size function or NULL
TRUE); // stretch tab page to fit tab ctrl
//同上
New_TabControl( &TabCtrl_2, GetDlgItem(hwnd, TAB_CONTROL_2), tab2names, dlg2names, &FormMain_DlgProc, &TabCtrl2_TabPages_OnSize, TRUE); //设定Tab Control 2 中Edit Cntrol中的初始文字
Edit_SetText(GetDlgItem(TabCtrl_2.hTabPages[0],LBL_3), "Use the Tab key to navagate between\r\ntab controls.\r\n\r\n" "Use the arrow keys or PageUp/Down keys\r\nto select a tab.\r\n\r\n" "Use the arrow keys to enter a tab page.\r\n\r\n" "Use the Tab key or arrow keys to navagate\r\ntab page child commands.\r\n\r\n" "Use Enter key to execute selected command.\r\n\r\n" "Try resizing the dialog while looking\r\nat different tabs.");
//----Everything else must follow the above----//
//Get the initial Width and height of the dialog
//in order to fix the minimum size of dialog
GetWindowRect(hwnd,&rc); gMinSize.cx = (rc.right - rc.left); gMinSize.cy = (rc.bottom - rc.top);
return 0; }
|