void NewTerrainWindow::addDropdownListPair(const std::string& name, std::vector<UINT> listData) { const UINT count = (UINT)m_items.size(); const UINT width = 2 * m_dropdownListWidth + m_itemMargin; UINT x = m_itemMargin; UINT y = (count / 2) * (m_dropdownListTextSize + m_dropdownListHeight + m_itemMargin) + m_itemMargin; const UINT id = m_itemIDStart + count; const UINT dropdownListHeight = 200; HWND hText = CreateWindow("STATIC", name.c_str(), WS_VISIBLE | WS_CHILD, x, y, width, m_dropdownListTextSize, m_hWnd, NULL, m_hInstance, NULL); HFONT hFont = CreateFont(m_dropdownListTextSize, 0, 0, 0, FW_MEDIUM, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Tahoma"); SendMessage(hText, WM_SETFONT, (WPARAM)hFont, TRUE); y += m_dropdownListTextSize; HWND hDropdownList1 = CreateWindow("COMBOBOX", "", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | CBS_DROPDOWNLIST, x, y, m_dropdownListWidth, dropdownListHeight, m_hWnd, (HMENU)id, m_hInstance, NULL); x += m_dropdownListWidth + m_itemMargin; HWND hDropdownList2 = CreateWindow("COMBOBOX", "", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | CBS_DROPDOWNLIST, x, y, m_dropdownListWidth, dropdownListHeight, m_hWnd, (HMENU)(id + 1), m_hInstance, NULL); hFont = CreateFont(14, 0, 0, 0, FW_MEDIUM, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Tahoma"); SendMessage(hDropdownList1, WM_SETFONT, (WPARAM)hFont, TRUE); SendMessage(hDropdownList2, WM_SETFONT, (WPARAM)hFont, TRUE); m_items.push_back(EventElement(name, nullptr)); m_items.push_back(EventElement(name, nullptr)); for (std::vector<UINT>::iterator it = listData.begin(); it != listData.end(); it++) { std::string element = std::to_string((long double)(*it)); ComboBox_AddString(hDropdownList1, element.c_str()); ComboBox_AddString(hDropdownList2, element.c_str()); if (it == listData.begin()) { ComboBox_SelectString(hDropdownList1, -1, element.c_str()); ComboBox_SelectString(hDropdownList2, -1, element.c_str()); } } m_clientHeight += m_dropdownListTextSize + m_dropdownListHeight + m_itemMargin; const POINT windowSize = getWindowSize(); const POINT windowPosition = getWindowPosition(); SetWindowPos(m_hWnd, HWND_TOP, windowPosition.x, windowPosition.y, windowSize.x, windowSize.y, NULL); }
/** * @brief Load disk selection information into dialog * * @param hwndDlg Disk selection dialog * @param lpDiskSelection Disk selection */ static VOID LoadSelection( HWND hwndDlg, LPDISKSELECTION lpDiskSelection ) { int iDisk; for(iDisk = 0; iDisk < VUT_DISK_NUM; iDisk ++) { HWND hwnd; TCHAR lptstrLetter[2]; lptstrLetter[1] = TEXT('\0'); /* Load disk enable */ hwnd = GetDlgItem(hwndDlg, IDC_DISK_ENABLE_BASE + iDisk); if(NULL != hwnd) { Button_SetCheck(hwnd, ((lpDiskSelection->dwDiskEnable >> iDisk) & 0x1) ? BST_CHECKED : BST_UNCHECKED); } /* Load disk letter */ hwnd = GetDlgItem(hwndDlg, IDC_DISK_LETTER_BASE + iDisk); if(NULL != hwnd) { lptstrLetter[0] = lpDiskSelection->aDiskLetters[iDisk]; ComboBox_SelectString(hwnd, -1, lptstrLetter); } }
void populate_dir (void) { char buf[MAX_PATH]; char mask[MAX_MASK_LEN]; GetWindowText(GetDlgItem(hMainWindow, IDC_MANPATH), buf, sizeof(buf)); GetWindowText(GetDlgItem(hMainWindow, IDC_MASK), mask, sizeof(mask)); if (!DirectoryExists(buf)) { current_path_to_edit (); strcpy (buf, CurrentPath); } else { size_t off; off = strlen(buf); if ((off) && (buf[off-1] != '\\') && (buf[off-1] != '/')) { buf[off] = '\\'; buf[off+1] = 0; } strcpy (CurrentPath, buf); current_path_to_edit (); } DlgDirListComboBox(hMainWindow, buf, IDC_DRIVES, 0, DDL_DRIVES); DlgDirList (hMainWindow, buf, IDC_DIRS, 0, DDL_DIRECTORY + DDL_EXCLUSIVE); /* if you want to show only files that match mask - uncomment next line */ //strcat (buf, mask); DlgDirList (hMainWindow, buf, IDC_FILES, IDC_REALPATH, 0x27); snprintf (mask, sizeof(mask), "[-%c-]", 'a' +_getdrive() - 1); ComboBox_SelectString (GetDlgItem(hMainWindow, IDC_DRIVES), 0, mask); }
void plAnimComponentProc::SetBoxToAgeGlobal(HWND box, const char *varName) { char buff[512]; if (!varName || !strcmp(varName, "")) varName = "(none)"; ComboBox_SelectString(box, 0, varName); ComboBox_GetLBText(box, ComboBox_GetCurSel(box), buff); if (strcmp(varName, buff)) { // Didn't find our variable in the age SDL file... // Probably just missing the sdl file, // so we'll force it in there. It'll export fine. ComboBox_AddString(box, varName); ComboBox_SelectString(box, 0, varName); } }
//----------------------------------------------------------------------------- // Name: LoadOptions // Object: set user interface values according to pOptions object // Parameters : // in : // out : // return : //----------------------------------------------------------------------------- void CFilters::LoadOptions() { if (this->pOptions->FilterApplyToCurrentEntries) CheckDlgButton(this->hWndDialog,IDC_CHECK_FILTERS_APPLY_TO_CURRENT_RESULTS,BST_CHECKED); if (this->pOptions->FilterMinSize!=0) SetDlgItemInt(this->hWndDialog,IDC_EDIT_FILTERS_MIN_SIZE,this->pOptions->FilterMinSize,FALSE); if (this->pOptions->FilterMaxSize!=0) SetDlgItemInt(this->hWndDialog,IDC_EDIT_FILTERS_MAX_SIZE,this->pOptions->FilterMaxSize,FALSE); TCHAR psz[MAX_PATH]; if (this->pOptions->FilterMinAddress!=0) { _stprintf(psz,_T("0x%x"),this->pOptions->FilterMinAddress); SetDlgItemText(this->hWndDialog,IDC_EDIT_FILTERS_MIN_ADDRESS,psz); } if (this->pOptions->FilterMaxAddress!=0) { _stprintf(psz,_T("0x%x"),this->pOptions->FilterMaxAddress); SetDlgItemText(this->hWndDialog,IDC_EDIT_FILTERS_MAX_ADDRESS,psz); } HWND hWndComboFlags=GetDlgItem(this->hWndDialog,IDC_COMBO_FILTERS_FLAGS); switch (this->pOptions->FilterMemoryFlags) { case COptions::FILTERMEMORYFLAGS_ALL: ComboBox_SelectString(hWndComboFlags,-1,HEAP_WALKER_MEMORY_FLAG_ALL); break; case COptions::FILTERMEMORYFLAGS_FIXED: ComboBox_SelectString(hWndComboFlags,-1,HEAP_WALKER_MEMORY_FLAG_FIXED); break; case COptions::FILTERMEMORYFLAGS_MOVABLE: ComboBox_SelectString(hWndComboFlags,-1,HEAP_WALKER_MEMORY_FLAG_MOVABLE); break; case COptions::FILTERMEMORYFLAGS_FREE: ComboBox_SelectString(hWndComboFlags,-1,HEAP_WALKER_MEMORY_FLAG_FREE); break; } }
INT_PTR CALLBACK GeneralSettingsDlgProc(HWND hwndDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lParam) { LPPSHNOTIFY psn; langProcData langData = { .languages = GetDlgItem(hwndDlg, ID_CMB_LANGUAGE), .language = GetGUILanguage() }; switch(msg) { case WM_INITDIALOG: /* Populate UI language selection combo box */ EnumResourceLanguages( NULL, RT_STRING, MAKEINTRESOURCE(IDS_LANGUAGE_NAME / 16 + 1), (ENUMRESLANGPROC) FillLangListProc, (LONG_PTR) &langData ); /* If none of the available languages matched, select the fallback */ if (ComboBox_GetCurSel(langData.languages) == CB_ERR) ComboBox_SelectString(langData.languages, -1, LangListEntry(IDS_LANGUAGE_NAME, fallbackLangId)); /* Clear language id data for the selected item */ ComboBox_SetItemData(langData.languages, ComboBox_GetCurSel(langData.languages), 0); if (GetLaunchOnStartup()) Button_SetCheck(GetDlgItem(hwndDlg, ID_CHK_STARTUP), BST_CHECKED); break; case WM_NOTIFY: psn = (LPPSHNOTIFY) lParam; if (psn->hdr.code == (UINT) PSN_APPLY) { LANGID langId = (LANGID) ComboBox_GetItemData(langData.languages, ComboBox_GetCurSel(langData.languages)); if (langId != 0) SetGUILanguage(langId); SetLaunchOnStartup(Button_GetCheck(GetDlgItem(hwndDlg, ID_CHK_STARTUP)) == BST_CHECKED); SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR); return TRUE; } break; } return FALSE; }
BOOL CALLBACK RollupDialogProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam , NavInfoObject* th) { if ( !th && message != WM_INITDIALOG ) return FALSE; switch ( message ) { case WM_INITDIALOG: { HWND cb = GetDlgItem(hDlg, IDC_TYPE); int i; for(i = 0; i < 4; i++) ComboBox_AddString(cb, navTypes[i]); int type; th->pblock->GetValue(PB_TYPE, th->iObjParams->GetTime(), type, FOREVER); if (type < 0 || type > 3) type = 0; ComboBox_SelectString(cb, 0, navTypes[type]); return TRUE; } case WM_COMMAND: switch(HIWORD(wParam)) { case LBN_SELCHANGE: HWND cb = GetDlgItem(hDlg, IDC_TYPE); int curSel = ComboBox_GetCurSel(cb); if (curSel < 0 || curSel > 3) curSel = 0; th->pblock->SetValue(PB_TYPE, th->iObjParams->GetTime(), curSel); return TRUE; } default: return FALSE; } return FALSE; }
INT_PTR CALLBACK RollupDialogProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam , FogObject* th) { if ( !th && message != WM_INITDIALOG ) return FALSE; switch ( message ) { case WM_INITDIALOG: { HWND cb = GetDlgItem(hDlg, IDC_FOG_COMBO); int i; // gdf this prevents extra entries if the user cancel during create ComboBox_ResetContent(cb); for(i = 0; i < 2; i++) ComboBox_AddString(cb, fogTypes[i]); int type; th->pblock->GetValue(PB_TYPE, th->iObjParams->GetTime(), type, FOREVER); ComboBox_SelectString(cb, 0, fogTypes[type]); return TRUE; } case WM_COMMAND: switch(HIWORD(wParam)) { case LBN_SELCHANGE: HWND cb = GetDlgItem(hDlg, IDC_FOG_COMBO); int curSel = ComboBox_GetCurSel(cb); th->pblock->SetValue(PB_TYPE, th->iObjParams->GetTime(), curSel); return TRUE; } default: return FALSE; } return FALSE; }
INT_PTR CFilterDialog::OnInitDialog() { HIMAGELIST himl = ImageList_Create(16,16,ILC_COLOR32|ILC_MASK,0,48); HBITMAP hBitmap = LoadBitmap(GetModuleHandle(0),MAKEINTRESOURCE(IDB_SHELLIMAGES)); ImageList_Add(himl,hBitmap,NULL); m_hDialogIcon = ImageList_GetIcon(himl,SHELLIMAGES_FILTER,ILD_NORMAL); SetClassLongPtr(m_hDlg,GCLP_HICONSM,reinterpret_cast<LONG_PTR>(m_hDialogIcon)); DeleteObject(hBitmap); ImageList_Destroy(himl); HWND hComboBox = GetDlgItem(m_hDlg,IDC_FILTER_COMBOBOX); SetFocus(hComboBox); for each(auto strFilter in m_pfdps->m_FilterList) { SendMessage(hComboBox,CB_ADDSTRING,static_cast<WPARAM>(-1), reinterpret_cast<LPARAM>(strFilter.c_str())); } TCHAR szFilter[512]; m_pexpp->GetActiveShellBrowser()->GetFilter(szFilter,SIZEOF_ARRAY(szFilter)); ComboBox_SelectString(hComboBox,-1,szFilter); SendMessage(hComboBox,CB_SETEDITSEL,0,MAKELPARAM(0,-1)); if (m_pexpp->GetActiveShellBrowser()->GetFilterCaseSensitive()) CheckDlgButton(m_hDlg,IDC_FILTERS_CASESENSITIVE,BST_CHECKED); m_pfdps->RestoreDialogPosition(m_hDlg,true); return 0; }
INT PhSelectComboBoxString( _In_ HWND hwnd, _In_ PWSTR String, _In_ BOOLEAN Partial ) { if (Partial) { return ComboBox_SelectString(hwnd, -1, String); } else { INT index; index = ComboBox_FindStringExact(hwnd, -1, String); if (index == CB_ERR) return CB_ERR; ComboBox_SetCurSel(hwnd, index); return index; } }
static BOOL OnInitDialog (HWND hwnd, HWND hwndFocus, LPARAM lParam) { LPSECURITYALARMPARAMS lpsecurity = (LPSECURITYALARMPARAMS)lParam; HWND hwndUsers = GetDlgItem (hwnd, IDC_SALARM_BYUSER ); HWND hwndDB = GetDlgItem (hwnd, IDC_SALARM_ONTABLE); HWND hwndDBE = GetDlgItem (hwnd, IDC_SALARM_DBEVENT); HWND hwndCaptionDB= GetDlgItem (hwnd, IDC_SALARM_STATIC_DB); char szFormat [100]; char szTitle [180]; if (!AllocDlgProp (hwnd, lpsecurity)) return FALSE; bNoDisplayMessageDB = FALSE; // // force catolist.dll to load // CATOListDummy(); if (lpsecurity->bInstallLevel) { SetWindowText (hwndCaptionDB, "On:"); //"Create Security Alarm on Current Installation on %s" wsprintf (szTitle, ResourceString(IDS_F_CREATE_SECURITY), GetVirtNodeName ( GetCurMdiNodeHandle ())); } else { LoadString (hResource, (UINT)IDS_T_CREATE_SECURITY, szFormat, sizeof (szFormat)); wsprintf (szTitle, szFormat, GetVirtNodeName ( GetCurMdiNodeHandle ()), lpsecurity->DBName); } SetWindowText (hwnd, szTitle); Edit_LimitText (GetDlgItem (hwnd, IDC_SALARM_DBEVENT_TEXT), MAXOBJECTNAME-1); ZEROINIT (szSecurityDBEvent); LoadString (hResource, (UINT)IDS_I_NODBEVENT, szSecurityDBEvent, sizeof (szSecurityDBEvent)); // // Set the default to user // Button_SetCheck (GetDlgItem (hwnd, IDC_SALARM_USER), TRUE); // // Get the available users names and insert them into the CA list box // CAListBoxFillUsers (hwndUsers); // // Get the available DB names and insert them into the table list // if (lpsecurity->bInstallLevel) { char * pcurinst = ResourceString(IDS_CURRENT_INSTALLATION); CAListBox_AddString (hwndDB,pcurinst); CAListBox_SelectString(hwndDB,-1,pcurinst); lpsecurity->iObjectType = OT_VIRTNODE; EnableWindow(hwndDB,FALSE); EnableWindow(hwndDBE,FALSE); } else { CAListBoxFillDatabases (hwndDB); lpsecurity->iObjectType = OT_DATABASE; } if (!lpsecurity->bInstallLevel && !ComboBoxFillDBevents (hwndDBE, "iidbdb")) { ComboBoxDestroyItemData (hwndDBE); return FALSE; } { int k; char* buffowner; k = ComboBox_AddString (hwndDBE, szSecurityDBEvent); buffowner = ESL_AllocMem (x_strlen (szSecurityDBEvent) +1); x_strcpy (buffowner, szSecurityDBEvent); ComboBox_SetItemData (hwndDBE, k, buffowner); ComboBox_SelectString(hwndDBE, -1, szSecurityDBEvent); EnableControl (hwnd, FALSE); } PreCheckItem (hwnd); EnableDisableOKButton (hwnd); // // The value 9039 is defined in MAINMFC.H but is not accessible from this file: lpHelpStack = StackObject_PUSH (lpHelpStack, StackObject_INIT (lpsecurity->bInstallLevel? 9039: (UINT)IDD_SECURITY_ALARM2)); richCenterDialog (hwnd); return TRUE; }
void SetDlgOutlineTextSp(HWND hDlg,const int *idArray,const int *editWndArray) { if(!OpenClipboard(hDlg)) { AfxMessageBox(_T("clipboard fail!")); return; } UINT cfMp3Infp = RegisterClipboardFormat(CF_MP3INFP); HANDLE hText = GetClipboardData(cfMp3Infp); if(!hText) { return; } char *txtData = (char *)GlobalLock(hText); if(!txtData) { return; } int readOffset = 0; while(*(int *)(&(txtData[readOffset]))) { int id = *(int *)(&(txtData[readOffset])); readOffset += sizeof(int); int len = *(int *)(&(txtData[readOffset])); readOffset += sizeof(int); if(id != -1) { for(int i=0; idArray[i]!=0; i++) { if(idArray[i] == id) { HWND hwnd = GetDlgItem(hDlg,editWndArray[i]); LPCTSTR szTxt = (LPCTSTR)&(txtData[readOffset]); if(!IsButton(hwnd)) { // Edit or ComboBox if(GetWindowStyle(hwnd) & CBS_DROPDOWNLIST) { // TODO: Do we need to check the window class? ComboBox_SelectString(hwnd, 0, szTxt); } else { SetWindowText(hwnd, szTxt); } } else { // Checkbox int val = _ttoi(szTxt) ? 1 : 0; CheckDlgButton(hDlg,editWndArray[i],val); } break; } } } readOffset += (len + 1) * sizeof(TCHAR); } GlobalUnlock(hText); CloseClipboard(); }
// // CustomEntryDlgProc // // This function is the dialog procedure for the custom entry dialog and handles // the basic events that happen within that dialog // INT_PTR CALLBACK CustomEntryDlgProc( HWND hwndDlg, // handle to dialog box UINT uMsg, // message WPARAM wParam, // first message parameter LPARAM lParam // second message parameter ) { HWND hEditBox = NULL; // handle to an edit box HWND hComboBox = NULL; // handle to the combo box LPRASENTRYDLG lpInfo = NULL; // pointer to the RASENTRYDLG structure static LPRASENTRY lpRasEntry = NULL; // pointer to the RASENTRY structure static PSAMPLE_CUSTOM_ENTRY_DATA pData = NULL; // pointer to the SAMPLE_CUSTOM_ENTRY_DATA structure switch (uMsg) { case WM_INITDIALOG: { // set up the dialog and the parameters pData = (PSAMPLE_CUSTOM_ENTRY_DATA) lParam; if (!pData) { return FALSE; } lpInfo = &(pData->tEntryDlg); lpRasEntry = pData->ptEntry; hComboBox = GetDlgItem(hwndDlg, IDC_LIST_MODEMS); hEditBox = GetDlgItem(hwndDlg, IDC_EDIT_ENTRYNAME); if (hEditBox) { Edit_LimitText(hEditBox, RAS_MaxEntryName); // Count doesn't include NULL Edit_SetText(hEditBox, (LPTSTR)pData->szEntryName); } hEditBox = GetDlgItem(hwndDlg, IDC_EDIT_PHONENO); if (hEditBox) { Edit_LimitText(hEditBox, CELEMS(lpRasEntry->szLocalPhoneNumber) - 1); // Count doesn't include NULL Edit_SetText(hEditBox, lpRasEntry->szLocalPhoneNumber); } // // enumerate to get the device name to use - we'll just do modems // // first get the size of the buffer required LPRASDEVINFO lpRasDevInfo = NULL; // RASDEVINFO structure pointer DWORD dwNumEntries = 0; // number of entries returned DWORD dwSize = sizeof(RASDEVINFO); // size of buffer DWORD rc = 0; // return code // Allocate buffer with space for at least one structure lpRasDevInfo = (LPRASDEVINFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize); if (NULL == lpRasDevInfo) { return FALSE; } lpRasDevInfo->dwSize = sizeof(RASDEVINFO); rc = RasEnumDevices(lpRasDevInfo, &dwSize, &dwNumEntries); if (ERROR_BUFFER_TOO_SMALL == rc) { // If the buffer is too small, free the allocated memory and allocate a bigger buffer. if (HeapFree(GetProcessHeap(), 0, (LPVOID)lpRasDevInfo)) { lpRasDevInfo = (LPRASDEVINFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize); if (NULL == lpRasDevInfo) { OutputTraceString(L"--- Error allocating memory (HeapAlloc) for RASDEVINFO structures for RasEnumDevices(): %d\n", GetLastError()); return FALSE; } lpRasDevInfo->dwSize = sizeof(RASDEVINFO); rc = RasEnumDevices(lpRasDevInfo, &dwSize, &dwNumEntries); } else { // Couldn't free the memory return FALSE; } } // Check whether RasEnumDevices succeeded if (ERROR_SUCCESS == rc) { lpRasDevInfo = (LPRASDEVINFO) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize); if (NULL != lpRasDevInfo) { lpRasDevInfo->dwSize = sizeof(RASDEVINFO); rc = RasEnumDevices(lpRasDevInfo, &dwSize, &dwNumEntries); if (ERROR_SUCCESS == rc) { for (UINT i = 0; i < dwNumEntries; i++, lpRasDevInfo++) { if (lstrcmpi(lpRasDevInfo->szDeviceType, RASDT_Modem) == 0) { if (hComboBox) { // add to the list ComboBox_AddString(hComboBox, lpRasDevInfo->szDeviceName); } } } } HeapFree(GetProcessHeap(), 0, (LPVOID)lpRasDevInfo); lpRasDevInfo = NULL; } else { OutputTraceString(L"--- Error allocating memory (HeapAlloc) for RASDEVINFO structures for RasEnumDevices(): %d\n", GetLastError()); } } if (hComboBox) { // select the item we have in the entry ComboBox_SelectString(hComboBox, -1, lpRasEntry->szDeviceName); } // move dialog and position according to structure paramters // NOTE: we don't take into account multiple monitors or extreme // cases here as this is only a quick sample DWORD xPos = 0; // x coordinate position for centering DWORD yPos = 0; // y coordinate position for centering if (lpInfo->dwFlags & RASDDFLAG_PositionDlg) { xPos = lpInfo->xDlg; yPos = lpInfo->yDlg; } else { RECT rectTop; // parent rectangle used for centering RECT rectDlg; // dialog rectangle used for centering // center window within the owner or desktop GetWindowRect(lpInfo->hwndOwner != NULL ? lpInfo->hwndOwner : GetDesktopWindow(), &rectTop); GetWindowRect(hwndDlg, &rectDlg); xPos = ((rectTop.left + rectTop.right) / 2) - ((rectDlg.right - rectDlg.left) / 2); yPos = ((rectTop.top + rectTop.bottom) / 2) - ((rectDlg.bottom - rectDlg.top) / 2); } SetWindowPos(hwndDlg, NULL, xPos, yPos, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); return TRUE; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: { TCHAR szEntryName[RAS_MaxEntryName + 1] = {0}; // Entry name TCHAR szPhoneBook[MAX_PATH + 1] = {0}; // Phonebook path TCHAR szPhoneNumber[RAS_MaxPhoneNumber + 1] = {0}; // copy back the phonenumber, entry name, & device name hEditBox = GetDlgItem(hwndDlg, IDC_EDIT_PHONENO); if (hEditBox) { Edit_GetText(hEditBox, lpRasEntry->szLocalPhoneNumber, CELEMS(lpRasEntry->szLocalPhoneNumber)); } hEditBox = GetDlgItem(hwndDlg, IDC_EDIT_ENTRYNAME); if (hEditBox) { Edit_GetText(hEditBox, szEntryName, CELEMS(szEntryName)); } hEditBox = GetDlgItem(hwndDlg, IDC_EDIT_PHONENO); if (hEditBox) { Edit_GetText(hEditBox, szPhoneNumber, CELEMS(szPhoneNumber)); } hComboBox = GetDlgItem(hwndDlg, IDC_LIST_MODEMS); if (hComboBox) { ComboBox_GetLBText(hComboBox, ComboBox_GetCurSel(hComboBox), lpRasEntry->szDeviceName); } if (!pData) return FALSE; // Check entry name for validity StringCchCopy(szPhoneBook, CELEMS(szPhoneBook), (LPTSTR)pData->szPhoneBookPath); if (RasValidateEntryName(szPhoneBook, szEntryName) == ERROR_INVALID_NAME) { MessageBox(hwndDlg, L"The Entry Name is Invalid.", L"Entry name error", MB_OK); } else { StringCchCopy(pData->szEntryName, CELEMS(pData->szEntryName), szEntryName); StringCchCopy(lpRasEntry->szLocalPhoneNumber, CELEMS(lpRasEntry->szLocalPhoneNumber), szPhoneNumber); EndDialog(hwndDlg, TRUE); } return TRUE; } case IDCANCEL: EndDialog(hwndDlg, FALSE); return TRUE; } break; } return FALSE; }
BOOL CALLBACK AnchorDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam, AnchorObject *th) { TCHAR text[MAX_PATH]; int c, camIndex, i, type; HWND cb; Tab<INode *> cameras; switch (message) { case WM_INITDIALOG: th->ParentPickButton = GetICustButton(GetDlgItem(hDlg, IDC_PICK_PARENT)); th->ParentPickButton->SetType(CBT_CHECK); th->ParentPickButton->SetButtonDownNotify(TRUE); th->ParentPickButton->SetHighlightColor(GREEN_WASH); th->ParentPickButton->SetCheck(FALSE); th->dlgPrevSel = -1; th->hRollup = hDlg; if (th->triggerObject) Static_SetText(GetDlgItem(hDlg, IDC_TRIGGER_OBJ), th->triggerObject->GetName()); th->pblock->GetValue(PB_AN_TYPE, th->iObjParams->GetTime(), type, FOREVER); th->isJump = type == 0; EnableWindow(GetDlgItem(hDlg, IDC_ANCHOR_URL), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_PARAMETER), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_BOOKMARKS), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_CAMERA), !th->isJump); GetCameras(th->iObjParams->GetRootNode(), &cameras); c = cameras.Count(); cb = GetDlgItem(hDlg, IDC_CAMERA); camIndex = -1; for (i = 0; i < c; i++) { // add the name to the list TSTR name = cameras[i]->GetName(); int ind = ComboBox_AddString(cb, name.data()); ComboBox_SetItemData(cb, ind, cameras[i]); if (cameras[i] == th->cameraObject) camIndex = i; } if (camIndex != -1) ComboBox_SelectString(cb, 0, cameras[camIndex]->GetName()); Edit_SetText(GetDlgItem(hDlg, IDC_DESC), th->description.data()); Edit_SetText(GetDlgItem(hDlg, IDC_ANCHOR_URL), th->URL.data()); Edit_SetText(GetDlgItem(hDlg, IDC_PARAMETER), th->parameter.data()); if (pickMode) SetPickMode(th); return TRUE; case WM_DESTROY: if (pickMode) SetPickMode(th); //th->iObjParams->ClearPickMode(); //th->previousMode = NULL; ReleaseICustButton(th->ParentPickButton); return FALSE; case WM_MOUSEACTIVATE: return FALSE; case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_MOUSEMOVE: return FALSE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_BOOKMARKS: { // do bookmarks TSTR url, cam, desc; if (GetBookmarkURL(th->iObjParams, &url, &cam, &desc)) { // get the new URL information; Edit_SetText(GetDlgItem(hDlg, IDC_ANCHOR_URL), url.data()); Edit_SetText(GetDlgItem(hDlg, IDC_DESC), desc.data()); } } break; case IDC_CAMERA: if (HIWORD(wParam) == CBN_SELCHANGE) { cb = GetDlgItem(hDlg, IDC_CAMERA); int sel = ComboBox_GetCurSel(cb); INode *rtarg; rtarg = (INode *)ComboBox_GetItemData(cb, sel); th->ReplaceReference(2, rtarg); } break; case IDC_HYPERLINK: th->isJump = IsDlgButtonChecked(hDlg, IDC_HYPERLINK); EnableWindow(GetDlgItem(hDlg, IDC_ANCHOR_URL), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_PARAMETER), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_BOOKMARKS), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_CAMERA), !th->isJump); break; case IDC_SET_CAMERA: th->isJump = !IsDlgButtonChecked(hDlg, IDC_SET_CAMERA); EnableWindow(GetDlgItem(hDlg, IDC_ANCHOR_URL), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_PARAMETER), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_BOOKMARKS), th->isJump); EnableWindow(GetDlgItem(hDlg, IDC_CAMERA), !th->isJump); break; case IDC_PICK_PARENT: // Pick an object from the scene // Set the pickmode... switch (HIWORD(wParam)) { case BN_BUTTONDOWN: SetPickMode(th); /* if (th->previousMode) { // reset the command mode th->iObjParams->SetCommandMode(th->previousMode); th->previousMode = NULL; } else { th->previousMode = th->iObjParams->GetCommandMode(); theParentPick.SetAnchor(th); th->iObjParams->SetPickMode(&theParentPick); } */ break; } return TRUE; case IDC_ANCHOR_URL: switch (HIWORD(wParam)) { case EN_SETFOCUS: DisableAccelerators(); break; case EN_KILLFOCUS: EnableAccelerators(); break; case EN_CHANGE: Edit_GetText(GetDlgItem(hDlg, IDC_ANCHOR_URL), text, MAX_PATH); th->URL = text; } break; case IDC_DESC: switch (HIWORD(wParam)) { case EN_SETFOCUS: DisableAccelerators(); break; case EN_KILLFOCUS: EnableAccelerators(); break; case EN_CHANGE: Edit_GetText(GetDlgItem(hDlg, IDC_DESC), text, MAX_PATH); th->description = text; } break; case IDC_PARAMETER: switch (HIWORD(wParam)) { case EN_SETFOCUS: DisableAccelerators(); break; case EN_KILLFOCUS: EnableAccelerators(); break; case EN_CHANGE: Edit_GetText(GetDlgItem(hDlg, IDC_PARAMETER), text, MAX_PATH); th->parameter = text; } break; default: return FALSE; } } return FALSE; }
INT_PTR CALLBACK GeneralSettingsDlgProc(HWND hwndDlg, UINT msg, UNUSED WPARAM wParam, LPARAM lParam) { LPPSHNOTIFY psn; langProcData langData = { .languages = GetDlgItem(hwndDlg, ID_CMB_LANGUAGE), .language = GetGUILanguage() }; switch(msg) { case WM_INITDIALOG: /* Populate UI language selection combo box */ EnumResourceLanguages( NULL, RT_STRING, MAKEINTRESOURCE(IDS_LANGUAGE_NAME / 16 + 1), (ENUMRESLANGPROC) FillLangListProc, (LONG_PTR) &langData ); /* If none of the available languages matched, select the fallback */ if (ComboBox_GetCurSel(langData.languages) == CB_ERR) ComboBox_SelectString(langData.languages, -1, LangListEntry(IDS_LANGUAGE_NAME, fallbackLangId)); /* Clear language id data for the selected item */ ComboBox_SetItemData(langData.languages, ComboBox_GetCurSel(langData.languages), 0); if (GetLaunchOnStartup()) Button_SetCheck(GetDlgItem(hwndDlg, ID_CHK_STARTUP), BST_CHECKED); if (o.log_append) Button_SetCheck(GetDlgItem(hwndDlg, ID_CHK_LOG_APPEND), BST_CHECKED); if (o.silent_connection) Button_SetCheck(GetDlgItem(hwndDlg, ID_CHK_SILENT), BST_CHECKED); if (o.show_balloon == 0) CheckRadioButton (hwndDlg, ID_RB_BALLOON0, ID_RB_BALLOON2, ID_RB_BALLOON0); else if (o.show_balloon == 1) CheckRadioButton (hwndDlg, ID_RB_BALLOON0, ID_RB_BALLOON2, ID_RB_BALLOON1); else if (o.show_balloon == 2) CheckRadioButton (hwndDlg, ID_RB_BALLOON0, ID_RB_BALLOON2, ID_RB_BALLOON2); if (o.show_script_window) Button_SetCheck(GetDlgItem(hwndDlg, ID_CHK_SHOW_SCRIPT_WIN), BST_CHECKED); break; case WM_NOTIFY: psn = (LPPSHNOTIFY) lParam; if (psn->hdr.code == (UINT) PSN_APPLY) { LANGID langId = (LANGID) ComboBox_GetItemData(langData.languages, ComboBox_GetCurSel(langData.languages)); if (langId != 0) SetGUILanguage(langId); SetLaunchOnStartup(Button_GetCheck(GetDlgItem(hwndDlg, ID_CHK_STARTUP)) == BST_CHECKED); o.log_append = (Button_GetCheck(GetDlgItem(hwndDlg, ID_CHK_LOG_APPEND)) == BST_CHECKED); o.silent_connection = (Button_GetCheck(GetDlgItem(hwndDlg, ID_CHK_SILENT)) == BST_CHECKED); if (IsDlgButtonChecked(hwndDlg, ID_RB_BALLOON0)) o.show_balloon = 0; else if (IsDlgButtonChecked(hwndDlg, ID_RB_BALLOON2)) o.show_balloon = 2; else o.show_balloon = 1; o.show_script_window = (Button_GetCheck(GetDlgItem(hwndDlg, ID_CHK_SHOW_SCRIPT_WIN)) == BST_CHECKED); SaveRegistryKeys(); SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR); return TRUE; } break; } return FALSE; }
static BOOL OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) { LPTABLEPARAMS lptbl = (LPTABLEPARAMS)lParam; if (!AllocDlgProp(hwnd, lptbl)) return FALSE; // // OpenIngres Version 2.0 only // Initialize the Combobox of page_size. ComboBox_InitPageSize (hwnd, lptbl->uPage_size); if (GetOIVers() == OIVERS_12) { ShowWindow (GetDlgItem (hwnd, IDC_STATIC_PS), SW_HIDE); ShowWindow (GetDlgItem (hwnd, IDC_COMBOPAGESIZE), SW_HIDE); } else { ShowWindow (GetDlgItem (hwnd, IDC_STATIC_PS), SW_SHOW); ShowWindow (GetDlgItem (hwnd, IDC_COMBOPAGESIZE), SW_SHOW); } if (GetOIVers() >= OIVERS_30) { HWND hwndC = GetDlgItem(hwnd, IDC_STATIC1); if (hwndC) ShowWindow (hwndC, SW_HIDE); hwndC = GetDlgItem(hwnd, IDC_LABEL_GRAN); if (hwndC) ShowWindow (hwndC, SW_HIDE); } if (!OccupyLabelControl(hwnd) || !OccupyAuditOptionControl(hwnd) || !OccupyAuditKeyControl(hwnd) || !OccupyLocationControl(hwnd)) { ASSERT(NULL); return FALSE; } CheckDlgButton(hwnd, IDC_JOURNALING, lptbl->bJournaling); CheckDlgButton(hwnd, IDC_DUPLICATES, lptbl->bDuplicates); if (lptbl->nSecAudit != USE_DEFAULT) { SelectComboBoxItem(GetDlgItem(hwnd, IDC_SEC_AUDIT_OPTION), auditTypes, lptbl->nSecAudit); } if (lptbl->nLabelGran != USE_DEFAULT) { SelectComboBoxItem(GetDlgItem(hwnd, IDC_LABEL_GRAN), labelTypes, lptbl->nLabelGran); } if (*lptbl->szSecAuditKey) { ComboBox_SelectString(GetDlgItem(hwnd, IDC_SEC_AUDIT_KEY), -1, lptbl->szSecAuditKey); } if (lptbl->lpLocations) { LPOBJECTLIST lplist = lptbl->lpLocations; while (lplist) { LPCHECKEDOBJECTS lpObj = (LPCHECKEDOBJECTS)lplist->lpObject; CAListBox_SelectString(GetDlgItem(hwnd, IDC_LOCATIONS), -1, lpObj->dbname); lplist = lplist->lpNext; } } if (GetOIVers() != OIVERS_12) lpHelpStack = StackObject_PUSH (lpHelpStack, StackObject_INIT ((UINT)IDD_OIV2_TABLESTRUCT)); else lpHelpStack = StackObject_PUSH (lpHelpStack, StackObject_INIT ((UINT)IDD_TABLESTRUCT)); richCenterDialog(hwnd); return TRUE; }
static void onCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify) { char szCurDir[_MAX_PATH]; switch(id) { case ID_LIST_DIR: if(codeNotify == LBN_DBLCLK) { int index = ListBox_GetCurSel(hWndCtl); DWORD dwItemData = ListBox_GetItemData(hWndCtl, index); if(HIWORD(dwItemData) == ID_ICON_OPENSELECT) { shutDialog(hWnd); char szString[_MAX_PATH]; Edit_GetText(GetDlgItem(hWndDirPicker, ID_EDIT_DIR), szString, sizeof(szString)); lstrcpy(lpszStringToReturn, szString); EndDialog(hWnd, IDOK); break; } ListBox_GetText(hWndCtl, index, szCurDir); char szDir[_MAX_DIR]; LPSTR lpsz; if((HIWORD(dwItemData) == ID_ICON_FOLDEROPEN) && (index != 0)) { GetWindowText(hWndCtl, szDir, sizeof(szDir)); lpsz=_fstrstr(szDir, szCurDir); *(lpsz + lstrlen(szCurDir)) = '\0'; lstrcpy(szCurDir, szDir); } if (_chdir(szCurDir) == 0) { _getcwd(szCurDir, _MAX_PATH); fillListBox(hWndDirPicker, szCurDir); } } break; case ID_COMBO_DIR: if(codeNotify == CBN_SELCHANGE) { char szDrive[80]; int index = ComboBox_GetCurSel(hWndCtl); if(index == CB_ERR) break; ComboBox_GetLBText(hWndCtl, index, szDrive); int iCurDrive = _getdrive(); Retry: HCURSOR hCursorOld = SetCursor(LoadCursor(NULL, IDC_WAIT)); SetCapture(hWndDirPicker); if((0 == _chdrive((int)(szDrive[0] - 'a' + 1))) && (NULL != _getcwd(szCurDir, _MAX_PATH))) { fillListBox(hWndDirPicker, szCurDir); ListBox_SetTopIndex(GetDlgItem(hWndDirPicker, ID_LIST_DIR), 0); SetCursor(hCursorOld); ReleaseCapture(); break; } SetCursor(hCursorOld); ReleaseCapture(); char szText[80]; sprintf(szText, "Cannot read drive %c:", szDrive[0]); if(IDRETRY == MessageBox(hWndDirPicker, szText, "Choose Directory", MB_ICONEXCLAMATION|MB_RETRYCANCEL)) goto Retry; //Changing drives failed so restore drive and selection _chdrive(iCurDrive); sprintf(szDrive, "%c:", (char)(iCurDrive + 'a' - 1)); index = ComboBox_SelectString(hWndCtl, -1, szDrive); } break; case IDOK: shutDialog(hWnd); char szString[_MAX_PATH]; Edit_GetText(GetDlgItem(hWndDirPicker, ID_EDIT_DIR), szString, sizeof(szString)); lstrcpy(lpszStringToReturn, szString); EndDialog(hWnd, IDOK); break; case IDCANCEL: shutDialog(hWnd); lpszStringToReturn[0] = '\0'; EndDialog(hWnd, IDCANCEL); break; default: break; } }
/* This function handles the WM_COMMAND message. */ void FASTCALL ChangeDir_OnCommand( HWND hwnd, int id, HWND hwndCtl, UINT codeNotify ) { static BOOL fListHasFocus = FALSE; switch( id ) { case IDD_NETWORK: if( WNetConnectionDialog( hwnd, WNTYPE_DRIVE ) == WN_SUCCESS ) { #ifndef WIN32 HINSTANCE hinstNetDriver; int iDrive; hinstNetDriver = (HINSTANCE)WNetGetCaps( 0xFFFF ); if( hinstNetDriver ) { LPWNETGETLASTCONNECTION lpDialogAPI; lpDialogAPI = (LPWNETGETLASTCONNECTION)GetProcAddress( hinstNetDriver, (LPSTR)ORD_WNETGETLASTCONNECTION); if( lpDialogAPI != NULL ) if( lpDialogAPI( WNTYPE_DRIVE, &iDrive ) == WN_SUCCESS ) { ++iDrive; DriveListInitialize( GetDlgItem( hwnd, IDD_DRIVELIST ), GetDlgItem( hwnd, IDD_TEMPLIST ), iDrive ); // SendDlgCommand( hwnd, IDD_DRIVELIST, CBN_SELCHANGE ); } } #endif } break; case IDD_DIRECTORYLIST: if( codeNotify == LBN_SETFOCUS ) fListHasFocus = TRUE; else if( codeNotify == LBN_KILLFOCUS ) fListHasFocus = FALSE; else if( codeNotify == LBN_DBLCLK ) { UINT i; DWORD dw; char szDir[_MAX_PATH]; char szCurDir[_MAX_PATH]; LPSTR lpsz; /* On double-click, change directory and reinit the * listbox. But all we stored in the string was * the directory's single name, so we use the bitmap * type to tell if we're below the current directory * (in which case we just chdir to our name) or above * (in which case we prepend "..\"'s as necessary. */ i = ListBox_GetCurSel( hwndCtl ); dw = ListBox_GetItemData( hwndCtl, i ); /* If out bitmap is IDB_FOLDERCLOSED or the root, * then just . If we're IDB_FOLDEROPENSELECT, * don't do anything. If we're IDB_FOLDEROPEN then * we get the full current path and truncate it * after the directory to which we're switching. */ if( IDB_FOLDEROPENSELECT == HIWORD( dw ) ) { id = IDOK; goto CloseDialog; } /* Get get the directory for sub-directory changes. */ ListBox_GetText( hwndCtl, i, szCurDir ); if( IDB_FOLDEROPEN == HIWORD( dw ) && 0 != i ) { /* Get the current path and find us in this path */ GetWindowText( hwndCtl, szDir, sizeof( szDir ) ); lpsz=_fstrstr( szDir, szCurDir ); /* Null terminate right after us. */ *( lpsz + strlen( szCurDir ) ) = '\0'; /* Get this new directory in the right place */ strcpy( szCurDir, szDir ); } /* chdir has a nice way of validating for us. */ if( 0 == _chdir( szCurDir ) ) { /* Get the new full path. */ Amdir_GetCurrentDirectory( szCurDir, _MAX_PATH ); DirectoryListInitialize( hwndCtl, GetDlgItem( hwnd, IDD_TEMPLIST ), szCurDir ); //???? YH18/04/96 AnsiLower( szCurDir ); SetDlgItemText( hwnd, IDD_EDIT, szCurDir ); } } break; case IDD_DRIVELIST: if( codeNotify == CBN_SELCHANGE ) { UINT i, iCurDrive; char szCurDir[ _MAX_PATH ]; char szDrive[ _MAX_PATH ]; /* Enough for drive:volume */ /* Get the first letter in the current selection */ i = ComboBox_GetCurSel( hwndCtl ); ComboBox_GetLBText( hwndCtl, i, szDrive ); iCurDrive = _getdrive(); /* Save in case of restore */ /* Attempt to set the drive and get the current * directory on it. Both must work for the change * to be certain. If we are certain, reinitialize * the directories. Note that we depend on drives * stored as lower case in the combobox. */ if( _chdrive( (int)( szDrive[ 0 ] - 'a' + 1 ) ) == 0 && ( Amdir_GetCurrentDirectory( szCurDir, _MAX_PATH ) != 0 ) ) { DirectoryListInitialize( GetDlgItem( hwnd, IDD_DIRECTORYLIST ), GetDlgItem( hwnd, IDD_TEMPLIST ), szCurDir ); /* Insure that the root is visible (UI guideline) */ SendDlgItemMessage( hwnd, IDD_DIRECTORYLIST, LB_SETTOPINDEX, 0, 0L ); AnsiLower( szCurDir ); SetDlgItemText( hwnd, IDD_EDIT, szCurDir ); break; } /* Changing drives failed so restore drive and selection */ _chdrive( (int)iCurDrive ); wsprintf( szDrive, "%c:", (char)( iCurDrive + 'a' - 1 ) ); ComboBox_SelectString( hwndCtl, -1, szDrive ); } break; case IDD_EDIT: if( codeNotify == EN_UPDATE ) EnableControl( hwnd, IDOK, Edit_GetTextLength( hwndCtl ) > 0 ); break; case IDOK: { LPCHGDIR lpChgDir; if( fListHasFocus ) { // PostDlgCommand( hwnd, IDD_DIRECTORYLIST, LBN_DBLCLK ); break; } CloseDialog: lpChgDir = (LPCHGDIR)GetWindowLong( hwnd, DWL_USER ); Edit_GetText( GetDlgItem( hwnd, IDD_EDIT ), lpChgDir->szPath, sizeof( lpChgDir->szPath ) ); } case IDCANCEL: { register int i; for( i = IDB_DRIVEMIN; i <= IDB_DRIVEMAX; i++ ) DeleteBitmap( rghBmpDrives[ i - IDB_DRIVEMIN ] ); for( i = IDB_FOLDERMIN; i <= IDB_FOLDERMAX; i++ ) DeleteBitmap( rghBmpFolders[ i - IDB_FOLDERMIN ] ); fBitmapsLoaded = FALSE; _chdrive( iCurDrive ); _chdir( szDefDir ); EndDialog( hwnd, id == IDOK ); break; } } }
INT_PTR CALLBACK PhpServiceGeneralDlgProc( __in HWND hwndDlg, __in UINT uMsg, __in WPARAM wParam, __in LPARAM lParam ) { switch (uMsg) { case WM_INITDIALOG: { LPPROPSHEETPAGE propSheetPage = (LPPROPSHEETPAGE)lParam; PSERVICE_PROPERTIES_CONTEXT context = (PSERVICE_PROPERTIES_CONTEXT)propSheetPage->lParam; PPH_SERVICE_ITEM serviceItem = context->ServiceItem; SC_HANDLE serviceHandle; // HACK PhCenterWindow(GetParent(hwndDlg), GetParent(GetParent(hwndDlg))); SetProp(hwndDlg, PhMakeContextAtom(), (HANDLE)context); PhAddComboBoxStrings(GetDlgItem(hwndDlg, IDC_TYPE), PhServiceTypeStrings, sizeof(PhServiceTypeStrings) / sizeof(WCHAR *)); PhAddComboBoxStrings(GetDlgItem(hwndDlg, IDC_STARTTYPE), PhServiceStartTypeStrings, sizeof(PhServiceStartTypeStrings) / sizeof(WCHAR *)); PhAddComboBoxStrings(GetDlgItem(hwndDlg, IDC_ERRORCONTROL), PhServiceErrorControlStrings, sizeof(PhServiceErrorControlStrings) / sizeof(WCHAR *)); SetDlgItemText(hwndDlg, IDC_DESCRIPTION, serviceItem->DisplayName->Buffer); ComboBox_SelectString(GetDlgItem(hwndDlg, IDC_TYPE), -1, PhGetServiceTypeString(serviceItem->Type)); ComboBox_SelectString(GetDlgItem(hwndDlg, IDC_STARTTYPE), -1, PhGetServiceStartTypeString(serviceItem->StartType)); ComboBox_SelectString(GetDlgItem(hwndDlg, IDC_ERRORCONTROL), -1, PhGetServiceErrorControlString(serviceItem->ErrorControl)); serviceHandle = PhOpenService(serviceItem->Name->Buffer, SERVICE_QUERY_CONFIG); if (serviceHandle) { LPQUERY_SERVICE_CONFIG config; PPH_STRING description; BOOLEAN delayedStart; if (config = PhGetServiceConfig(serviceHandle)) { SetDlgItemText(hwndDlg, IDC_GROUP, config->lpLoadOrderGroup); SetDlgItemText(hwndDlg, IDC_BINARYPATH, config->lpBinaryPathName); SetDlgItemText(hwndDlg, IDC_USERACCOUNT, config->lpServiceStartName); PhFree(config); } if (description = PhGetServiceDescription(serviceHandle)) { SetDlgItemText(hwndDlg, IDC_DESCRIPTION, description->Buffer); PhDereferenceObject(description); } if (PhGetServiceDelayedAutoStart(serviceHandle, &delayedStart)) { context->OldDelayedStart = delayedStart; if (delayedStart) Button_SetCheck(GetDlgItem(hwndDlg, IDC_DELAYEDSTART), BST_CHECKED); } CloseServiceHandle(serviceHandle); } SetDlgItemText(hwndDlg, IDC_PASSWORD, L"password"); Button_SetCheck(GetDlgItem(hwndDlg, IDC_PASSWORDCHECK), BST_UNCHECKED); SetDlgItemText(hwndDlg, IDC_SERVICEDLL, L"N/A"); { HANDLE keyHandle; PPH_STRING keyName; keyName = PhConcatStrings( 3, L"System\\CurrentControlSet\\Services\\", serviceItem->Name->Buffer, L"\\Parameters" ); if (NT_SUCCESS(PhOpenKey( &keyHandle, KEY_READ, PH_KEY_LOCAL_MACHINE, &keyName->sr, 0 ))) { PPH_STRING serviceDllString; if (serviceDllString = PhQueryRegistryString(keyHandle, L"ServiceDll")) { PPH_STRING expandedString; if (expandedString = PhExpandEnvironmentStrings(&serviceDllString->sr)) { SetDlgItemText(hwndDlg, IDC_SERVICEDLL, expandedString->Buffer); PhDereferenceObject(expandedString); } PhDereferenceObject(serviceDllString); } NtClose(keyHandle); } PhDereferenceObject(keyName); } PhpRefreshControls(hwndDlg); context->Ready = TRUE; } break; case WM_DESTROY: { RemoveProp(hwndDlg, PhMakeContextAtom()); } break; case WM_COMMAND: { PSERVICE_PROPERTIES_CONTEXT context = (PSERVICE_PROPERTIES_CONTEXT)GetProp(hwndDlg, PhMakeContextAtom()); switch (LOWORD(wParam)) { case IDCANCEL: { // Workaround for property sheet + multiline edit: http://support.microsoft.com/kb/130765 SendMessage(GetParent(hwndDlg), uMsg, wParam, lParam); } break; case IDC_PASSWORD: { if (HIWORD(wParam) == EN_CHANGE) { Button_SetCheck(GetDlgItem(hwndDlg, IDC_PASSWORDCHECK), BST_CHECKED); } } break; case IDC_DELAYEDSTART: { context->Dirty = TRUE; } break; case IDC_BROWSE: { static PH_FILETYPE_FILTER filters[] = { { L"Executable files (*.exe;*.sys)", L"*.exe;*.sys" }, { L"All files (*.*)", L"*.*" } }; PVOID fileDialog; PPH_STRING fileName; fileDialog = PhCreateOpenFileDialog(); PhSetFileDialogFilter(fileDialog, filters, sizeof(filters) / sizeof(PH_FILETYPE_FILTER)); fileName = PhGetFileName(PHA_GET_DLGITEM_TEXT(hwndDlg, IDC_BINARYPATH)); PhSetFileDialogFileName(fileDialog, fileName->Buffer); PhDereferenceObject(fileName); if (PhShowFileDialog(hwndDlg, fileDialog)) { fileName = PhGetFileDialogFileName(fileDialog); SetDlgItemText(hwndDlg, IDC_BINARYPATH, fileName->Buffer); PhDereferenceObject(fileName); } PhFreeFileDialog(fileDialog); } break; } switch (HIWORD(wParam)) { case EN_CHANGE: case CBN_SELCHANGE: { PhpRefreshControls(hwndDlg); if (context->Ready) context->Dirty = TRUE; } break; } } break; case WM_NOTIFY: { LPNMHDR header = (LPNMHDR)lParam; switch (header->code) { case PSN_QUERYINITIALFOCUS: { SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (LONG_PTR)GetDlgItem(hwndDlg, IDC_TYPE)); } return TRUE; case PSN_KILLACTIVE: { SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, FALSE); } return TRUE; case PSN_APPLY: { NTSTATUS status; PSERVICE_PROPERTIES_CONTEXT context = (PSERVICE_PROPERTIES_CONTEXT)GetProp(hwndDlg, PhMakeContextAtom()); PPH_SERVICE_ITEM serviceItem = context->ServiceItem; SC_HANDLE serviceHandle; PPH_STRING newServiceTypeString; PPH_STRING newServiceStartTypeString; PPH_STRING newServiceErrorControlString; ULONG newServiceType; ULONG newServiceStartType; ULONG newServiceErrorControl; PPH_STRING newServiceGroup; PPH_STRING newServiceBinaryPath; PPH_STRING newServiceUserAccount; PPH_STRING newServicePassword; SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR); if (!context->Dirty) { return TRUE; } newServiceTypeString = PHA_DEREFERENCE(PhGetWindowText(GetDlgItem(hwndDlg, IDC_TYPE))); newServiceStartTypeString = PHA_DEREFERENCE(PhGetWindowText(GetDlgItem(hwndDlg, IDC_STARTTYPE))); newServiceErrorControlString = PHA_DEREFERENCE(PhGetWindowText(GetDlgItem(hwndDlg, IDC_ERRORCONTROL))); newServiceType = PhGetServiceTypeInteger(newServiceTypeString->Buffer); newServiceStartType = PhGetServiceStartTypeInteger(newServiceStartTypeString->Buffer); newServiceErrorControl = PhGetServiceErrorControlInteger(newServiceErrorControlString->Buffer); newServiceGroup = PHA_DEREFERENCE(PhGetWindowText(GetDlgItem(hwndDlg, IDC_GROUP))); newServiceBinaryPath = PHA_DEREFERENCE(PhGetWindowText(GetDlgItem(hwndDlg, IDC_BINARYPATH))); newServiceUserAccount = PHA_DEREFERENCE(PhGetWindowText(GetDlgItem(hwndDlg, IDC_USERACCOUNT))); if (Button_GetCheck(GetDlgItem(hwndDlg, IDC_PASSWORDCHECK)) == BST_CHECKED) { newServicePassword = PhGetWindowText(GetDlgItem(hwndDlg, IDC_PASSWORD)); } else { newServicePassword = NULL; } if (newServiceType == SERVICE_KERNEL_DRIVER && newServiceUserAccount->Length == 0) { newServiceUserAccount = NULL; } serviceHandle = PhOpenService(serviceItem->Name->Buffer, SERVICE_CHANGE_CONFIG); if (serviceHandle) { if (ChangeServiceConfig( serviceHandle, newServiceType, newServiceStartType, newServiceErrorControl, newServiceBinaryPath->Buffer, newServiceGroup->Buffer, NULL, NULL, PhGetString(newServiceUserAccount), PhGetString(newServicePassword), NULL )) { BOOLEAN newDelayedStart; newDelayedStart = Button_GetCheck(GetDlgItem(hwndDlg, IDC_DELAYEDSTART)) == BST_CHECKED; if (newDelayedStart != context->OldDelayedStart) { PhSetServiceDelayedAutoStart(serviceHandle, newDelayedStart); } PhMarkNeedsConfigUpdateServiceItem(serviceItem); CloseServiceHandle(serviceHandle); } else { CloseServiceHandle(serviceHandle); goto ErrorCase; } } else { if (GetLastError() == ERROR_ACCESS_DENIED && !PhElevated) { // Elevate using phsvc. if (PhUiConnectToPhSvc(hwndDlg, FALSE)) { if (NT_SUCCESS(status = PhSvcCallChangeServiceConfig( serviceItem->Name->Buffer, newServiceType, newServiceStartType, newServiceErrorControl, newServiceBinaryPath->Buffer, newServiceGroup->Buffer, NULL, NULL, PhGetString(newServiceUserAccount), PhGetString(newServicePassword), NULL ))) { BOOLEAN newDelayedStart; newDelayedStart = Button_GetCheck(GetDlgItem(hwndDlg, IDC_DELAYEDSTART)) == BST_CHECKED; if (newDelayedStart != context->OldDelayedStart) { SERVICE_DELAYED_AUTO_START_INFO info; info.fDelayedAutostart = newDelayedStart; PhSvcCallChangeServiceConfig2( serviceItem->Name->Buffer, SERVICE_CONFIG_DELAYED_AUTO_START_INFO, &info ); } PhMarkNeedsConfigUpdateServiceItem(serviceItem); } PhUiDisconnectFromPhSvc(); if (!NT_SUCCESS(status)) { SetLastError(PhNtStatusToDosError(status)); goto ErrorCase; } } else { // User cancelled elevation. SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID); } } else { goto ErrorCase; } } goto Cleanup; ErrorCase: if (PhShowMessage( hwndDlg, MB_ICONERROR | MB_RETRYCANCEL, L"Unable to change service configuration: %s", ((PPH_STRING)PHA_DEREFERENCE(PhGetWin32Message(GetLastError())))->Buffer ) == IDRETRY) { SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID); } Cleanup: if (newServicePassword) { RtlSecureZeroMemory(newServicePassword->Buffer, newServicePassword->Length); PhDereferenceObject(newServicePassword); } } return TRUE; } } break; } return FALSE; }
INT_PTR CALLBACK PhpSessionShadowDlgProc( __in HWND hwndDlg, __in UINT uMsg, __in WPARAM wParam, __in LPARAM lParam ) { switch (uMsg) { case WM_INITDIALOG: { HWND virtualKeyComboBox; PH_INTEGER_PAIR hotkey; ULONG i; PWSTR stringToSelect; SetProp(hwndDlg, L"SessionId", (HANDLE)(ULONG)lParam); PhCenterWindow(hwndDlg, GetParent(hwndDlg)); hotkey = PhGetIntegerPairSetting(L"SessionShadowHotkey"); // Set up the hotkeys. virtualKeyComboBox = GetDlgItem(hwndDlg, IDC_VIRTUALKEY); stringToSelect = L"{*}"; for (i = 0; i < sizeof(VirtualKeyPairs) / sizeof(PH_KEY_VALUE_PAIR); i++) { ComboBox_AddString(virtualKeyComboBox, VirtualKeyPairs[i].Key); if ((ULONG)VirtualKeyPairs[i].Value == (ULONG)hotkey.X) { stringToSelect = VirtualKeyPairs[i].Key; } } ComboBox_SelectString(virtualKeyComboBox, -1, stringToSelect); // Set up the modifiers. Button_SetCheck(GetDlgItem(hwndDlg, IDC_SHIFT), hotkey.Y & KBDSHIFT); Button_SetCheck(GetDlgItem(hwndDlg, IDC_CTRL), hotkey.Y & KBDCTRL); Button_SetCheck(GetDlgItem(hwndDlg, IDC_ALT), hotkey.Y & KBDALT); } break; case WM_DESTROY: { RemoveProp(hwndDlg, L"SessionId"); } break; case WM_COMMAND: { switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hwndDlg, IDCANCEL); break; case IDOK: { ULONG sessionId = (ULONG)GetProp(hwndDlg, L"SessionId"); ULONG virtualKey; ULONG modifiers; WCHAR computerName[64]; ULONG computerNameLength = 64; virtualKey = VK_MULTIPLY; PhFindIntegerSiKeyValuePairs( VirtualKeyPairs, sizeof(VirtualKeyPairs), PHA_GET_DLGITEM_TEXT(hwndDlg, IDC_VIRTUALKEY)->Buffer, &virtualKey ); modifiers = 0; if (Button_GetCheck(GetDlgItem(hwndDlg, IDC_SHIFT)) == BST_CHECKED) modifiers |= KBDSHIFT; if (Button_GetCheck(GetDlgItem(hwndDlg, IDC_CTRL)) == BST_CHECKED) modifiers |= KBDCTRL; if (Button_GetCheck(GetDlgItem(hwndDlg, IDC_ALT)) == BST_CHECKED) modifiers |= KBDALT; if (GetComputerName(computerName, &computerNameLength)) { if (WinStationShadow(NULL, computerName, sessionId, (UCHAR)virtualKey, (USHORT)modifiers)) { PH_INTEGER_PAIR hotkey; hotkey.X = virtualKey; hotkey.Y = modifiers; PhSetIntegerPairSetting(L"SessionShadowHotkey", hotkey); EndDialog(hwndDlg, IDOK); } else { PhShowStatus(hwndDlg, L"Unable to remote control the session", 0, GetLastError()); } } else { PhShowError(hwndDlg, L"The computer name is too long."); } } break; } } break; } return FALSE; }
/*------------------------------------------------ Dialog procedure --------------------------------------------------*/ INT_PTR CALLBACK Page_Color(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: OnInit(hDlg); return TRUE; case WM_DESTROY:{ HFONT hfontb=(HFONT)SendDlgItemMessage(hDlg,IDC_BOLD,WM_GETFONT,0,0); HFONT hfonti=(HFONT)SendDlgItemMessage(hDlg,IDC_ITALIC,WM_GETFONT,0,0); SendDlgItemMessage(hDlg,IDC_BOLD,WM_SETFONT,0,0); SendDlgItemMessage(hDlg,IDC_ITALIC,WM_SETFONT,0,0); DeleteObject(hfontb); DeleteObject(hfonti); break;} case WM_MEASUREITEM: return ColorBox_OnMeasureItem(wParam, lParam); case WM_DRAWITEM: return ColorBox_OnDrawItem(wParam, lParam); case WM_COMMAND: { WORD id=LOWORD(wParam); switch(HIWORD(wParam)){ case CBN_SELCHANGE: if(id==IDC_COLFORE || id==IDC_COLBACK || id==IDC_FONT || id==IDC_FONTQUAL || id==IDC_FONTSIZE){ if(id==IDC_FONT) SetComboFontSize(hDlg, FALSE); SendPSChanged(hDlg); } break; case CBN_EDITCHANGE: if(id==IDC_FONTSIZE) SendPSChanged(hDlg); break; case EN_CHANGE: if(id==IDC_CLOCKHEIGHT || id==IDC_CLOCKWIDTH || id==IDC_ALPHATB || id==IDC_VERTPOS || id==IDC_LINEHEIGHT || id==IDC_HORIZPOS || id==IDC_ANGLE){ SendPSChanged(hDlg); } break; default: if(id==IDC_COLFORE_BTN || id==IDC_COLBACK_BTN){ ColorBox_ChooseColor((HWND)lParam); }else if(id==IDC_CHOOSEFONT){ HWND hwndCombo; HDC hdc; wchar_t size[8]; LOGFONT lf = {0}; CHOOSEFONT chosenfont = {sizeof(CHOOSEFONT)}; chosenfont.hwndOwner = hDlg; chosenfont.Flags = CF_FORCEFONTEXIST | CF_INITTOLOGFONTSTRUCT | CF_PRINTERFONTS | CF_SCREENFONTS; chosenfont.lpLogFont = &lf; hwndCombo = GetDlgItem(hDlg,IDC_FONTSIZE); ComboBox_GetText(hwndCombo, size, _countof(size)); hdc = GetDC(NULL); lf.lfWeight = IsDlgButtonChecked(hDlg, IDC_BOLD) ? FW_BOLD : FW_REGULAR; lf.lfItalic = (BYTE)IsDlgButtonChecked(hDlg, IDC_ITALIC); lf.lfHeight = -MulDiv(_wtoi(size), GetDeviceCaps(hdc,LOGPIXELSY), 72); ReleaseDC(NULL, hdc); hwndCombo = GetDlgItem(hDlg,IDC_FONT); ComboBox_GetText(hwndCombo, lf.lfFaceName, _countof(lf.lfFaceName)); if(ChooseFont(&chosenfont)){ int sel; CheckDlgButton(hDlg, IDC_BOLD, (chosenfont.lpLogFont->lfWeight >= FW_SEMIBOLD)); CheckDlgButton(hDlg, IDC_ITALIC, chosenfont.lpLogFont->lfItalic); ComboBox_SelectString(hwndCombo, -1, chosenfont.lpLogFont->lfFaceName); hwndCombo = GetDlgItem(hDlg,IDC_FONTSIZE); wsprintf(size, FMT("%d"), chosenfont.iPointSize/10); sel = ComboBox_FindStringExact(hwndCombo, -1, size); if(sel != CB_ERR) ComboBox_SetCurSel(hwndCombo, sel); else ComboBox_SetText(hwndCombo, size); SendPSChanged(hDlg); } }else if(id==IDC_BOLD || id==IDC_ITALIC) SendPSChanged(hDlg); } return TRUE;} case WM_NOTIFY:{ PSHNOTIFY* notify=(PSHNOTIFY*)lParam; switch(notify->hdr.code) { case PSN_APPLY: OnApply(hDlg,0); if(notify->lParam) m_transition=-1; break; case PSN_RESET: if(m_transition==1){ SendMessage(g_hwndClock, CLOCKM_REFRESHCLOCK, 0, 0); SendMessage(g_hwndClock, CLOCKM_REFRESHTASKBAR, 0, 0); api.DelKey(L"Preview"); } m_transition=-1; break; } return TRUE;} } return FALSE; }