void UpdateStrings() { // Update window title PropSheet_SetTitle(g_cfgwnd, 0, l10n->title); // Update tab titles HWND tc = PropSheet_GetTabControl(g_cfgwnd); int numrows_prev = TabCtrl_GetRowCount(tc); wchar_t *titles[] = { l10n->tab_general, l10n->tab_input, l10n->tab_blacklist, l10n->tab_advanced, l10n->tab_about }; int i; for (i=0; i < ARRAY_SIZE(titles); i++) { TCITEM ti; ti.mask = TCIF_TEXT; ti.pszText = titles[i]; TabCtrl_SetItem(tc, i, &ti); } // Modify UI if number of rows have changed int numrows = TabCtrl_GetRowCount(tc); if (numrows_prev != numrows) { HWND page = PropSheet_GetCurrentPageHwnd(g_cfgwnd); if (page != NULL) { int diffrows = numrows-numrows_prev; WINDOWPLACEMENT wndpl = { sizeof(WINDOWPLACEMENT) }; // Resize window GetWindowPlacement(g_cfgwnd, &wndpl); wndpl.rcNormalPosition.bottom += 18*diffrows; SetWindowPlacement(g_cfgwnd, &wndpl); // Resize tabcontrol GetWindowPlacement(tc, &wndpl); wndpl.rcNormalPosition.bottom += 18*diffrows; SetWindowPlacement(tc, &wndpl); // Move button HWND button = GetDlgItem(g_cfgwnd, IDOK); GetWindowPlacement(button, &wndpl); int height = wndpl.rcNormalPosition.bottom-wndpl.rcNormalPosition.top; wndpl.rcNormalPosition.top += 18*diffrows; wndpl.rcNormalPosition.bottom = wndpl.rcNormalPosition.top+height; SetWindowPlacement(button, &wndpl); // Re-select tab PropSheet_SetCurSel(g_cfgwnd, page, 0); // Invalidate region GetWindowPlacement(g_cfgwnd, &wndpl); InvalidateRect(g_cfgwnd, &wndpl.rcNormalPosition, TRUE); } } }
// Entry point void OpenConfig(int startpage) { if (IsWindow(g_cfgwnd)) { PropSheet_SetCurSel(g_cfgwnd, 0, startpage); SetForegroundWindow(g_cfgwnd); return; } // Define the pages struct { int pszTemplate; DLGPROC pfnDlgProc; } pages[] = { { IDD_GENERALPAGE, GeneralPageDialogProc }, { IDD_INPUTPAGE, InputPageDialogProc }, { IDD_BLACKLISTPAGE, BlacklistPageDialogProc }, { IDD_ADVANCEDPAGE, AdvancedPageDialogProc }, { IDD_ABOUTPAGE, AboutPageDialogProc }, }; PROPSHEETPAGE psp[ARRAY_SIZE(pages)] = {}; int i; for (i=0; i < ARRAY_SIZE(pages); i++) { psp[i].dwSize = sizeof(PROPSHEETPAGE); psp[i].hInstance = g_hinst; psp[i].pszTemplate = MAKEINTRESOURCE(pages[i].pszTemplate); psp[i].pfnDlgProc = pages[i].pfnDlgProc; } // Define the property sheet PROPSHEETHEADER psh = { sizeof(PROPSHEETHEADER) }; psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USECALLBACK | PSH_USEHICON | PSH_NOAPPLYNOW | PSH_NOCONTEXTHELP; psh.hwndParent = NULL; psh.hInstance = g_hinst; psh.hIcon = icon[1]; psh.pszCaption = APP_NAME; psh.nPages = ARRAY_SIZE(pages); psh.ppsp = (LPCPROPSHEETPAGE) &psp; psh.pfnCallback = PropSheetProc; psh.nStartPage = startpage; // Open the property sheet PropertySheet(&psh); }
/* This function is called as soon as the property sheet has * finished initialising. We raise a AE_PREFSDIALOG event to allow * addons to attach their own property pages. */ UINT CALLBACK EXPORT BlinkmanPropertiesCallbackFunc( HWND hwnd, UINT uMsg, LPARAM lParam ) { AMPROPSHEETPAGE psp; if( PSCB_INITIALIZED == uMsg ) Amuser_CallRegistered( AE_BLINKPROPERTIESDIALOG, (LPARAM)(LPSTR)hwnd, (LPARAM)lpbeThis ); /* Add RAS page if Win32. */ psp.dwSize = sizeof( AMPROPSHEETPAGE ); psp.dwFlags = PSP_USETITLE; psp.hInstance = hInst; psp.pszTemplate = MAKEINTRESOURCE( IDDLG_BLINK_RAS ); psp.pszIcon = NULL; psp.pfnDlgProc = RASBlinkProperties; psp.pszTitle = "DUN"; psp.lParam = (LPARAM)lpbeThis; idRasTab = (int)PropSheet_AddPage( hwnd, &psp ); /* Set default selection. */ PropSheet_SetCurSel( hwnd, 0L, 0 ); return( 0 ); }