// Modify password dialog procedure INT_PTR CALLBACK ProcDlgSetTimeout(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == WM_INITDIALOG) { HKEY hSoftwareKey; DWORD dwTimeout = 60; DWORD dwLen = sizeof(dwTimeout); if (RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_QUERY_VALUE, &hSoftwareKey) == 0) { if (RegGetValue(hSoftwareKey, "ScreenLock", "Timeout", RRF_RT_REG_DWORD, 0, &dwTimeout, &dwLen) != 0) { dwTimeout = 60; // Default is one minute } else { dwTimeout = max(30, min(3600, dwTimeout)); } RegCloseKey(hSoftwareKey); } SetDlgItemInt(hWnd, IDC_SET_TIMEOUT, dwTimeout, FALSE); } if (uMsg == WM_COMMAND) { if (wParam == IDOK) { // Check range DWORD dwTimeout = GetDlgItemInt(hWnd, IDC_SET_TIMEOUT, NULL, FALSE); if (dwTimeout < 30 || dwTimeout > 3600) { MessageBox(hWnd, "Timeout should be between 30 and 3600 seconds!", "Error", MB_OK | MB_ICONWARNING); return TRUE; } // Open HKEY_CURRENT_USER\Software HKEY hSoftwareKey; if (RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_CREATE_SUB_KEY, &hSoftwareKey) != 0) // Key not exist { MessageBox(hWnd, "Cannot open HKEY_CURRENT_USER\\Software!", "Error", MB_OK | MB_ICONWARNING); return TRUE; } // Create HKEY_CURRENT_USER\Software\ScreenLock HKEY hScreenLockKey; if (RegCreateKeyEx(hSoftwareKey, "ScreenLock", 0, NULL, 0, KEY_SET_VALUE, NULL, &hScreenLockKey, NULL) != 0) { MessageBox(hWnd, "Cannot create HKEY_CURRENT_USER\\Software\\ScreenLock!", "Error", MB_OK | MB_ICONWARNING); RegCloseKey(hSoftwareKey); return TRUE; } // Create HKEY_CURRENT_USER\Software\ScreenLock\Timeout if (RegSetValueEx(hScreenLockKey, "Timeout", 0, REG_DWORD, (BYTE *)&dwTimeout, sizeof(dwTimeout)) != 0) { MessageBox(hWnd, "Cannot create registry value!", "Error", MB_OK | MB_ICONWARNING); RegCloseKey(hScreenLockKey); RegCloseKey(hSoftwareKey); return TRUE; } g_uTimeout = dwTimeout; MessageBox(hWnd, "Timeout updated successfully", "Screen Locker", MB_OK | MB_ICONINFORMATION); EndDialog(hWnd, 0); return TRUE; } else if (wParam == IDCANCEL) { EndDialog(hWnd, 0); } } return FALSE; }
static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { int i; switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); if (ColorMode == COLOR_WINDOWS) { CheckDlgButton(hwndDlg, IDC_USEWINCOLORS, BST_CHECKED); Utils::enableDlgControl(hwndDlg, IDC_USEPOPUPCOLORS, FALSE); Utils::enableDlgControl(hwndDlg, IDC_USEWINCOLORS, TRUE); CheckDlgButton(hwndDlg, IDC_USEPOPUPCOLORS, BST_UNCHECKED); } else if (ColorMode == COLOR_POPUP) { CheckDlgButton(hwndDlg, IDC_USEWINCOLORS, BST_UNCHECKED); Utils::enableDlgControl(hwndDlg, IDC_USEWINCOLORS, FALSE); Utils::enableDlgControl(hwndDlg, IDC_USEPOPUPCOLORS, TRUE); CheckDlgButton(hwndDlg, IDC_USEPOPUPCOLORS, BST_CHECKED); } for (i=0; i < SIZEOF(colorPicker); i++) { SendDlgItemMessage(hwndDlg, colorPicker[i].res, CPM_SETCOLOUR, 0, colorPicker[i].color); Utils::enableDlgControl(hwndDlg, colorPicker[i].res, (ColorMode == COLOR_OWN)); } CheckDlgButton(hwndDlg, IDC_TIMEOUT_PERMANENT, (TimeoutMode == TIMEOUT_PERMANENT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_TIMEOUT_POPUP, (TimeoutMode == TIMEOUT_POPUP) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_TIMEOUT_PROTO, (TimeoutMode == TIMEOUT_PROTO) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_TIMEOUT_CUSTOM, (TimeoutMode == TIMEOUT_CUSTOM) ? BST_CHECKED : BST_UNCHECKED); SetDlgItemInt(hwndDlg, IDC_TIMEOUT_VALUE, Timeout, 0); Utils::enableDlgControl(hwndDlg, IDC_TIMEOUT_VALUE, TimeoutMode == TIMEOUT_CUSTOM); CheckDlgButton(hwndDlg, IDC_TIMEOUT_PERMANENT2, (TimeoutMode2 == TIMEOUT_PERMANENT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_TIMEOUT_POPUP2, (TimeoutMode2 == TIMEOUT_POPUP) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_TIMEOUT_CUSTOM2, (TimeoutMode2 == TIMEOUT_CUSTOM) ? BST_CHECKED : BST_UNCHECKED); SetDlgItemInt(hwndDlg, IDC_TIMEOUT_VALUE2, Timeout2, 0); Utils::enableDlgControl(hwndDlg, IDC_TIMEOUT_VALUE2, TimeoutMode2 == TIMEOUT_CUSTOM); CheckDlgButton(hwndDlg, IDC_START, (StartDisabled) ? BST_UNCHECKED : BST_CHECKED); CheckDlgButton(hwndDlg, IDC_STOP, (StopDisabled) ? BST_UNCHECKED : BST_CHECKED); CheckDlgButton(hwndDlg, IDC_ONEPOPUP, (OnePopup) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_SHOWMENU, (ShowMenu) ? BST_CHECKED : BST_UNCHECKED); Utils::enableDlgControl(hwndDlg, IDC_ONEPOPUP, PluginConfig.g_PopupAvail); Utils::enableDlgControl(hwndDlg, IDC_SHOWMENU, PluginConfig.g_PopupAvail); Utils::enableDlgControl(hwndDlg, IDC_PREVIEW, PluginConfig.g_PopupAvail/*&&!ServiceExists(MS_POPUP_REGISTERNOTIFICATION)*/); newTimeout = Timeout; newTimeoutMode = TimeoutMode; newTimeout2 = Timeout2; newTimeoutMode2 = TimeoutMode2; newColorMode = ColorMode; break; case WM_COMMAND: { WORD idCtrl = LOWORD(wParam), wNotifyCode = HIWORD(wParam); if (wNotifyCode == CPN_COLOURCHANGED) { SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); return TRUE; } switch (idCtrl) { case IDC_USEWINCOLORS: if (wNotifyCode == BN_CLICKED) { BOOL bEnableOthers; if (IsDlgButtonChecked(hwndDlg, IDC_USEWINCOLORS)) { newColorMode = COLOR_WINDOWS; bEnableOthers = FALSE; } else { newColorMode = COLOR_OWN; bEnableOthers = TRUE; } for (i=0; i < SIZEOF(colorPicker); i++) Utils::enableDlgControl(hwndDlg, colorPicker[i].res, bEnableOthers); Utils::enableDlgControl(hwndDlg, IDC_USEPOPUPCOLORS, bEnableOthers); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } break; case IDC_USEPOPUPCOLORS: if (wNotifyCode == BN_CLICKED) { BOOL bEnableOthers; if (IsDlgButtonChecked(hwndDlg, IDC_USEPOPUPCOLORS)) { newColorMode = COLOR_POPUP; bEnableOthers = FALSE; } else { newColorMode = COLOR_OWN; bEnableOthers = TRUE; } for (i=0; i < sizeof(colorPicker) / sizeof(colorPicker[0]); i++) Utils::enableDlgControl(hwndDlg, colorPicker[i].res, bEnableOthers); Utils::enableDlgControl(hwndDlg, IDC_USEWINCOLORS, bEnableOthers); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } break; case IDC_ONEPOPUP: case IDC_CLIST: case IDC_DISABLED: case IDC_SHOWMENU: case IDC_START: case IDC_STOP: case IDC_WOCL: if (wNotifyCode == BN_CLICKED) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_PREVIEW: if (PluginConfig.g_PopupAvail) { POPUPDATAT ppd = { 0 }; for (i=0; i < 2; i++) { int notyping; if (i == PROTOTYPE_CONTACTTYPING_OFF) { lstrcpy(ppd.lptzContactName, TranslateT("Contact")); lstrcpyn(ppd.lptzText, szStop, MAX_SECONDLINE); notyping = 1; } else { lstrcpy(ppd.lptzContactName, TranslateT("Contact")); lstrcpyn(ppd.lptzText, szStart, MAX_SECONDLINE); notyping = 0; } switch (newColorMode) { case COLOR_OWN: ppd.colorText = SendDlgItemMessage(hwndDlg, colorPicker[2*notyping + 1].res, CPM_GETCOLOUR, 0, 0); ppd.colorBack = SendDlgItemMessage(hwndDlg, colorPicker[2*notyping ].res, CPM_GETCOLOUR, 0, 0); break; case COLOR_WINDOWS: ppd.colorBack = GetSysColor(COLOR_BTNFACE); ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); break; case COLOR_POPUP: default: ppd.colorBack = ppd.colorText = 0; break; } if (notyping) switch (newTimeoutMode2) { case TIMEOUT_CUSTOM: ppd.iSeconds = newTimeout2; break; case TIMEOUT_PERMANENT: ppd.iSeconds = -1; break; case TIMEOUT_POPUP: default: ppd.iSeconds = 0; break; } else switch (newTimeoutMode) { case TIMEOUT_CUSTOM: ppd.iSeconds = newTimeout; break; case TIMEOUT_PROTO: ppd.iSeconds = 10; break; case TIMEOUT_PERMANENT: ppd.iSeconds = -1; break; case TIMEOUT_POPUP: default: ppd.iSeconds = 0; break; } ppd.lchIcon = PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING]; ppd.lchContact = (HANDLE)wParam; ppd.PluginWindowProc = NULL; ppd.PluginData = NULL; PUAddPopupT(&ppd); } } break; case IDC_TIMEOUT_POPUP2: if (wNotifyCode != BN_CLICKED) break; newTimeoutMode2 = TIMEOUT_POPUP; Utils::enableDlgControl(hwndDlg, IDC_TIMEOUT_VALUE2, 0); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_TIMEOUT_CUSTOM2: if (wNotifyCode != BN_CLICKED) break; newTimeoutMode2 = TIMEOUT_CUSTOM; Utils::enableDlgControl(hwndDlg, IDC_TIMEOUT_VALUE2, 1); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_TIMEOUT_POPUP: if (wNotifyCode != BN_CLICKED) break; newTimeoutMode = TIMEOUT_POPUP; Utils::enableDlgControl(hwndDlg, IDC_TIMEOUT_VALUE, 0); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_TIMEOUT_PERMANENT: if (wNotifyCode != BN_CLICKED) break; newTimeoutMode = TIMEOUT_PERMANENT; Utils::enableDlgControl(hwndDlg, IDC_TIMEOUT_VALUE, 0); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_TIMEOUT_PERMANENT2: if (wNotifyCode != BN_CLICKED) break; newTimeoutMode2 = TIMEOUT_PERMANENT; Utils::enableDlgControl(hwndDlg, IDC_TIMEOUT_VALUE2, 0); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_TIMEOUT_CUSTOM: if (wNotifyCode != BN_CLICKED) break; newTimeoutMode = TIMEOUT_CUSTOM; Utils::enableDlgControl(hwndDlg, IDC_TIMEOUT_VALUE, 1); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_TIMEOUT_PROTO: if (wNotifyCode != BN_CLICKED) break; newTimeoutMode = TIMEOUT_PROTO; Utils::enableDlgControl(hwndDlg, IDC_TIMEOUT_VALUE, 0); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_TIMEOUT_VALUE: case IDC_TIMEOUT_VALUE2: { int newValue = GetDlgItemInt(hwndDlg, idCtrl, NULL, 0); if (wNotifyCode == EN_KILLFOCUS) { int oldValue; if (idCtrl == IDC_TIMEOUT_VALUE) oldValue = newTimeout; else oldValue = newTimeout2; if (newValue != oldValue) SetDlgItemInt(hwndDlg, idCtrl, oldValue, 0); return TRUE; } if (wNotifyCode != EN_CHANGE || (HWND) lParam != GetFocus()) return TRUE; if (newValue > TIMEOUT_MAXVALUE) newValue = TIMEOUT_MAXVALUE; else if (newValue < TIMEOUT_MINVALUE) newValue = TIMEOUT_MINVALUE; if (idCtrl == IDC_TIMEOUT_VALUE) newTimeout = newValue; else newTimeout2 = newValue; SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } } } break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case 0: switch (((LPNMHDR) lParam)->code) { case PSN_APPLY: for (i=0; i < sizeof(colorPicker) / sizeof(colorPicker[0]); i++) { colorPicker[i].color = SendDlgItemMessage(hwndDlg, colorPicker[i].res, CPM_GETCOLOUR, 0, 0); db_set_dw(0, Module, colorPicker[i].desc, colorPicker[i].color); } Timeout = newTimeout; TimeoutMode = newTimeoutMode; Timeout2 = newTimeout2; TimeoutMode2 = newTimeoutMode2; ColorMode = newColorMode; if (Disabled != IsDlgButtonChecked(hwndDlg, IDC_DISABLED)) EnableDisableMenuCommand(0, 0); StartDisabled = IsDlgButtonChecked(hwndDlg, IDC_START) ? 0 : 2; StopDisabled = IsDlgButtonChecked(hwndDlg, IDC_STOP) ? 0 : 4; OnePopup = IsDlgButtonChecked(hwndDlg, IDC_ONEPOPUP); ShowMenu = IsDlgButtonChecked(hwndDlg, IDC_SHOWMENU); db_set_b(0, Module, SET_ONEPOPUP, OnePopup); db_set_b(0, Module, SET_SHOWDISABLEMENU, ShowMenu); db_set_b(0, Module, SET_DISABLED, (BYTE) (StartDisabled | StopDisabled)); db_set_b(0, Module, SET_COLOR_MODE, ColorMode); db_set_b(0, Module, SET_TIMEOUT_MODE, TimeoutMode); db_set_b(0, Module, SET_TIMEOUT, (BYTE) Timeout); db_set_b(0, Module, SET_TIMEOUT_MODE2, TimeoutMode2); db_set_b(0, Module, SET_TIMEOUT2, (BYTE) Timeout2); return TRUE; } } break; } return FALSE; }
//************************************************************************ void CPuzzleScene::OnCommand(HWND hWnd, int id, HWND hControl, UINT codeNotify) //************************************************************************ { BOOL Bool; int iSkill; switch (id) { case IDC_NEXTPUZZLE: { id = IDC_PUZZLE; if (GetDlgItem(hWnd, IDC_PUZZLE)) { PPUZZLE lpPuzzle = GetPuzzle(GetDlgItem(hWnd, IDC_PUZZLE)); if (lpPuzzle) id = lpPuzzle->NextPuzzle(); } if (GetDlgItem(hWnd, IDC_PUZZLEVIEW)) { SetWindowWord(GetDlgItem(hWnd, IDC_PUZZLEVIEW), GWW_ICONID, id-IDC_PUZZLE1+IDC_PUZZLEVIEW1); InvalidateRect(GetDlgItem(hWnd, IDC_PUZZLEVIEW), NULL, TRUE); } break; } case IDC_HINTMODE: { m_bHintMode = !m_bHintMode; CheckDlgButton(hWnd, id, m_bHintMode); if (GetDlgItem(hWnd, IDC_PUZZLE)) { PPUZZLE lpPuzzle = GetPuzzle(GetDlgItem(hWnd, IDC_PUZZLE)); if (lpPuzzle) lpPuzzle->SetHintMode(m_bHintMode); } break; } case IDC_SKILL: { if (GetFocus() != GetDlgItem(hWnd, id)) break; if (codeNotify != EN_CHANGE) break; iSkill = GetDlgItemInt(hWnd, id, &Bool, NO); if (iSkill <= 0) break; m_iSkill = iSkill; if (GetDlgItem(hWnd, IDC_PUZZLE)) { PPUZZLE lpPuzzle = GetPuzzle(GetDlgItem(hWnd, IDC_PUZZLE)); if (lpPuzzle) lpPuzzle->Init(m_iSkill, m_iSkill); } break; } case IDC_MAINMENU: { break; } case IDC_BACK: { GetApp()->GotoScene(hWnd, m_nNextSceneNo); break; } default: break; } }
/* ======================================================================================= ======================================================================================= */ bool shave_v2_v16(HWND hDlg, int version, int line_count, int max_particles, FILE *fin, FILE *fout) { char line[2048]; int num_particles, num_to_keep; int *keep_list, counter, written; unsigned int seed; memset(line, 0, sizeof(line)); if (!fgets(line, 32, fin)) { MessageBox(hDlg, "Error reading particle count from list file.", "Error", MB_OK); return false; } num_particles = atoi(line); num_to_keep = max_particles; seed = GetDlgItemInt(hDlg, IDC_RAND_SEED, NULL, FALSE); if (seed == 0) { seed = 1; } keep_list = generate_keep_list(&num_to_keep, num_particles, seed); if (!keep_list) { MessageBox(hDlg, "Internal error allocating memory.", "Error", MB_OK); return false; } sprintf_s(line, sizeof(line), "%d\n%d\n", version, num_to_keep); if (fputs(line, fout) < 0) { MessageBox(hDlg, "Error writing output file", "Error", MB_OK); return false; } counter = 0; written = 0; while (!feof(fin)) { if (!fgets(line, sizeof(line), fin)) { if (ferror(fin)) { MessageBox(hDlg, "Error reading input file", "Error", MB_OK); return false; } } if (keep_list[counter++]) { if (fputs(line, fout) < 0) { MessageBox(hDlg, "Error writing output file", "Error", MB_OK); return false; } if (++written >= num_to_keep) { break; } } } delete [] keep_list; return true; }
void COptionsPageStyle::OnOK() { if(!m_bCreated) return; StyleDetails display; StyleDetails current; m_defclass->Combine(NULL, current); display.FontName = m_FontCombo.GetSelFontName(); display.FontSize = GetDlgItemInt(IDC_FONTSIZE_COMBO); display.ForeColor = m_fore.SafeGetColor(); display.BackColor = m_back.SafeGetColor(); display.Bold = (m_bold.GetCheck() == BST_CHECKED); display.Italic = (m_italic.GetCheck() == BST_CHECKED); display.Underline = (m_underline.GetCheck() == BST_CHECKED); display.name = _T("default"); if(display != current) { // the new style is not the same as the current style: // work out what the differences are StyleDetails therealdefault( *m_defclass->Style ); display.compareTo(therealdefault); if(display.values == 0) { // Not custom any more... m_defclass->Reset(); } else { if(m_defclass->CustomStyle) *m_defclass->CustomStyle = display; else m_defclass->CustomStyle = new StyleDetails(display); } } // Clear all existing colour customisations EditorColours* ec = m_pSchemes->GetDefaultColours(); ec->Clear(); COLORREF c; c = m_cur.GetColor(); if( CButton(GetDlgItem(IDC_STYLE_SELUSEFORE)).GetCheck() == BST_CHECKED ) c = CLR_NONE; else c = m_selFore.GetColor(); if(c != CLR_DEFAULT) ec->SetColour( EditorColours::ecSelFore, c); StoreIfSet(m_selBack, ec, EditorColours::ecSelBack); StoreIfSet(m_cur, ec, EditorColours::ecCaret); StoreIfSet(m_indentGuides, ec, EditorColours::ecIndentG); StoreIfSet(m_markAll, ec, EditorColours::ecMarkAll); StoreIfSet(m_smartHighlight, ec, EditorColours::ecSmartHL); StoreIfSet(m_templateField, ec, EditorColours::ecTemplateField); }
static INT_PTR APIENTRY OptWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch ( uMsg ) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); // Properties CheckDlgButton(hwndDlg, IDC_CHK_HIDE_OFFLINE, (fcOpt.bHideOffline ? BST_CHECKED : BST_UNCHECKED)); CheckDlgButton(hwndDlg, IDC_CHK_HIDE_ALL, (fcOpt.bHideAll ? BST_CHECKED : BST_UNCHECKED)); CheckDlgButton(hwndDlg, IDC_CHK_HIDE_WHEN_FULSCREEN, (fcOpt.bHideWhenFullscreen ? BST_CHECKED : BST_UNCHECKED)); CheckDlgButton(hwndDlg, IDC_CHK_STICK, (fcOpt.bMoveTogether ? BST_CHECKED : BST_UNCHECKED)); CheckDlgButton(hwndDlg, IDC_CHK_WIDTH, (fcOpt.bFixedWidth ? BST_CHECKED : BST_UNCHECKED)); EnableWindow(GetDlgItem(hwndDlg, IDC_LBL_WIDTH), fcOpt.bFixedWidth); EnableWindow(GetDlgItem(hwndDlg, IDC_TXT_WIDTH), fcOpt.bFixedWidth); EnableWindow(GetDlgItem(hwndDlg, IDC_WIDTHSPIN), fcOpt.bFixedWidth); SendDlgItemMessage(hwndDlg, IDC_WIDTHSPIN, UDM_SETRANGE, 0, MAKELONG(255,0)); SendDlgItemMessage(hwndDlg, IDC_WIDTHSPIN, UDM_SETPOS, 0, fcOpt.nThumbWidth); CheckDlgButton(hwndDlg, IDC_CHK_TIP, (fcOpt.bShowTip ? BST_CHECKED : BST_UNCHECKED)); EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_TIP), bEnableTip); EnableWindow(GetDlgItem(hwndDlg, IDC_LBL_TIMEIN), bEnableTip && fcOpt.bShowTip); EnableWindow(GetDlgItem(hwndDlg, IDC_LBL_TIMEIN_CMT), bEnableTip && fcOpt.bShowTip); EnableWindow(GetDlgItem(hwndDlg, IDC_TXT_TIMEIN), bEnableTip && fcOpt.bShowTip); EnableWindow(GetDlgItem(hwndDlg, IDC_TIMEINSPIN), bEnableTip && fcOpt.bShowTip); SendDlgItemMessage(hwndDlg, IDC_TIMEINSPIN, UDM_SETRANGE, 0, MAKELONG(5000,0)); SendDlgItemMessage(hwndDlg, IDC_TIMEINSPIN, UDM_SETPOS, 0, fcOpt.TimeIn); CheckDlgButton(hwndDlg, IDC_CHK_TOTOP, (fcOpt.bToTop ? BST_CHECKED : BST_UNCHECKED)); EnableWindow(GetDlgItem(hwndDlg, IDC_LBL_TOTOP), fcOpt.bToTop); EnableWindow(GetDlgItem(hwndDlg, IDC_TXT_TOTOPTIME), fcOpt.bToTop); EnableWindow(GetDlgItem(hwndDlg, IDC_TOTOPTIMESPIN), fcOpt.bToTop); SendDlgItemMessage(hwndDlg, IDC_TOTOPTIMESPIN, UDM_SETRANGE, 0, MAKELONG(TOTOPTIME_MAX,1)); SendDlgItemMessage(hwndDlg, IDC_TOTOPTIMESPIN, UDM_SETPOS, 0, fcOpt.ToTopTime); CheckDlgButton(hwndDlg, IDC_CHK_HIDE_WHEN_CLISTSHOW, (fcOpt.bHideWhenCListShow ? BST_CHECKED : BST_UNCHECKED)); CheckDlgButton(hwndDlg, IDC_CHK_SINGLECLK, (fcOpt.bUseSingleClick ? BST_CHECKED : BST_UNCHECKED)); CheckDlgButton(hwndDlg, IDC_CHK_SHOWIDLE, (fcOpt.bShowIdle ? BST_CHECKED : BST_UNCHECKED)); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_CHK_WIDTH: if (BN_CLICKED == HIWORD(wParam)) { BOOL bChecked = (BOOL)IsDlgButtonChecked(hwndDlg, IDC_CHK_WIDTH); EnableWindow(GetDlgItem(hwndDlg, IDC_LBL_WIDTH ), bChecked); EnableWindow(GetDlgItem(hwndDlg, IDC_TXT_WIDTH ), bChecked); EnableWindow(GetDlgItem(hwndDlg, IDC_WIDTHSPIN), bChecked); } break; case IDC_TXT_TIMEIN: case IDC_TXT_TOTOPTIME: case IDC_TXT_WIDTH: if (EN_CHANGE != HIWORD(wParam) || (HWND)lParam != GetFocus()) return 0; break; case IDC_CHK_TIP: if (BN_CLICKED == HIWORD(wParam)) { BOOL bChecked = (BOOL)IsDlgButtonChecked(hwndDlg, IDC_CHK_TIP); EnableWindow(GetDlgItem(hwndDlg, IDC_LBL_TIMEIN ), bChecked); EnableWindow(GetDlgItem(hwndDlg, IDC_LBL_TIMEIN_CMT ), bChecked); EnableWindow(GetDlgItem(hwndDlg, IDC_TXT_TIMEIN ), bChecked); EnableWindow(GetDlgItem(hwndDlg, IDC_TIMEINSPIN), bChecked); } break; case IDC_CHK_TOTOP: if (BN_CLICKED == HIWORD(wParam)) { BOOL bChecked = (BOOL)IsDlgButtonChecked(hwndDlg, IDC_CHK_TOTOP); EnableWindow(GetDlgItem(hwndDlg, IDC_LBL_TOTOP ), bChecked); EnableWindow(GetDlgItem(hwndDlg, IDC_TXT_TOTOPTIME ), bChecked); EnableWindow(GetDlgItem(hwndDlg, IDC_TOTOPTIMESPIN), bChecked); } break; } SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case WM_NOTIFY: LPNMHDR phdr = (LPNMHDR)(lParam); if (0 == phdr->idFrom) { switch (phdr->code) { case PSN_APPLY: BOOL bSuccess = FALSE; fcOpt.bHideOffline = (BOOL)IsDlgButtonChecked(hwndDlg, IDC_CHK_HIDE_OFFLINE); db_set_b(NULL, MODULE, "HideOffline", (BYTE)fcOpt.bHideOffline); fcOpt.bHideAll = (BOOL)IsDlgButtonChecked(hwndDlg, IDC_CHK_HIDE_ALL); db_set_b(NULL, MODULE, "HideAll", (BYTE)fcOpt.bHideAll); fcOpt.bHideWhenFullscreen = (BOOL)IsDlgButtonChecked(hwndDlg, IDC_CHK_HIDE_WHEN_FULSCREEN); db_set_b(NULL, MODULE, "HideWhenFullscreen", (BYTE)fcOpt.bHideWhenFullscreen); fcOpt.bMoveTogether = (BOOL)IsDlgButtonChecked(hwndDlg, IDC_CHK_STICK); db_set_b(NULL, MODULE, "MoveTogether", (BYTE)fcOpt.bMoveTogether); fcOpt.bFixedWidth = (BOOL)IsDlgButtonChecked(hwndDlg, IDC_CHK_WIDTH); db_set_b(NULL, MODULE, "FixedWidth", (BYTE)fcOpt.bFixedWidth); fcOpt.nThumbWidth = GetDlgItemInt(hwndDlg, IDC_TXT_WIDTH, &bSuccess, FALSE); db_set_dw(NULL, MODULE, "Width", fcOpt.nThumbWidth ); if (bEnableTip) { fcOpt.bShowTip = (BOOL)IsDlgButtonChecked(hwndDlg, IDC_CHK_TIP); db_set_b(NULL, MODULE, "ShowTip", (BYTE)fcOpt.bShowTip); fcOpt.TimeIn = GetDlgItemInt(hwndDlg, IDC_TXT_TIMEIN, &bSuccess, FALSE); db_set_w(NULL, MODULE, "TimeIn", fcOpt.TimeIn ); } fcOpt.bToTop = (BOOL)IsDlgButtonChecked(hwndDlg, IDC_CHK_TOTOP); db_set_b(NULL, MODULE, "ToTop", (BYTE)fcOpt.bToTop); fcOpt.ToTopTime = GetDlgItemInt(hwndDlg, IDC_TXT_TOTOPTIME, &bSuccess, FALSE); db_set_w(NULL, MODULE, "ToTopTime", fcOpt.ToTopTime ); fcOpt.bHideWhenCListShow = (BOOL)IsDlgButtonChecked(hwndDlg, IDC_CHK_HIDE_WHEN_CLISTSHOW); db_set_b(NULL, MODULE, "HideWhenCListShow", (BYTE)fcOpt.bHideWhenCListShow); fcOpt.bUseSingleClick = (BOOL)IsDlgButtonChecked(hwndDlg, IDC_CHK_SINGLECLK); db_set_b(NULL, MODULE, "UseSingleClick", (BYTE)fcOpt.bUseSingleClick); fcOpt.bShowIdle = (BOOL)IsDlgButtonChecked(hwndDlg, IDC_CHK_SHOWIDLE); db_set_b(NULL, MODULE, "ShowIdle", (BYTE)fcOpt.bShowIdle); ApplyOptionsChanges(); OnStatusChanged(); return TRUE; } } break; } return FALSE; }
//代理测试 VOID CCollocateProxy::OnBnClickedProxyTest() { //代理类型 BYTE cbProxyType=(BYTE)m_cmProxyType.GetItemData(m_cmProxyType.GetCurSel()); //代理信息 tagProxyServer ProxyServer; ZeroMemory(&ProxyServer,sizeof(ProxyServer)); ProxyServer.wProxyPort=GetDlgItemInt(IDC_PROXY_PORT); GetDlgItemText(IDC_PROXY_USER,ProxyServer.szUserName,CountArray(ProxyServer.szUserName)); GetDlgItemText(IDC_PROXY_PASS,ProxyServer.szPassword,CountArray(ProxyServer.szPassword)); GetDlgItemText(IDC_PROXY_SERVER,ProxyServer.szProxyServer,CountArray(ProxyServer.szProxyServer)); //效验代理 if (cbProxyType!=PROXY_NONE) { //代理地址 if (ProxyServer.szProxyServer[0]==0) { //错误提示 CInformation Information(this); Information.ShowMessageBox(TEXT("代理服务器地址不能为空,请重新输入!"),MB_ICONERROR,30); //设置焦点 m_edProxyServer.SetFocus(); return; } //代理端口 if (ProxyServer.wProxyPort==0) { //错误提示 CInformation Information(this); Information.ShowMessageBox(TEXT("请输入代理服务器端口号,例如:1080!"),MB_ICONERROR,30); //设置焦点 m_edProxyPort.SetFocus(); return; } } else { //错误提示 CInformation Information(this); Information.ShowMessageBox(TEXT("请先选择代理服务器类型与代理服务器连接信息!"),MB_ICONERROR,30); //设置焦点 m_cmProxyType.SetFocus(); return; } //创建组件 CWHNetworkHelper WHNetworkModule; if (WHNetworkModule.CreateInstance()==false) { ShowInformation(TEXT("网络服务管理组件创建失败,测试失败!"),MB_ICONERROR,30); return; } //代理测试 switch (WHNetworkModule->ProxyServerTesting(cbProxyType,ProxyServer)) { case CONNECT_SUCCESS: //连接成功 { CInformation Information(this); Information.ShowMessageBox(TEXT("代理服务器工作正常!"),MB_ICONINFORMATION); return; } case CONNECT_PROXY_USER_INVALID: //用户错误 { CInformation Information(this); Information.ShowMessageBox(TEXT("代理服务器用户名或者密码错误!"),MB_ICONERROR); return; } default: //默认处理 { CInformation Information(this); Information.ShowMessageBox(TEXT("代理服务器不存在或者连接失败!"),MB_ICONERROR); return; } } return; }
static VOID SetScreenSaver(HWND hwndDlg, PDATA pData) { HKEY regKey; BOOL DeleteMode = FALSE; if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Control Panel\\Desktop"), 0, KEY_ALL_ACCESS, ®Key) == ERROR_SUCCESS) { INT Time; BOOL bRet; TCHAR Sec; UINT Ret; /* Set the screensaver */ if (pData->ScreenSaverItems[pData->Selection].bIsScreenSaver) { RegSetValueEx(regKey, _T("SCRNSAVE.EXE"), 0, REG_SZ, (PBYTE)pData->ScreenSaverItems[pData->Selection].szFilename, _tcslen(pData->ScreenSaverItems[pData->Selection].szFilename) * sizeof(TCHAR)); SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, TRUE, 0, SPIF_UPDATEINIFILE); } else { /* Windows deletes the value if no screensaver is set */ RegDeleteValue(regKey, _T("SCRNSAVE.EXE")); DeleteMode = TRUE; SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, 0, SPIF_UPDATEINIFILE); } /* Set the secure value */ Ret = SendDlgItemMessage(hwndDlg, IDC_SCREENS_USEPASSCHK, BM_GETCHECK, 0, 0); Sec = (Ret == BST_CHECKED) ? _T('1') : _T('0'); RegSetValueEx(regKey, _T("ScreenSaverIsSecure"), 0, REG_SZ, (PBYTE)&Sec, sizeof(TCHAR)); /* Set the screensaver time delay */ Time = GetDlgItemInt(hwndDlg, IDC_SCREENS_TIMEDELAY, &bRet, FALSE); if (Time == 0) Time = 60; else Time *= 60; SystemParametersInfoW(SPI_SETSCREENSAVETIMEOUT, Time, 0, SPIF_SENDCHANGE | SPIF_UPDATEINIFILE); RegCloseKey(regKey); } }
BOOL CALLBACK PropertyDlgProc(HWND hDlg,UINT iMessage,WPARAM wParam,LPARAM lParam) { static DObject *Obj; LPMEASUREITEMSTRUCT lpmis; LPDRAWITEMSTRUCT lpdis; HBRUSH ColorBrush, OldBrush; COLORREF Color; int i; switch(iMessage) { case WM_INITDIALOG: for (i=0;i<sizeof(arColor)/sizeof(arColor[0]);i++) { SendDlgItemMessage(hDlg,IDC_CBLINECOLOR,CB_ADDSTRING,0,(LPARAM)arColor[i]); SendDlgItemMessage(hDlg,IDC_CBPLANECOLOR,CB_ADDSTRING,0,(LPARAM)arColor[i]); } SendDlgItemMessage(hDlg,IDC_SPLINEWIDTH,UDM_SETRANGE,0,MAKELONG(10,0)); Obj=(DObject *)lParam; SetDlgItemInt(hDlg,IDC_EDLINEWIDTH,Obj->LineWidth,FALSE); for (i=0;i<sizeof(arColor)/sizeof(arColor[0]);i++) { if (arColor[i] == Obj->LineColor) { break; } } SendDlgItemMessage(hDlg,IDC_CBLINECOLOR,CB_SETCURSEL,i,0); for (i=0;i<sizeof(arColor)/sizeof(arColor[0]);i++) { if (arColor[i] == Obj->PlaneColor) { break; } } SendDlgItemMessage(hDlg,IDC_CBPLANECOLOR,CB_SETCURSEL,i,0); return TRUE; case WM_MEASUREITEM: lpmis=(LPMEASUREITEMSTRUCT)lParam; lpmis->itemHeight=24; return TRUE; case WM_DRAWITEM: lpdis=(LPDRAWITEMSTRUCT)lParam; if (lpdis->itemState & ODS_SELECTED) { FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT)); } else { FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_WINDOW)); } Color=(COLORREF)SendMessage(lpdis->hwndItem, CB_GETITEMDATA, lpdis->itemID, 0); if (Color == (COLORREF)-1) { ColorBrush=(HBRUSH)GetStockObject(NULL_BRUSH); } else { ColorBrush=CreateSolidBrush(Color); } OldBrush=(HBRUSH)SelectObject(lpdis->hDC, ColorBrush); Rectangle(lpdis->hDC,lpdis->rcItem.left+5,lpdis->rcItem.top+2, lpdis->rcItem.right-5, lpdis->rcItem.bottom-2); SelectObject(lpdis->hDC, OldBrush); if (Color == (COLORREF)-1) { SetTextAlign(lpdis->hDC,TA_CENTER); SetBkMode(lpdis->hDC,TRANSPARENT); TextOut(lpdis->hDC,(lpdis->rcItem.right+lpdis->rcItem.left)/2, lpdis->rcItem.top+4,"투명",4); } else { DeleteObject(ColorBrush); } return TRUE; case WM_COMMAND: switch (wParam) { case IDOK: Obj->LineWidth=GetDlgItemInt(hDlg,IDC_EDLINEWIDTH,NULL,FALSE); i=SendDlgItemMessage(hDlg,IDC_CBLINECOLOR,CB_GETCURSEL,0,0); Obj->LineColor=arColor[i]; i=SendDlgItemMessage(hDlg,IDC_CBPLANECOLOR,CB_GETCURSEL,0,0); Obj->PlaneColor=arColor[i]; EndDialog(hDlg,IDOK); return TRUE; case IDCANCEL: EndDialog(hDlg,IDCANCEL); return TRUE; } break; } return FALSE; }
/////////////////////////////////////////// // Is called when the attack is to begin. /////////////////////////////////////////// void CRSAFactorHintDlg::OnStart() { UpdateData(); int m_b=GetDlgItemInt(IDC_EDITB); int m_bitsOfP=GetDlgItemInt(IDC_EDITBITSOFP); if (m_bitsOfP==0){ CString tmp, myTitle; tmp.LoadString(IDS_RSA_FH_ENTERP); this->GetWindowText(myTitle); MessageBox(tmp,myTitle); } else if(m_b>m_bitsOfP){ CString msg, myTitle; msg.Format(IDS_RSA_FH_BITSOFP, m_bitsOfP, m_b); this->GetWindowText(myTitle); MessageBox(msg,myTitle); } else if(m_bitsOfN==0){ CString tmp, myTitle; tmp.LoadString(IDS_RSA_FH_CHOOSEN); this->GetWindowText(myTitle); MessageBox(tmp,myTitle); } else if(GetDlgItemInt(IDC_EDITDIM)==0){ int needed = (int)((double)(m_bitsOfN+3)/4)+1; CString form, myTitle; form.Format(IDS_RSA_FH_ATLEASTKNOWN, m_b, needed); this->GetWindowText(myTitle); MessageBox(form,myTitle); } else{ disableEnable(false); // disable example geneartion GetDlgItem(IDCANCELATTACK)->EnableWindow(true); GetDlgItem(IDSTART)->EnableWindow(false); SetTimer(1, 1000, 0); // this timer updates the GUI elapsedTime=0; int newbase=2; // representation of the Parameters N UpdateData(); // and P if(m_base==0) newbase=10; if(m_base==1) newbase=16; fh.setN(m_N); ZZ P = m_GuessP; if(m_msbLsb==0) P*=power(to_ZZ(2),m_bitsOfP-m_b); fh.setP(P); fh.setBitsOfP(m_bitsOfP); fh.setB(GetDlgItemInt(IDC_EDITB)); SetDlgItemText(IDC_EDITFACTORP,""); SetDlgItemText(IDC_EDITFACTORQ,""); UpdateData(); fh.status=1; pThread = AfxBeginThread (thrFunction, this); } }
/** * @brief Paste the bytes. * @param [in] hDlg Handle to dialog. * @return TRUE if paste succeeded, FALSE if failed. */ BOOL PasteDlg::Apply(HWND hDlg) { bPasteAsText = (IsDlgButtonChecked(hDlg, IDC_PASTE_BINARY) == BST_CHECKED); iPasteTimes = GetDlgItemInt(hDlg, IDC_PASTE_TIMES, 0, TRUE); if (iPasteTimes <= 0) { LangString atleastOnce(IDS_PASTE_ATLEAST_ONCE); MessageBox(hDlg, atleastOnce, MB_ICONERROR); return FALSE; } iPasteSkip = GetDlgItemInt(hDlg, IDC_PASTE_SKIPBYTES, 0, TRUE); HWND hwndEdit1 = GetDlgItem(hDlg, IDC_PASTE_CLIPBOARD); int destlen = GetWindowTextLength(hwndEdit1) + 1; TCHAR *pcPastestring = new TCHAR[destlen]; destlen = GetWindowText(hwndEdit1, pcPastestring, destlen); if (!bPasteAsText) { BYTE *pc = 0; destlen = create_bc_translation(&pc, pcPastestring, _tcslen(pcPastestring), iCharacterSet, iBinaryMode); delete [] pcPastestring; pcPastestring = (TCHAR *) pc; } if (destlen == 0) { LangString zeroLenArray(IDS_PASTE_WAS_EMPTY); MessageBox(hDlg, zeroLenArray, MB_ICONERROR); delete [] pcPastestring; return FALSE; } // Choose to paste as Unicode text or ansi text regardless of build configuration, // TODO: UI not yet implemented. // ex) bool bPasteAsUnicode = IsDlgButtonChecked(hDlg, IDC_PASTE_AS_UNICODE)) bool bPasteAsUnicode = false; BYTE *pasteData = (BYTE*) pcPastestring; int pasteSize = destlen * sizeof TCHAR; if (bPasteAsUnicode) { pasteData = new BYTE[destlen * sizeof WCHAR]; pasteSize = WideCharToMultiByte(CP_ACP, 0, pcPastestring, destlen, (LPSTR) pasteData, destlen, NULL, NULL); if ( pasteSize > 0 ) { delete [] pcPastestring; pcPastestring = (TCHAR *) pasteData; // delete me later. } } WaitCursor wc1; if (bSelected || IsDlgButtonChecked(hDlg, IDC_PASTE_INSERT)) { // Insert at iCurByte. Bytes there will be pushed up. if (bSelected) { iCurByte = iGetStartOfSelection(); int iEndByte = iGetEndOfSelection(); m_dataArray.RemoveAt(iCurByte, iEndByte - iCurByte + 1);//Remove extraneous data bSelected = false; // Deselect } int i = iCurByte; for (int k = 0 ; k < iPasteTimes ; k++) { if (!m_dataArray.InsertAtGrow(i, pasteData, 0, destlen)) { LangString noMem(IDS_PASTE_NO_MEM); MessageBox(hDlg, noMem, MB_ICONERROR); break; } i += destlen + iPasteSkip; } iFileChanged = TRUE; bFilestatusChanged = true; resize_window(); } else { // Overwrite. // Enough space for writing? // m_dataArray.GetLength()-iCurByte = number of bytes from including curbyte to end. if (m_dataArray.GetLength() - iCurByte < (iPasteSkip + destlen) * iPasteTimes) { LangString noSpace(IDS_PASTE_NO_SPACE); MessageBox(hDlg, noSpace, MB_ICONERROR); delete [] pcPastestring; return TRUE; } // Overwrite data. for (int k = 0 ; k < iPasteTimes ; k++) { for (int i = 0 ; i < destlen ; i++) { m_dataArray[iCurByte + k * (iPasteSkip + destlen) + i] = pasteData[i]; } } iFileChanged = TRUE; bFilestatusChanged = true; repaint(); } delete [] pcPastestring; return TRUE; }
INT_PTR CRecreateDlg::OnButtonClicked(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lParam) { switch (LOWORD(wParam)) { case IDC_CHOOSE: { wchar_t *pszFilePath = SelectFile(L"Choose program to run", NULL, NULL, hDlg, L"Executables (*.exe)\0*.exe\0All files (*.*)\0*.*\0\0", sff_AutoQuote); if (pszFilePath) { SetDlgItemText(hDlg, IDC_RESTART_CMD, pszFilePath); SafeFree(pszFilePath); } return TRUE; } // case IDC_CHOOSE: case IDC_CHOOSE_DIR: { wchar_t* pszDefFolder = GetDlgItemTextPtr(hDlg, IDC_STARTUP_DIR); wchar_t* pszFolder = SelectFolder(L"Choose startup directory", pszDefFolder, hDlg, sff_Default); if (pszFolder) { SetDlgItemText(hDlg, IDC_STARTUP_DIR, pszFolder); SafeFree(pszFolder); } SafeFree(pszDefFolder); return TRUE; } // case IDC_CHOOSE_DIR: case cbRunAsAdmin: { // BCM_SETSHIELD = 5644 BOOL bRunAs = SendDlgItemMessage(hDlg, cbRunAsAdmin, BM_GETCHECK, 0, 0); if (gOSVer.dwMajorVersion >= 6) { SendDlgItemMessage(hDlg, IDC_START, 5644/*BCM_SETSHIELD*/, 0, bRunAs && (mp_Args->aRecreate != cra_EditTab)); } if (bRunAs) { CheckRadioButton(hDlg, rbCurrentUser, rbAnotherUser, rbCurrentUser); CheckDlgButton(hDlg, cbRunAsRestricted, BST_UNCHECKED); RecreateDlgProc(hDlg, UM_USER_CONTROLS, 0, 0); } return TRUE; } // case cbRunAsAdmin: case rbCurrentUser: case rbAnotherUser: case cbRunAsNetOnly: case cbRunAsRestricted: { RecreateDlgProc(hDlg, UM_USER_CONTROLS, LOWORD(wParam), 0); return TRUE; } case rbRecreateSplitNone: case rbRecreateSplit2Right: case rbRecreateSplit2Bottom: { RConStartArgsEx* pArgs = mp_Args; switch (LOWORD(wParam)) { case rbRecreateSplitNone: pArgs->eSplit = RConStartArgsEx::eSplitNone; break; case rbRecreateSplit2Right: pArgs->eSplit = RConStartArgsEx::eSplitHorz; break; case rbRecreateSplit2Bottom: pArgs->eSplit = RConStartArgsEx::eSplitVert; break; } EnableWindow(GetDlgItem(hDlg, tRecreateSplit), (pArgs->eSplit != pArgs->eSplitNone)); EnableWindow(GetDlgItem(hDlg, stRecreateSplit), (pArgs->eSplit != pArgs->eSplitNone)); if (pArgs->eSplit != pArgs->eSplitNone) SetFocus(GetDlgItem(hDlg, tRecreateSplit)); return TRUE; } // case rbRecreateSplitXXX case IDC_START: { RConStartArgsEx* pArgs = mp_Args; _ASSERTE(pArgs); SafeFree(pArgs->pszUserName); SafeFree(pArgs->pszDomain); //SafeFree(pArgs->pszUserPassword); if (SendDlgItemMessage(hDlg, rbAnotherUser, BM_GETCHECK, 0, 0)) { pArgs->RunAsRestricted = crb_Off; pArgs->pszUserName = GetDlgItemTextPtr(hDlg, tRunAsUser); pArgs->RunAsNetOnly = SendDlgItemMessage(hDlg, cbRunAsNetOnly, BM_GETCHECK, 0, 0) ? crb_On : crb_Off; if (pArgs->pszUserName) { //pArgs->pszUserPassword = GetDlgItemText(hDlg, tRunAsPassword); // Попытаться проверить правильность введенного пароля и возможность запуска bool bCheckPwd = pArgs->CheckUserToken(GetDlgItem(hDlg, tRunAsPassword)); DWORD nErr = bCheckPwd ? 0 : GetLastError(); if (!bCheckPwd) { DisplayLastError(L"Invalid user name or password was specified!", nErr, MB_ICONSTOP, NULL, hDlg); return 1; } } } else { pArgs->RunAsRestricted = SendDlgItemMessage(hDlg, cbRunAsRestricted, BM_GETCHECK, 0, 0) ? crb_On : crb_Off; pArgs->RunAsNetOnly = crb_Off; } // Vista+ (As Admin...) pArgs->RunAsAdministrator = SendDlgItemMessage(hDlg, cbRunAsAdmin, BM_GETCHECK, 0, 0) ? crb_On : crb_Off; // StartupDir (may be specified as argument) wchar_t* pszDir = GetDlgItemTextPtr(hDlg, IDC_STARTUP_DIR); wchar_t* pszExpand = (pszDir && wcschr(pszDir, L'%')) ? ExpandEnvStr(pszDir) : NULL; LPCWSTR pszDirResult = pszExpand ? pszExpand : pszDir; // Another user? We may fail with access denied. Check only for "current user" account if (!pArgs->pszUserName && pszDirResult && *pszDirResult && !DirectoryExists(pszDirResult)) { wchar_t* pszErrInfo = lstrmerge(L"Specified directory does not exists!\n", pszDirResult, L"\n" L"Do you want to choose another directory?\n\n"); DWORD nErr = GetLastError(); int iDirBtn = DisplayLastError(pszErrInfo, nErr, MB_ICONEXCLAMATION|MB_YESNO, NULL, hDlg); if (iDirBtn == IDYES) { SafeFree(pszDir); SafeFree(pszExpand); SafeFree(pszErrInfo); return 1; } // User want to run "as is". Most likely it will fail, but who knows... } SafeFree(pArgs->pszStartupDir); pArgs->pszStartupDir = pszExpand ? pszExpand : pszDir; if (pszExpand) { SafeFree(pszDir) } // Command // pszSpecialCmd мог быть передан аргументом - умолчание для строки ввода SafeFree(pArgs->pszSpecialCmd); // GetDlgItemText выделяет память через calloc pArgs->pszSpecialCmd = GetDlgItemTextPtr(hDlg, IDC_RESTART_CMD); if (pArgs->pszSpecialCmd) gpSet->HistoryAdd(pArgs->pszSpecialCmd); // Especially to reset properly RunAsSystem in active console pArgs->ProcessNewConArg(); if (pArgs->RunAsSystem == crb_Undefined) pArgs->RunAsSystem = crb_Off; if ((pArgs->aRecreate != cra_RecreateTab) && (pArgs->aRecreate != cra_EditTab)) { if (SendDlgItemMessage(hDlg, cbRunInNewWindow, BM_GETCHECK, 0, 0)) pArgs->aRecreate = cra_CreateWindow; else pArgs->aRecreate = cra_CreateTab; } if (((pArgs->aRecreate == cra_CreateTab) || (pArgs->aRecreate == cra_EditTab)) && (pArgs->eSplit != RConStartArgsEx::eSplitNone)) { BOOL bOk = FALSE; int nPercent = GetDlgItemInt(hDlg, tRecreateSplit, &bOk, FALSE); if (bOk && (nPercent >= 1) && (nPercent <= 99)) { pArgs->nSplitValue = (100-nPercent) * 10; } //pArgs->nSplitPane = 0; Сбрасывать не будем? } mn_DlgRc = IDC_START; EndDialog(hDlg, IDC_START); return TRUE; } // case IDC_START: case IDC_TERMINATE: mn_DlgRc = IDC_TERMINATE; EndDialog(hDlg, IDC_TERMINATE); return TRUE; case IDCANCEL: mn_DlgRc = IDCANCEL; EndDialog(hDlg, IDCANCEL); return TRUE; } return FALSE; }
/****************************************************************** * WCUSER_ConfigDlgProc * * Dialog proc for the config property sheet */ static BOOL WINAPI WCUSER_ConfigDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { struct dialog_info* di; switch (msg) { case WM_INITDIALOG: di = (struct dialog_info*)((PROPSHEETPAGEA*)lParam)->lParam; di->hDlg = hDlg; SetWindowLong(hDlg, DWL_USER, (DWORD)di); SetDlgItemInt(hDlg, IDC_CNF_SB_WIDTH, di->config->sb_width, FALSE); SetDlgItemInt(hDlg, IDC_CNF_SB_HEIGHT, di->config->sb_height, FALSE); SetDlgItemInt(hDlg, IDC_CNF_WIN_WIDTH, di->config->win_width, FALSE); SetDlgItemInt(hDlg, IDC_CNF_WIN_HEIGHT, di->config->win_height, FALSE); break; case WM_COMMAND: di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER); switch (LOWORD(wParam)) { } break; case WM_NOTIFY: { NMHDR* nmhdr = (NMHDR*)lParam; COORD sb; SMALL_RECT pos; BOOL st_w, st_h; di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER); switch (nmhdr->code) { case PSN_SETACTIVE: di->hDlg = hDlg; break; case PSN_APPLY: sb.X = GetDlgItemInt(hDlg, IDC_CNF_SB_WIDTH, &st_w, FALSE); sb.Y = GetDlgItemInt(hDlg, IDC_CNF_SB_HEIGHT, &st_h, FALSE); if (st_w && st_h && (sb.X != di->config->sb_width || sb.Y != di->config->sb_height)) { (di->apply)(di, hDlg, WCUSER_ApplyToBufferSize, (DWORD)&sb); } pos.Right = GetDlgItemInt(hDlg, IDC_CNF_WIN_WIDTH, &st_w, FALSE); pos.Bottom = GetDlgItemInt(hDlg, IDC_CNF_WIN_HEIGHT, &st_h, FALSE); if (st_w && st_h && (pos.Right != di->config->win_width || pos.Bottom != di->config->win_height)) { pos.Left = pos.Top = 0; pos.Right--; pos.Bottom--; (di->apply)(di, hDlg, WCUSER_ApplyToWindow, (DWORD)&pos); } SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR); return TRUE; default: return FALSE; } break; } default: return FALSE; } return TRUE; }
/****************************************************************** * WCUSER_OptionDlgProc * * Dialog prop for the option property sheet */ static BOOL WINAPI WCUSER_OptionDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { struct dialog_info* di; unsigned idc; switch (msg) { case WM_INITDIALOG: di = (struct dialog_info*)((PROPSHEETPAGEA*)lParam)->lParam; di->hDlg = hDlg; SetWindowLong(hDlg, DWL_USER, (DWORD)di); if (di->config->cursor_size <= 25) idc = IDC_OPT_CURSOR_SMALL; else if (di->config->cursor_size <= 50) idc = IDC_OPT_CURSOR_MEDIUM; else idc = IDC_OPT_CURSOR_LARGE; SendDlgItemMessage(hDlg, idc, BM_SETCHECK, BST_CHECKED, 0L); SetDlgItemInt(hDlg, IDC_OPT_HIST_SIZE, WINECON_GetHistorySize(di->data->hConIn), FALSE); if (WINECON_GetHistoryMode(di->data->hConIn)) SendDlgItemMessage(hDlg, IDC_OPT_HIST_DOUBLE, BM_SETCHECK, BST_CHECKED, 0L); SendDlgItemMessage(hDlg, IDC_OPT_CONF_CTRL, BM_SETCHECK, (di->config->menu_mask & MK_CONTROL) ? BST_CHECKED : BST_UNCHECKED, 0L); SendDlgItemMessage(hDlg, IDC_OPT_CONF_SHIFT, BM_SETCHECK, (di->config->menu_mask & MK_SHIFT) ? BST_CHECKED : BST_UNCHECKED, 0L); SendDlgItemMessage(hDlg, IDC_OPT_QUICK_EDIT, BM_SETCHECK, (di->config->quick_edit) ? BST_CHECKED : BST_UNCHECKED, 0L); return FALSE; /* because we set the focus */ case WM_COMMAND: break; case WM_NOTIFY: { NMHDR* nmhdr = (NMHDR*)lParam; DWORD val; BOOL done; di = (struct dialog_info*)GetWindowLong(hDlg, DWL_USER); switch (nmhdr->code) { case PSN_SETACTIVE: /* needed in propsheet to keep properly the selected radio button * otherwise, the focus would be set to the first tab stop in the * propsheet, which would always activate the first radio button */ if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_SMALL) == BST_CHECKED) idc = IDC_OPT_CURSOR_SMALL; else if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_MEDIUM) == BST_CHECKED) idc = IDC_OPT_CURSOR_MEDIUM; else idc = IDC_OPT_CURSOR_LARGE; PostMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg, idc), TRUE); di->hDlg = hDlg; break; case PSN_APPLY: if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_SMALL) == BST_CHECKED) val = 25; else if (IsDlgButtonChecked(hDlg, IDC_OPT_CURSOR_MEDIUM) == BST_CHECKED) val = 50; else val = 99; (di->apply)(di, hDlg, WCUSER_ApplyToCursorSize, val); val = GetDlgItemInt(hDlg, IDC_OPT_HIST_SIZE, &done, FALSE); if (done) (di->apply)(di, hDlg, WCUSER_ApplyToHistorySize, val); (di->apply)(di, hDlg, WCUSER_ApplyToHistoryMode, IsDlgButtonChecked(hDlg, IDC_OPT_HIST_DOUBLE) & BST_CHECKED); val = 0; if (IsDlgButtonChecked(hDlg, IDC_OPT_CONF_CTRL) & BST_CHECKED) val |= MK_CONTROL; if (IsDlgButtonChecked(hDlg, IDC_OPT_CONF_SHIFT) & BST_CHECKED) val |= MK_SHIFT; (di->apply)(di, hDlg, WCUSER_ApplyToMenuMask, val); val = (IsDlgButtonChecked(hDlg, IDC_OPT_QUICK_EDIT) & BST_CHECKED) ? TRUE : FALSE; (di->apply)(di, hDlg, WCUSER_ApplyToEditMode, val); SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR); return TRUE; default: return FALSE; } break; } default: return FALSE; } return TRUE; }
static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE); OrderData *dat = (OrderData*)GetWindowLongPtr(hTree, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); dat = (OrderData*)malloc( sizeof(OrderData)); SetWindowLongPtr(hTree, GWLP_USERDATA, (LONG_PTR)dat); dat->dragging = 0; SetWindowLongPtr(hTree, GWL_STYLE, GetWindowLongPtr(hTree, GWL_STYLE)|TVS_NOHSCROLL); SetDlgItemInt(hwndDlg, IDC_BUTTHEIGHT, g_ctrl->nButtonHeight, FALSE); SendDlgItemMessage(hwndDlg, IDC_SPIN_HEIGHT, UDM_SETRANGE, 0, MAKELONG(50,10)); SendDlgItemMessage(hwndDlg, IDC_SPIN_HEIGHT, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonHeight,0)); SetDlgItemInt(hwndDlg, IDC_BUTTWIDTH, g_ctrl->nButtonWidth, FALSE); SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETRANGE, 0, MAKELONG(50,10)); SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonWidth,0)); SetDlgItemInt(hwndDlg, IDC_BUTTGAP, g_ctrl->nButtonSpace, FALSE); SendDlgItemMessage(hwndDlg, IDC_SPIN_GAP, UDM_SETRANGE, 0, MAKELONG(20,0)); SendDlgItemMessage(hwndDlg, IDC_SPIN_GAP, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonSpace,0)); CheckDlgButton(hwndDlg, IDC_USEFLAT, g_ctrl->bFlatButtons); CheckDlgButton(hwndDlg, IDC_AUTORESIZE, g_ctrl->bAutoSize); CheckDlgButton(hwndDlg, IDC_SINGLELINE, g_ctrl->bSingleLine); BuildTree(hwndDlg); EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_DELLBUTTON), FALSE); OptionshWnd = hwndDlg; return TRUE; case WM_COMMAND: if (HIWORD(wParam) == EN_CHANGE && OptionshWnd) { switch(LOWORD(wParam)) { case IDC_ENAME: case IDC_EPATH: break; default: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } break; } if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DBLCLK)) { int ctrlid = LOWORD(wParam); //----- Launch buttons ----- if (ctrlid == IDC_BROWSE) { TCHAR str[MAX_PATH]; OPENFILENAME ofn = {0}; GetDlgItemText(hwndDlg, IDC_EPATH, str, sizeof(str)); ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwndDlg; ofn.hInstance = NULL; ofn.lpstrFilter = NULL; ofn.lpstrFile = str; ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_EXPLORER; ofn.nMaxFile = sizeof(str); ofn.nMaxFileTitle = MAX_PATH; ofn.lpstrDefExt = _T("exe"); if (!GetOpenFileName(&ofn)) break; SetDlgItemText(hwndDlg, IDC_EPATH, str); break; } SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); if (ctrlid == IDC_LBUTTONSET) { TVITEM tvi ={0}; tvi.hItem = TreeView_GetSelection(hTree); if (tvi.hItem == NULL) break; tvi.mask = TVIF_PARAM; TreeView_GetItem(hTree, &tvi); TopButtonInt* btn = (TopButtonInt*)tvi.lParam; TCHAR buf [256]; // probably, condition not needs if (btn->dwFlags & TTBBF_ISLBUTTON) { if (!(btn->dwFlags & TTBBF_OPTIONAL)) { // create button TTBButton ttb = { 0 }; ttb.cbSize = sizeof(ttb); ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL; ttb.name = NULL; ttb.program = NULL; int id = btn->id; btn = CreateButton(&ttb); btn->id = id; tvi.lParam = (LPARAM)btn; TreeView_SetItem(hTree, &tvi); } GetDlgItemText(hwndDlg, IDC_ENAME, buf, 255); replaceStr(btn->pszName, _T2A(buf)); tvi.mask = TVIF_TEXT; tvi.pszText = buf; TreeView_SetItem(hTree, &tvi); GetDlgItemText(hwndDlg, IDC_EPATH, buf, 255); replaceStrT(btn->ptszProgram, buf); } break; } if (ctrlid == IDC_ADDLBUTTON) { // create button TTBButton ttb = { 0 }; ttb.cbSize = sizeof(ttb); ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL; ttb.name = LPGEN("Default"); ttb.program = _T("Execute Path"); TopButtonInt* b = CreateButton(&ttb); // get selection for insert TVITEM tvi = {0}; tvi.hItem = TreeView_GetSelection(hTree); // insert item AddLine(hTree, b, tvi.hItem, dat->himlButtonIcons); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } //----- Separators ----- if (ctrlid == IDC_ADDSEP) { // create button TTBButton ttb = { 0 }; ttb.cbSize = sizeof(ttb); ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSEPARATOR | TTBBF_INTERNAL | TTBBF_OPTIONAL; TopButtonInt* b = CreateButton(&ttb); // get selection for insert TVITEM tvi = {0}; tvi.hItem = TreeView_GetSelection(hTree); // insert item AddLine(hTree, b, tvi.hItem, dat->himlButtonIcons); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } if (ctrlid == IDC_REMOVEBUTTON) { TVITEM tvi = {0}; tvi.hItem = TreeView_GetSelection(hTree); if (tvi.hItem == NULL) break; tvi.mask = TVIF_PARAM; TreeView_GetItem(hTree, &tvi); TopButtonInt* btn = (TopButtonInt*)tvi.lParam; // if button enabled for separator and launch only, no need condition // except possible service button introducing if (btn->dwFlags & (TTBBF_ISSEPARATOR | TTBBF_ISLBUTTON)) { // delete if was added in options if (btn->dwFlags & TTBBF_OPTIONAL) delete btn; TreeView_DeleteItem(hTree,tvi.hItem); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } break; } } break; case WM_NOTIFY: switch(((LPNMHDR)lParam)->idFrom) { case 0: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: g_ctrl->nButtonHeight = GetDlgItemInt(hwndDlg, IDC_BUTTHEIGHT, NULL, FALSE); g_ctrl->nButtonWidth = GetDlgItemInt(hwndDlg, IDC_BUTTWIDTH, NULL, FALSE); g_ctrl->nButtonSpace = GetDlgItemInt(hwndDlg, IDC_BUTTGAP, NULL, FALSE); g_ctrl->bFlatButtons = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_USEFLAT); g_ctrl->bAutoSize = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTORESIZE); g_ctrl->bSingleLine = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SINGLELINE); db_set_dw(0, TTB_OPTDIR, "BUTTHEIGHT", g_ctrl->nButtonHeight); db_set_dw(0, TTB_OPTDIR, "BUTTWIDTH", g_ctrl->nButtonWidth); db_set_dw(0, TTB_OPTDIR, "BUTTGAP", g_ctrl->nButtonSpace); db_set_b(0, TTB_OPTDIR, "UseFlatButton", g_ctrl->bFlatButtons); db_set_b(0, TTB_OPTDIR, "SingleLine", g_ctrl->bSingleLine); db_set_b(0, TTB_OPTDIR, "AutoSize", g_ctrl->bAutoSize); SaveTree(hwndDlg); RecreateWindows(); ArrangeButtons(); } break; case IDC_BUTTONORDERTREE: switch (((LPNMHDR)lParam)->code) { case TVN_BEGINDRAGA: case TVN_BEGINDRAGW: SetCapture(hwndDlg); dat->dragging = 1; dat->hDragItem = ((LPNMTREEVIEW)lParam)->itemNew.hItem; TreeView_SelectItem(hTree, dat->hDragItem); break; case NM_CLICK: { TVHITTESTINFO hti; hti.pt.x = (short)LOWORD(GetMessagePos()); hti.pt.y = (short)HIWORD(GetMessagePos()); ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt); if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) if (hti.flags & TVHT_ONITEMSTATEICON) { SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); TreeView_SelectItem(hTree, hti.hItem); } } break; case TVN_SELCHANGEDA: case TVN_SELCHANGEDW: { HTREEITEM hti = TreeView_GetSelection(hTree); if (hti == NULL) break; TopButtonInt *btn = (TopButtonInt*)((LPNMTREEVIEW)lParam)->itemNew.lParam; mir_cslock lck(csButtonsHook); if (btn->dwFlags & TTBBF_ISLBUTTON) { bool enable = (btn->dwFlags & TTBBF_INTERNAL) !=0; EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), enable); EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), enable); EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVEBUTTON), enable); EnableWindow(GetDlgItem(hwndDlg, IDC_LBUTTONSET), enable); if (btn->pszName != NULL) SetDlgItemTextA(hwndDlg, IDC_ENAME, btn->pszName); else SetDlgItemTextA(hwndDlg, IDC_ENAME, ""); if (btn->ptszProgram != NULL) SetDlgItemText(hwndDlg, IDC_EPATH, btn->ptszProgram); else SetDlgItemTextA(hwndDlg, IDC_EPATH, ""); } else { EnableWindow(GetDlgItem(hwndDlg,IDC_REMOVEBUTTON), (btn->dwFlags & TTBBF_ISSEPARATOR)?TRUE:FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_LBUTTONSET), FALSE); SetDlgItemTextA(hwndDlg, IDC_ENAME, ""); SetDlgItemTextA(hwndDlg, IDC_EPATH, ""); } } } break; } break; case WM_MOUSEMOVE: if (dat->dragging) { TVHITTESTINFO hti; hti.pt.x = (short)LOWORD(lParam); hti.pt.y = (short)HIWORD(lParam); ClientToScreen(hwndDlg, &hti.pt); ScreenToClient(hTree, &hti.pt); TreeView_HitTest(hTree, &hti); if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) { HTREEITEM it=hti.hItem; hti.pt.y -= TreeView_GetItemHeight(hTree)/2; TreeView_HitTest(hTree, &hti); if (!(hti.flags&TVHT_ABOVE)) TreeView_SetInsertMark(hTree,hti.hItem,1); else TreeView_SetInsertMark(hTree,it,0); } else { if (hti.flags & TVHT_ABOVE) SendMessage(hTree, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0); if (hti.flags & TVHT_BELOW) SendMessage(hTree, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0); TreeView_SetInsertMark(hTree, NULL, 0); } } break; case WM_LBUTTONUP: if (dat->dragging) { TreeView_SetInsertMark(hTree, NULL, 0); dat->dragging = 0; ReleaseCapture(); TVHITTESTINFO hti; hti.pt.x = (short)LOWORD(lParam); hti.pt.y = (short)HIWORD(lParam); ClientToScreen(hwndDlg, &hti.pt); ScreenToClient(hTree, &hti.pt); hti.pt.y -= TreeView_GetItemHeight(hTree)/2; TreeView_HitTest(hTree, &hti); if (dat->hDragItem == hti.hItem) break; if (hti.flags&TVHT_ABOVE) hti.hItem=TVI_FIRST; TVITEM tvi; tvi.mask = TVIF_HANDLE|TVIF_PARAM; tvi.hItem = (HTREEITEM) dat->hDragItem; TreeView_GetItem(hTree, &tvi); if ( (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) || (hti.hItem==TVI_FIRST)) { TVINSERTSTRUCT tvis; TCHAR name[128]; tvis.item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE; tvis.item.stateMask = 0xFFFFFFFF; tvis.item.pszText = name; tvis.item.cchTextMax = SIZEOF(name); tvis.item.hItem = dat->hDragItem; TreeView_GetItem(hTree, &tvis.item); TreeView_DeleteItem(hTree, dat->hDragItem); tvis.hParent = NULL; tvis.hInsertAfter = hti.hItem; TreeView_SelectItem(hTree, TreeView_InsertItem(hTree, &tvis)); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } } break; case WM_DESTROY: if (dat) { ImageList_Destroy(dat->himlButtonIcons); free(dat); } OptionshWnd = NULL; break; } return FALSE; }
void CCreateTPDownloadDlg::OnOk() { if (IR_SUCCESS != Crack(m_strUrl)) return WrongURL (); GetDlgItemText (IDC_SAVEAS, m_strFileName); int nDldType = m_wndDldType.GetCurSel (); if (nDldType == 1) { char sz [MY_MAX_PATH]; GetTempPath (sizeof (sz), sz); m_strOutFolder = sz; } else { if (FALSE == _CheckFolderName (this, IDC_OUTFOLDER)) return; GetDlgItemText (IDC_OUTFOLDER, m_strOutFolder); if (IsDlgButtonChecked (IDC_FILEAUTO) == BST_UNCHECKED) { if (m_strFileName == "") { MessageBox (LS (L_EMPTY), LS (L_INPERR), MB_ICONEXCLAMATION); GetDlgItem (IDC_SAVEAS)->SetFocus (); return; } if (FALSE == _CheckFileName (this, IDC_SAVEAS)) return; _App.NewDL_GenerateNameAutomatically (FALSE); } else _App.NewDL_GenerateNameAutomatically (TRUE); } fsPathToGoodPath ((LPSTR)(LPCSTR)m_strOutFolder); fsPathToGoodPath ((LPSTR)(LPCSTR)m_strFileName); if (m_strOutFolder.GetLength () == 0) { MessageBox (LS (L_ENTERFLRNAME), LS (L_INPERR), MB_ICONEXCLAMATION); GetDlgItem (IDC_OUTFOLDER)->SetFocus (); return; } if (nDldType != 1) _LastFolders.AddRecord (m_strOutFolder); _LastUrlFiles.AddRecord (m_strUrl); if (m_strOutFolder [m_strOutFolder.GetLength () - 1] != '\\' && m_strOutFolder [m_strOutFolder.GetLength () - 1] != '/') m_strOutFolder += '\\'; if (_App.NewGrp_SelectWay () == NGSW_USE_ALWAYS_SAME_GROUP_WITH_OUTFOLDER_AUTO_UPDATE) { vmsDownloadsGroupSmartPtr pGrp = _DldsGrps.FindGroup (_App.NewDL_GroupId ()); if (pGrp != NULL) { pGrp->strOutFolder = m_strOutFolder; pGrp->setDirty(); } } if (_App.CheckIfDownloadWithSameUrlExists ()) { int ret = _CheckDownloadAlrExists (m_dld); if (ret) { if (ret == 1) EndDialog (ID_DLNOTADDED); return; } } m_dld->pGroup = m_wndGroups.GetSelectedGroup (); GetDlgItemText (IDC_COMMENT, m_dld->strComment); BOOL bUseZipPreview = _App.NewDL_UseZIPPreview (); _App.UseZipPreview (bUseZipPreview); if (nDldType == 1) { m_dld->dwFlags |= DLD_DELETEWHENDONE | DLD_DELETEFILEATRESTART; } else if (nDldType == 2) m_dld->dwFlags |= DPF_STARTWHENDONE; m_wndGroups.RememberSelectedGroup (); m_nStreamingSpeed = GetDlgItemInt (IDC_STRSPEED); if (m_bThread) { m_bNeedExit = TRUE; while (m_bThread); } _App.OnDlHasBeenCreatedByUser (); m_bPlaceAtTop = IsDlgButtonChecked (IDC_PLACEATTOP) == BST_CHECKED; CDialog::OnOK(); }
LRESULT CALLBACK DlgOptions( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { static LPCWSTR szExeName; SHIM_SETTINGS ShimSettingsTemp; LPSHIM_SETTINGS pShimSettings = & gShimSettings; DWORD cbSize; switch (message) { case WM_INITDIALOG: { // // find out what exe we're handling settings for // szExeName = ExeNameFromLParam(lParam); GetShimSettings (szExeName, & pShimSettings, & cbSize); RefreshDlgData (hDlg); return TRUE; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_DEFAULT: { // Save off the globals memcpy (& ShimSettingsTemp, & gShimSettings, sizeof (SHIM_SETTINGS)); // Set the default values gShimSettings.dwFoo = 0; // Update the UI to reflect the default values. RefreshDlgData (hDlg); // Restore the globals (in case this isn't 'applied') memcpy (& gShimSettings, & ShimSettingsTemp, sizeof (SHIM_SETTINGS)); break; } } break; case WM_NOTIFY: switch (((NMHDR FAR *) lParam)->code) { case PSN_KILLACTIVE: { break; } case PSN_APPLY: { NKDbgPrintfW (_T("Applying settings for %s\r\n"), szExeName); // Retrieve settings from the UI. gShimSettings.dwFoo = GetDlgItemInt ( hDlg, IDC_EDIT_FOO, NULL, FALSE ); SetShimSettings (szExeName, & gShimSettings, sizeof (SHIM_SETTINGS)); break; } } break; } return FALSE; }
INT_PTR CALLBACK DlgProcOptsConnections(HWND hWndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { CMraProto *ppro = (CMraProto*)GetWindowLongPtr(hWndDlg, GWLP_USERDATA); CMStringW szBuff; switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hWndDlg); SetWindowLongPtr(hWndDlg, GWLP_USERDATA, lParam); ppro = (CMraProto*)lParam; if (ppro->mraGetStringW(NULL, "Server", szBuff)) SetDlgItemText(hWndDlg, IDC_SERVER, szBuff.c_str()); else SetDlgItemTextA(hWndDlg, IDC_SERVER, MRA_DEFAULT_SERVER); SetDlgItemInt(hWndDlg, IDC_SERVERPORT, ppro->getWord("ServerPort", MRA_DEFAULT_SERVER_PORT), FALSE); // if set SSL proxy, setting will ignored //CheckDlgButton(hWndDlg, IDC_KEEPALIVE, getByte("keepalive", 0)); CheckDlgButton(hWndDlg, IDC_AUTO_ADD_CONTACTS_TO_SERVER, ppro->getByte("AutoAddContactsToServer", MRA_DEFAULT_AUTO_ADD_CONTACTS_TO_SERVER)); CheckDlgButton(hWndDlg, IDC_AUTO_AUTH_REQ_ON_LOGON, ppro->getByte("AutoAuthRequestOnLogon", MRA_DEFAULT_AUTO_AUTH_REQ_ON_LOGON)); CheckDlgButton(hWndDlg, IDC_AUTO_AUTH_GRAND_IN_CLIST, ppro->getByte("AutoAuthGrandUsersInCList", MRA_DEFAULT_AUTO_AUTH_GRAND_IN_CLIST)); CheckDlgButton(hWndDlg, IDC_AUTO_AUTH_GRAND_NEW_USERS, ppro->getByte("AutoAuthGrandNewUsers", MRA_DEFAULT_AUTO_AUTH_GRAND_NEW_USERS)); CheckDlgButton(hWndDlg, IDC_SLOWSEND, ppro->getByte("SlowSend", MRA_DEFAULT_SLOW_SEND)); CheckDlgButton(hWndDlg, IDC_INCREMENTAL_NEW_MAIL_NOTIFY, ppro->getByte("IncrementalNewMailNotify", MRA_DEFAULT_INC_NEW_MAIL_NOTIFY)); CheckDlgButton(hWndDlg, IDC_TRAYICON_NEW_MAIL_NOTIFY, ppro->getByte("TrayIconNewMailNotify", MRA_DEFAULT_TRAYICON_NEW_MAIL_NOTIFY)); CheckDlgButton(hWndDlg, IDC_TRAYICON_NEW_MAIL_NOTIFY_CLICK_TO_INBOX, ppro->getByte("TrayIconNewMailClkToInbox", MRA_DEFAULT_TRAYICON_NEW_MAIL_CLK_TO_INBOX)); EnableWindow(GetDlgItem(hWndDlg, IDC_TRAYICON_NEW_MAIL_NOTIFY_CLICK_TO_INBOX), ppro->getByte("TrayIconNewMailNotify", MRA_DEFAULT_TRAYICON_NEW_MAIL_NOTIFY)); CheckDlgButton(hWndDlg, IDC_RTF_RECEIVE_ENABLE, ppro->getByte("RTFReceiveEnable", MRA_DEFAULT_RTF_RECEIVE_ENABLE)); CheckDlgButton(hWndDlg, IDC_RTF_SEND_ENABLE, ppro->getByte("RTFSendEnable", MRA_DEFAULT_RTF_SEND_ENABLE)); EnableWindow(GetDlgItem(hWndDlg, IDC_RTF_SEND_SMART), ppro->getByte("RTFSendEnable", MRA_DEFAULT_RTF_SEND_ENABLE)); EnableWindow(GetDlgItem(hWndDlg, IDC_BUTTON_FONT), ppro->getByte("RTFSendEnable", MRA_DEFAULT_RTF_SEND_ENABLE)); EnableWindow(GetDlgItem(hWndDlg, IDC_RTF_BGCOLOUR), ppro->getByte("RTFSendEnable", MRA_DEFAULT_RTF_SEND_ENABLE)); SendDlgItemMessage(hWndDlg, IDC_RTF_BGCOLOUR, CPM_SETCOLOUR, 0, ppro->getDword("RTFBackgroundColour", MRA_DEFAULT_RTF_BACKGROUND_COLOUR)); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_BUTTON_DEFAULT: SetDlgItemTextA(hWndDlg, IDC_SERVER, MRA_DEFAULT_SERVER); SetDlgItemInt(hWndDlg, IDC_SERVERPORT, MRA_DEFAULT_SERVER_PORT, FALSE); break; case IDC_TRAYICON_NEW_MAIL_NOTIFY: EnableWindow(GetDlgItem(hWndDlg, IDC_TRAYICON_NEW_MAIL_NOTIFY_CLICK_TO_INBOX), IsDlgButtonChecked(hWndDlg, IDC_TRAYICON_NEW_MAIL_NOTIFY)); break; case IDC_RTF_SEND_ENABLE: EnableWindow(GetDlgItem(hWndDlg, IDC_RTF_SEND_SMART), IsDlgButtonChecked(hWndDlg, IDC_RTF_SEND_ENABLE)); EnableWindow(GetDlgItem(hWndDlg, IDC_BUTTON_FONT), IsDlgButtonChecked(hWndDlg, IDC_RTF_SEND_ENABLE)); EnableWindow(GetDlgItem(hWndDlg, IDC_RTF_BGCOLOUR), IsDlgButtonChecked(hWndDlg, IDC_RTF_SEND_ENABLE)); break; case IDC_BUTTON_FONT: { LOGFONT lf = {0}; CHOOSEFONT cf = {0}; cf.lStructSize = sizeof(cf); cf.lpLogFont = &lf; cf.rgbColors = ppro->getDword("RTFFontColour", MRA_DEFAULT_RTF_FONT_COLOUR); cf.Flags = (CF_SCREENFONTS|CF_EFFECTS|CF_FORCEFONTEXIST|CF_INITTOLOGFONTSTRUCT); if (ppro->mraGetContactSettingBlob(NULL, "RTFFont", &lf, sizeof(LOGFONT), NULL) == FALSE) { HDC hDC = GetDC(NULL);// kegl lf.lfCharSet = MRA_DEFAULT_RTF_FONT_CHARSET; lf.lfHeight = -MulDiv(MRA_DEFAULT_RTF_FONT_SIZE, GetDeviceCaps(hDC, LOGPIXELSY), 72); lstrcpyn(lf.lfFaceName, MRA_DEFAULT_RTF_FONT_NAME, LF_FACESIZE); ReleaseDC(NULL, hDC); } if (ChooseFont(&cf)) { ppro->mraWriteContactSettingBlob(NULL, "RTFFont", &lf, sizeof(LOGFONT)); ppro->setDword("RTFFontColour", cf.rgbColors); } } break; } if ((LOWORD(wParam) == IDC_SERVER || LOWORD(wParam) == IDC_SERVERPORT) && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return FALSE; SendMessage(GetParent(hWndDlg), PSM_CHANGED, 0, 0); break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: TCHAR szBuff[MAX_PATH]; GetDlgItemText(hWndDlg, IDC_SERVER, szBuff, SIZEOF(szBuff)); ppro->mraSetStringW(NULL, "Server", szBuff); ppro->setWord("ServerPort", (WORD)GetDlgItemInt(hWndDlg, IDC_SERVERPORT, NULL, FALSE)); ppro->setByte("AutoAddContactsToServer", IsDlgButtonChecked(hWndDlg, IDC_AUTO_ADD_CONTACTS_TO_SERVER)); ppro->setByte("AutoAuthRequestOnLogon", IsDlgButtonChecked(hWndDlg, IDC_AUTO_AUTH_REQ_ON_LOGON)); ppro->setByte("AutoAuthGrandUsersInCList", IsDlgButtonChecked(hWndDlg, IDC_AUTO_AUTH_GRAND_IN_CLIST)); ppro->setByte("AutoAuthGrandNewUsers", IsDlgButtonChecked(hWndDlg, IDC_AUTO_AUTH_GRAND_NEW_USERS)); ppro->setByte("SlowSend", IsDlgButtonChecked(hWndDlg, IDC_SLOWSEND)); ppro->setByte("IncrementalNewMailNotify", IsDlgButtonChecked(hWndDlg, IDC_INCREMENTAL_NEW_MAIL_NOTIFY)); ppro->setByte("TrayIconNewMailNotify", IsDlgButtonChecked(hWndDlg, IDC_TRAYICON_NEW_MAIL_NOTIFY)); ppro->setByte("TrayIconNewMailClkToInbox", IsDlgButtonChecked(hWndDlg, IDC_TRAYICON_NEW_MAIL_NOTIFY_CLICK_TO_INBOX)); ppro->setByte("RTFReceiveEnable", IsDlgButtonChecked(hWndDlg, IDC_RTF_RECEIVE_ENABLE)); ppro->setByte("RTFSendEnable", IsDlgButtonChecked(hWndDlg, IDC_RTF_SEND_ENABLE)); ppro->setDword("RTFBackgroundColour", SendDlgItemMessage(hWndDlg, IDC_RTF_BGCOLOUR, CPM_GETCOLOUR, 0, 0)); return TRUE; } break; } return FALSE; }
void SettingsAdvanced::ApplySettings() { //precheck for QSV enable/disable in case the checkbox is currently enabled while no hardware support is found bool bUseQSV = SendMessage(GetDlgItem(hwnd, IDC_USEQSV), BM_GETCHECK, 0, 0) == BST_CHECKED; bool bUseQSV_prev = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseQSV")) != 0; if (!bHasQSV && !bUseQSV && bUseQSV_prev && MessageBox(hwnd, Str("Settings.Advanced.UseQSVDisabledAfterApply"), Str("MessageBoxWarningCaption"), MB_ICONEXCLAMATION | MB_OKCANCEL) != IDOK) { SetAbortApplySettings(true); return; } //precheck for NVENC enable/disable in case the checkbox is currently enabled while no hardware support is found bool bUseNVENC = SendMessage(GetDlgItem(hwnd, IDC_USENVENC), BM_GETCHECK, 0, 0) == BST_CHECKED; bool bUseNVENC_prev = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseNVENC")) != 0; if (!bHasNVENC && !bUseNVENC && bUseNVENC_prev && MessageBox(hwnd, Str("Settings.Advanced.UseNVENCDisabledAfterApply"), Str("MessageBoxWarningCaption"), MB_ICONEXCLAMATION | MB_OKCANCEL) != IDOK) { SetAbortApplySettings(true); return; } //-------------------------------------------------- String strTemp = GetCBText(GetDlgItem(hwnd, IDC_PRESET)); AppConfig->SetString(TEXT("Video Encoding"), TEXT("Preset"), strTemp); //------------------------------------ strTemp = GetCBText(GetDlgItem(hwnd, IDC_X264PROFILE)); AppConfig->SetString(TEXT("Video Encoding"), TEXT("X264Profile"), strTemp); //-------------------------------------------------- bool bUseMTOptimizations = SendMessage(GetDlgItem(hwnd, IDC_USEMULTITHREADEDOPTIMIZATIONS), BM_GETCHECK, 0, 0) == BST_CHECKED; AppConfig->SetInt(TEXT("General"), TEXT("UseMultithreadedOptimizations"), bUseMTOptimizations); int priority = (int)SendMessage(GetDlgItem(hwnd, IDC_PRIORITY), CB_GETCURSEL, 0, 0); switch (priority) { case 0: strTemp = TEXT("High"); break; case 1: strTemp = TEXT("Above Normal"); break; case 2: strTemp = TEXT("Normal"); break; case 3: strTemp = TEXT("Idle"); break; } AppConfig->SetString(TEXT("General"), TEXT("Priority"), strTemp); //-------------------------------------------------- UINT sceneBufferTime = (UINT)SendMessage(GetDlgItem(hwnd, IDC_SCENEBUFFERTIME), UDM_GETPOS32, 0, 0); GlobalConfig->SetInt(TEXT("General"), TEXT("SceneBufferingTime"), sceneBufferTime); //-------------------------------------------------- bool bDisablePreviewEncoding = SendMessage(GetDlgItem(hwnd, IDC_DISABLEPREVIEWENCODING), BM_GETCHECK, 0, 0) == BST_CHECKED; GlobalConfig->SetInt(TEXT("General"), TEXT("DisablePreviewEncoding"), bDisablePreviewEncoding); //-------------------------------------------------- bool bAllowOtherHotkeyModifiers = SendMessage(GetDlgItem(hwnd, IDC_ALLOWOTHERHOTKEYMODIFIERS), BM_GETCHECK, 0, 0) == BST_CHECKED; GlobalConfig->SetInt(TEXT("General"), TEXT("AllowOtherHotkeyModifiers"), bAllowOtherHotkeyModifiers); //-------------------------------------------------- UINT keyframeInt = (UINT)SendMessage(GetDlgItem(hwnd, IDC_KEYFRAMEINTERVAL), UDM_GETPOS32, 0, 0); AppConfig->SetInt(TEXT("Video Encoding"), TEXT("KeyframeInterval"), keyframeInt); //-------------------------------------------------- bool bUseCFR = SendMessage(GetDlgItem(hwnd, IDC_USECFR), BM_GETCHECK, 0, 0) == BST_CHECKED; AppConfig->SetInt (TEXT("Video Encoding"), TEXT("UseCFR"), bUseCFR); //-------------------------------------------------- BOOL bUseCustomX264Settings = SendMessage(GetDlgItem(hwnd, IDC_USEVIDEOENCODERSETTINGS), BM_GETCHECK, 0, 0) == BST_CHECKED; String strCustomX264Settings = GetEditText(GetDlgItem(hwnd, IDC_VIDEOENCODERSETTINGS)); AppConfig->SetInt (TEXT("Video Encoding"), TEXT("UseCustomSettings"), bUseCustomX264Settings); AppConfig->SetString(TEXT("Video Encoding"), TEXT("CustomSettings"), strCustomX264Settings); //-------------------------------------------------- BOOL bUnlockFPS = SendMessage(GetDlgItem(hwnd, IDC_UNLOCKHIGHFPS), BM_GETCHECK, 0, 0) == BST_CHECKED; AppConfig->SetInt (TEXT("Video"), TEXT("UnlockFPS"), bUnlockFPS); //------------------------------------ EnableWindow(GetDlgItem(hwnd, IDC_USEQSV), (bHasQSV || bUseQSV) && !bUseNVENC); AppConfig->SetInt(TEXT("Video Encoding"), TEXT("UseQSV"), bUseQSV); BOOL bQSVUseVideoEncoderSettings = SendMessage(GetDlgItem(hwnd, IDC_QSVUSEVIDEOENCODERSETTINGS), BM_GETCHECK, 0, 0) == BST_CHECKED; AppConfig->SetInt(TEXT("Video Encoding"), TEXT("QSVUseVideoEncoderSettings"), bQSVUseVideoEncoderSettings); //------------------------------------ EnableWindow(GetDlgItem(hwnd, IDC_USENVENC), (bHasNVENC || bUseNVENC) && !bUseQSV); AppConfig->SetInt(TEXT("Video Encoding"), TEXT("UseNVENC"), bUseNVENC && !bUseQSV); SendMessage(GetDlgItem(hwnd, IDC_USENVENC), BM_SETCHECK, (bUseNVENC && !bUseQSV) ? BST_CHECKED : BST_UNCHECKED, 0); //------------------------------------ strTemp = GetCBText(GetDlgItem(hwnd, IDC_NVENCPRESET)); AppConfig->SetString(TEXT("Video Encoding"), TEXT("NVENCPreset"), strTemp); //------------------------------------ BOOL bSyncToVideoTime = SendMessage(GetDlgItem(hwnd, IDC_SYNCTOVIDEOTIME), BM_GETCHECK, 0, 0) == BST_CHECKED; AppConfig->SetInt (TEXT("Audio"), TEXT("SyncToVideoTime"), bSyncToVideoTime); //-------------------------------------------------- BOOL bUseMicQPC = SendMessage(GetDlgItem(hwnd, IDC_USEMICQPC), BM_GETCHECK, 0, 0) == BST_CHECKED; GlobalConfig->SetInt(TEXT("Audio"), TEXT("UseMicQPC"), bUseMicQPC); //-------------------------------------------------- int globalAudioTimeAdjust = (int)SendMessage(GetDlgItem(hwnd, IDC_AUDIOTIMEADJUST), UDM_GETPOS32, 0, 0); GlobalConfig->SetInt(TEXT("Audio"), TEXT("GlobalAudioTimeAdjust"), globalAudioTimeAdjust); //-------------------------------------------------- BOOL bUseMicSyncFixHack = SendMessage(GetDlgItem(hwnd, IDC_MICSYNCFIX), BM_GETCHECK, 0, 0) == BST_CHECKED; GlobalConfig->SetInt(TEXT("Audio"), TEXT("UseMicSyncFixHack"), bUseMicSyncFixHack); //-------------------------------------------------- BOOL bLowLatencyAutoMode = SendMessage(GetDlgItem(hwnd, IDC_LATENCYMETHOD), BM_GETCHECK, 0, 0) == BST_CHECKED; int latencyFactor = GetDlgItemInt(hwnd, IDC_LATENCYTUNE, NULL, TRUE); AppConfig->SetInt (TEXT("Publish"), TEXT("LatencyFactor"), latencyFactor); AppConfig->SetInt (TEXT("Publish"), TEXT("LowLatencyMethod"), bLowLatencyAutoMode); //-------------------------------------------------- strTemp = GetCBText(GetDlgItem(hwnd, IDC_BINDIP)); AppConfig->SetString(TEXT("Publish"), TEXT("BindToIP"), strTemp); }
UINT CShowNum::GetNum( int nID ) { UpdateData(TRUE); return GetDlgItemInt( nID, NULL, FALSE ); }
/* ======================================================================================= ======================================================================================= */ bool run(HWND hDlg) { char src[MAX_PATH], dst[MAX_PATH], dst_name[MAX_PATH], error[2 * MAX_PATH]; char *p; FILE *fin, *fout; int max_particles, line_count; bool result; max_particles = GetDlgItemInt(hDlg, IDC_MAX_PARTICLES, NULL, FALSE); if (max_particles == 0) { MessageBox(hDlg, "Zero max particles is not acceptable.", "Error", MB_OK); return false; } memset(src, 0, sizeof(src)); GetDlgItemText(hDlg, IDC_ORIGINAL_LIST, src, MAX_PATH - 1); if (!file_exists(src)) { return false; } memset(dst_name, 0, sizeof(dst_name)); GetDlgItemText(hDlg, IDC_OUTPUT_LIST, dst_name, sizeof(dst_name)); if (strlen(dst_name) == 0) { MessageBox(hDlg, "Need an output file name.", "Error", MB_OK); return false; } strncpy_s(dst, sizeof(dst), src, _TRUNCATE); p = strrchr(dst, '\\'); if (!p) { MessageBox(hDlg, "Can't find a path delimiter in the source file!", "Error", MB_OK); return false; } p++; *p = 0; strncat_s(dst, sizeof(dst), dst_name, _TRUNCATE); if (!strcmp(src, dst)) { MessageBox(hDlg, "Sorry, not going to overwrite the original list file.", "No Clobbering Originals", MB_OK); return false; } if (file_exists(dst)) { sprintf_s(error, sizeof(error), "The output file\n%s\nalready exists.\n\nOverwrite?", dst); if (IDNO == MessageBox(hDlg, error, "Overwrite Existing File", MB_YESNO)) { return false; } } line_count = count_lines_in_file(hDlg, src); if (line_count < 0) { // error already shown return false; } else if (line_count < 2) { MessageBox(hDlg, "Source file line count is too small to believe", "Error", MB_OK); return false; } if (fopen_s(&fin, src, "rb")) { MessageBox(hDlg, "Error opening original file.", "Error", MB_OK); return false; } if (fopen_s(&fout, dst, "wb")) { fclose(fin); MessageBox(hDlg, "Error opening output file.", "Error", MB_OK); return false; } SetCursor(LoadCursor(NULL, IDC_WAIT)); result = shave(hDlg, line_count, max_particles, fin, fout); fclose(fin); fclose(fout); SetCursor(LoadCursor(NULL, IDC_ARROW)); if (result) { p = strrchr(src, '.'); if (!p) { MessageBox(hDlg, "Internal error, source context", "Error Copying Context", MB_OK); return false; } *p = 0; strncat_s(src, MAX_PATH, ".ctx", _TRUNCATE); if (!file_exists(src)) { MessageBox(hDlg, "Failed to find context file for original.", "Error Copying Context", MB_OK); return false; } p = strrchr(dst, '.'); if (!p) { MessageBox(hDlg, "Internal error, dest context", "Error Copying Context", MB_OK); return false; } *p = 0; strncat_s(dst, MAX_PATH, ".ctx", _TRUNCATE); if (fopen_s(&fin, src, "rb")) { MessageBox(hDlg, "Error opening original context file.", "Error", MB_OK); return false; } if (fopen_s(&fout, dst, "wb")) { fclose(fin); MessageBox(hDlg, "Error opening output context file.", "Error", MB_OK); return false; } result = copy_context(fin, fout); fclose(fin); fclose(fout); if (!result) { MessageBox(hDlg, "Error copying context file.", "Error", MB_OK); } } return result; }
INT_PTR CALLBACK LayoutProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { LPNMUPDOWN lpnmud; LPPSHNOTIFY lppsn; PCONSOLE_PROPS pConInfo = (PCONSOLE_PROPS)GetWindowLongPtr(hwndDlg, DWLP_USER); PGUI_CONSOLE_INFO GuiInfo = (pConInfo ? pConInfo->TerminalInfo.TermInfo : NULL); UNREFERENCED_PARAMETER(hwndDlg); UNREFERENCED_PARAMETER(wParam); switch (uMsg) { case WM_INITDIALOG: { DWORD xres, yres; HDC hDC; pConInfo = (PCONSOLE_PROPS)((LPPROPSHEETPAGE)lParam)->lParam; GuiInfo = pConInfo->TerminalInfo.TermInfo; SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pConInfo); SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_SCREEN_BUFFER_HEIGHT), UDM_SETRANGE, 0, (LPARAM)MAKELONG(9999, 1)); SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_SCREEN_BUFFER_WIDTH), UDM_SETRANGE, 0, (LPARAM)MAKELONG(9999, 1)); SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_SIZE_HEIGHT), UDM_SETRANGE, 0, (LPARAM)MAKELONG(9999, 1)); SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_SIZE_WIDTH), UDM_SETRANGE, 0, (LPARAM)MAKELONG(9999, 1)); SetDlgItemInt(hwndDlg, IDC_EDIT_SCREEN_BUFFER_HEIGHT, pConInfo->ci.ScreenBufferSize.Y, FALSE); SetDlgItemInt(hwndDlg, IDC_EDIT_SCREEN_BUFFER_WIDTH, pConInfo->ci.ScreenBufferSize.X, FALSE); SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_HEIGHT, pConInfo->ci.ConsoleSize.Y, FALSE); SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_WIDTH, pConInfo->ci.ConsoleSize.X, FALSE); hDC = GetDC(NULL); xres = GetDeviceCaps(hDC, HORZRES); yres = GetDeviceCaps(hDC, VERTRES); SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_POS_LEFT), UDM_SETRANGE, 0, (LPARAM)MAKELONG(xres, 0)); SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_POS_TOP), UDM_SETRANGE, 0, (LPARAM)MAKELONG(yres, 0)); if ( GuiInfo->WindowOrigin.x != MAXDWORD && GuiInfo->WindowOrigin.y != MAXDWORD ) { SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_LEFT, GuiInfo->WindowOrigin.x, FALSE); SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_TOP, GuiInfo->WindowOrigin.y, FALSE); } else { // FIXME: Calculate window pos from xres, yres SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_LEFT, 88, FALSE); SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_TOP, 88, FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_WINDOW_POS_LEFT), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_WINDOW_POS_TOP), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_POS_LEFT), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_POS_TOP), FALSE); SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_SYSTEM_POS_WINDOW), BM_SETCHECK, (WPARAM)BST_CHECKED, 0); } return TRUE; } case WM_DRAWITEM: { PaintConsole((LPDRAWITEMSTRUCT)lParam, pConInfo); return TRUE; } case WM_NOTIFY: { lpnmud = (LPNMUPDOWN) lParam; lppsn = (LPPSHNOTIFY) lParam; if (lppsn->hdr.code == UDN_DELTAPOS) { DWORD wheight, wwidth; DWORD sheight, swidth; DWORD left, top; if (lppsn->hdr.idFrom == IDC_UPDOWN_WINDOW_SIZE_WIDTH) { wwidth = lpnmud->iPos + lpnmud->iDelta; } else { wwidth = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_WIDTH, NULL, FALSE); } if (lppsn->hdr.idFrom == IDC_UPDOWN_WINDOW_SIZE_HEIGHT) { wheight = lpnmud->iPos + lpnmud->iDelta; } else { wheight = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_HEIGHT, NULL, FALSE); } if (lppsn->hdr.idFrom == IDC_UPDOWN_SCREEN_BUFFER_WIDTH) { swidth = lpnmud->iPos + lpnmud->iDelta; } else { swidth = GetDlgItemInt(hwndDlg, IDC_EDIT_SCREEN_BUFFER_WIDTH, NULL, FALSE); } if (lppsn->hdr.idFrom == IDC_UPDOWN_SCREEN_BUFFER_HEIGHT) { sheight = lpnmud->iPos + lpnmud->iDelta; } else { sheight = GetDlgItemInt(hwndDlg, IDC_EDIT_SCREEN_BUFFER_HEIGHT, NULL, FALSE); } if (lppsn->hdr.idFrom == IDC_UPDOWN_WINDOW_POS_LEFT) { left = lpnmud->iPos + lpnmud->iDelta; } else { left = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_LEFT, NULL, FALSE); } if (lppsn->hdr.idFrom == IDC_UPDOWN_WINDOW_POS_TOP) { top = lpnmud->iPos + lpnmud->iDelta; } else { top = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_TOP, NULL, FALSE); } if (lppsn->hdr.idFrom == IDC_UPDOWN_WINDOW_SIZE_WIDTH || lppsn->hdr.idFrom == IDC_UPDOWN_WINDOW_SIZE_HEIGHT) { /* Automatically adjust screen buffer size when window size enlarges */ if (wwidth >= swidth) { SetDlgItemInt(hwndDlg, IDC_EDIT_SCREEN_BUFFER_WIDTH, wwidth, TRUE); swidth = wwidth; } if (wheight >= sheight) { SetDlgItemInt(hwndDlg, IDC_EDIT_SCREEN_BUFFER_HEIGHT, wheight, TRUE); sheight = wheight; } } swidth = min(max(swidth , 1), 0xFFFF); sheight = min(max(sheight, 1), 0xFFFF); if (lppsn->hdr.idFrom == IDC_UPDOWN_SCREEN_BUFFER_WIDTH || lppsn->hdr.idFrom == IDC_UPDOWN_SCREEN_BUFFER_HEIGHT) { /* Automatically adjust window size when screen buffer decreases */ if (wwidth > swidth) { SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_WIDTH, swidth, TRUE); wwidth = swidth; } if (wheight > sheight) { SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_HEIGHT, sheight, TRUE); wheight = sheight; } } pConInfo->ci.ScreenBufferSize.X = (SHORT)swidth; pConInfo->ci.ScreenBufferSize.Y = (SHORT)sheight; pConInfo->ci.ConsoleSize.X = (SHORT)wwidth; pConInfo->ci.ConsoleSize.Y = (SHORT)wheight; GuiInfo->WindowOrigin.x = left; GuiInfo->WindowOrigin.y = top; PropSheet_Changed(GetParent(hwndDlg), hwndDlg); } break; } case WM_COMMAND: { switch (LOWORD(wParam)) { case IDC_EDIT_SCREEN_BUFFER_WIDTH: case IDC_EDIT_SCREEN_BUFFER_HEIGHT: case IDC_EDIT_WINDOW_SIZE_WIDTH: case IDC_UPDOWN_WINDOW_SIZE_HEIGHT: case IDC_EDIT_WINDOW_POS_LEFT: case IDC_EDIT_WINDOW_POS_TOP: { if (HIWORD(wParam) == EN_KILLFOCUS) { DWORD wheight, wwidth; DWORD sheight, swidth; DWORD left, top; wwidth = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_WIDTH, NULL, FALSE); wheight = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_HEIGHT, NULL, FALSE); swidth = GetDlgItemInt(hwndDlg, IDC_EDIT_SCREEN_BUFFER_WIDTH, NULL, FALSE); sheight = GetDlgItemInt(hwndDlg, IDC_EDIT_SCREEN_BUFFER_HEIGHT, NULL, FALSE); left = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_LEFT, NULL, FALSE); top = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_TOP, NULL, FALSE); swidth = min(max(swidth , 1), 0xFFFF); sheight = min(max(sheight, 1), 0xFFFF); /* Automatically adjust window size when screen buffer decreases */ if (wwidth > swidth) { SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_WIDTH, swidth, TRUE); wwidth = swidth; } if (wheight > sheight) { SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_HEIGHT, sheight, TRUE); wheight = sheight; } pConInfo->ci.ScreenBufferSize.X = (SHORT)swidth; pConInfo->ci.ScreenBufferSize.Y = (SHORT)sheight; pConInfo->ci.ConsoleSize.X = (SHORT)wwidth; pConInfo->ci.ConsoleSize.Y = (SHORT)wheight; GuiInfo->WindowOrigin.x = left; GuiInfo->WindowOrigin.y = top; PropSheet_Changed(GetParent(hwndDlg), hwndDlg); } break; } case IDC_CHECK_SYSTEM_POS_WINDOW: { LONG res = SendMessage((HWND)lParam, BM_GETCHECK, 0, 0); if (res == BST_CHECKED) { ULONG left, top; left = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_LEFT, NULL, FALSE); top = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_TOP, NULL, FALSE); GuiInfo->WindowOrigin.x = left; GuiInfo->WindowOrigin.y = top; SendMessage((HWND)lParam, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_WINDOW_POS_LEFT), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_WINDOW_POS_TOP), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_POS_LEFT), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_POS_TOP), TRUE); } else if (res == BST_UNCHECKED) { GuiInfo->WindowOrigin.x = UINT_MAX; GuiInfo->WindowOrigin.y = UINT_MAX; SendMessage((HWND)lParam, BM_SETCHECK, (WPARAM)BST_CHECKED, 0); EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_WINDOW_POS_LEFT), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_WINDOW_POS_TOP), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_POS_LEFT), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_POS_TOP), FALSE); } } } } default: break; } return FALSE; }
/* ======================================================================================= ======================================================================================= */ bool shave_v17(HWND hDlg, int version, int line_count, int max_particles, FILE *fin, FILE *fout) { char line[2048]; int num_particles, num_to_keep, num_fields; int *keep_list, counter, written; unsigned int seed; memset(line, 0, sizeof(line)); if (!fgets(line, 32, fin)) { MessageBox(hDlg, "Error reading field count from list file.", "Error", MB_OK); return false; } num_fields = get_field_count(line); if (num_fields < 10) { MessageBox(hDlg, "Suspiciously low field count in list file. Not processing.", "Error", MB_OK); return false; } if (num_fields + 2 >= line_count) { MessageBox(hDlg, "More fields then lines in file. Not processing.", "Error", MB_OK); return false; } num_particles = line_count - (num_fields + 2); num_to_keep = max_particles; seed = GetDlgItemInt(hDlg, IDC_RAND_SEED, NULL, FALSE); if (seed == 0) { seed = 1; } keep_list = generate_keep_list(&num_to_keep, num_particles, seed); if (!keep_list) { MessageBox(hDlg, "Internal error allocating memory.", "Error", MB_OK); return false; } sprintf_s(line, sizeof(line), "%03d\nnum-fields|%d\n", version, num_fields); if (fputs(line, fout) < 0) { MessageBox(hDlg, "Error writing output file", "Error", MB_OK); return false; } // write out the fields for (int i = 0; i < num_fields; i++) { if (!fgets(line, sizeof(line), fin)) { if (ferror(fin)) { MessageBox(hDlg, "Error reading input file", "Error", MB_OK); return false; } } if (fputs(line, fout) < 0) { MessageBox(hDlg, "Error writing output file", "Error", MB_OK); return false; } } counter = 0; written = 0; while (!feof(fin)) { if (!fgets(line, sizeof(line), fin)) { if (ferror(fin)) { MessageBox(hDlg, "Error reading input file", "Error", MB_OK); return false; } } if (keep_list[counter++]) { if (fputs(line, fout) < 0) { MessageBox(hDlg, "Error writing output file", "Error", MB_OK); return false; } if (++written >= num_to_keep) { break; } } } delete [] keep_list; return true; }
static INT_PTR CALLBACK SettingsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { hwndSettingsDlg = hwndDlg; LCID locale = Langpack_GetDefaultLocale(); SendDlgItemMessage(hwndDlg, IDC_ICON_HEADER, STM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon("AutoShutdown_Header")); { HFONT hBoldFont; LOGFONT lf; if (GetObject((HFONT)SendDlgItemMessage(hwndDlg, IDC_TEXT_HEADER, WM_GETFONT, 0, 0), sizeof(lf), &lf)) { lf.lfWeight = FW_BOLD; hBoldFont = CreateFontIndirect(&lf); } else hBoldFont = NULL; SendDlgItemMessage(hwndDlg, IDC_TEXT_HEADER, WM_SETFONT, (WPARAM)hBoldFont, FALSE); } /* read-in watcher flags */ { WORD watcherType = db_get_w(NULL, "AutoShutdown", "WatcherFlags", SETTING_WATCHERFLAGS_DEFAULT); CheckRadioButton(hwndDlg, IDC_RADIO_STTIME, IDC_RADIO_STCOUNTDOWN, (watcherType&SDWTF_ST_TIME) ? IDC_RADIO_STTIME : IDC_RADIO_STCOUNTDOWN); CheckDlgButton(hwndDlg, IDC_CHECK_SPECIFICTIME, (watcherType&SDWTF_SPECIFICTIME) != 0 ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_CHECK_MESSAGE, (watcherType&SDWTF_MESSAGE) != 0 ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_CHECK_FILETRANSFER, (watcherType&SDWTF_FILETRANSFER) != 0 ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_CHECK_IDLE, (watcherType&SDWTF_IDLE) != 0 ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_CHECK_STATUS, (watcherType&SDWTF_STATUS) != 0 ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_CHECK_CPUUSAGE, (watcherType&SDWTF_CPUUSAGE) != 0 ? BST_CHECKED : BST_UNCHECKED); } /* read-in countdown val */ { SYSTEMTIME st; if (!TimeStampToSystemTime((time_t)db_get_dw(NULL, "AutoShutdown", "TimeStamp", SETTING_TIMESTAMP_DEFAULT), &st)) GetLocalTime(&st); DateTime_SetSystemtime(GetDlgItem(hwndDlg, IDC_TIME_TIMESTAMP), GDT_VALID, &st); DateTime_SetSystemtime(GetDlgItem(hwndDlg, IDC_DATE_TIMESTAMP), GDT_VALID, &st); SendMessage(hwndDlg, M_CHECK_DATETIME, 0, 0); } { DWORD setting = db_get_dw(NULL, "AutoShutdown", "Countdown", SETTING_COUNTDOWN_DEFAULT); if (setting < 1) setting = SETTING_COUNTDOWN_DEFAULT; SendDlgItemMessage(hwndDlg, IDC_SPIN_COUNTDOWN, UDM_SETRANGE, 0, MAKELPARAM(UD_MAXVAL, 1)); SendDlgItemMessage(hwndDlg, IDC_EDIT_COUNTDOWN, EM_SETLIMITTEXT, (WPARAM)10, 0); SendDlgItemMessage(hwndDlg, IDC_SPIN_COUNTDOWN, UDM_SETPOS, 0, MAKELPARAM(setting, 0)); SetDlgItemInt(hwndDlg, IDC_EDIT_COUNTDOWN, setting, FALSE); } { HWND hwndCombo = GetDlgItem(hwndDlg, IDC_COMBO_COUNTDOWNUNIT); DWORD lastUnit = db_get_dw(NULL, "AutoShutdown", "CountdownUnit", SETTING_COUNTDOWNUNIT_DEFAULT); SendMessage(hwndCombo, CB_SETLOCALE, (WPARAM)locale, 0); /* sort order */ SendMessage(hwndCombo, CB_INITSTORAGE, _countof(unitNames), _countof(unitNames) * 16); /* approx. */ for (int i = 0; i < _countof(unitNames); ++i) { int index = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)TranslateTS(unitNames[i])); if (index != LB_ERR) { SendMessage(hwndCombo, CB_SETITEMDATA, index, (LPARAM)unitValues[i]); if (i == 0 || unitValues[i] == lastUnit) SendMessage(hwndCombo, CB_SETCURSEL, index, 0); } } } { DBVARIANT dbv; if (!db_get_ts(NULL, "AutoShutdown", "Message", &dbv)) { SetDlgItemText(hwndDlg, IDC_EDIT_MESSAGE, dbv.ptszVal); mir_free(dbv.ptszVal); } } /* cpuusage threshold */ { BYTE setting = DBGetContactSettingRangedByte(NULL, "AutoShutdown", "CpuUsageThreshold", SETTING_CPUUSAGETHRESHOLD_DEFAULT, 1, 100); SendDlgItemMessage(hwndDlg, IDC_SPIN_CPUUSAGE, UDM_SETRANGE, 0, MAKELPARAM(100, 1)); SendDlgItemMessage(hwndDlg, IDC_EDIT_CPUUSAGE, EM_SETLIMITTEXT, (WPARAM)3, 0); SendDlgItemMessage(hwndDlg, IDC_SPIN_CPUUSAGE, UDM_SETPOS, 0, MAKELPARAM(setting, 0)); SetDlgItemInt(hwndDlg, IDC_EDIT_CPUUSAGE, setting, FALSE); } /* shutdown types */ { HWND hwndCombo = GetDlgItem(hwndDlg, IDC_COMBO_SHUTDOWNTYPE); BYTE lastShutdownType = db_get_b(NULL, "AutoShutdown", "ShutdownType", SETTING_SHUTDOWNTYPE_DEFAULT); SendMessage(hwndCombo, CB_SETLOCALE, (WPARAM)locale, 0); /* sort order */ SendMessage(hwndCombo, CB_SETEXTENDEDUI, TRUE, 0); SendMessage(hwndCombo, CB_INITSTORAGE, SDSDT_MAX, SDSDT_MAX * 32); for (BYTE shutdownType = 1; shutdownType <= SDSDT_MAX; ++shutdownType) if (ServiceIsTypeEnabled(shutdownType, 0)) { TCHAR *pszText = (TCHAR*)ServiceGetTypeDescription(shutdownType, GSTDF_TCHAR); /* never fails */ int index = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)pszText); if (index != LB_ERR) { SendMessage(hwndCombo, CB_SETITEMDATA, index, (LPARAM)shutdownType); if (shutdownType == 1 || shutdownType == lastShutdownType) SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM)index, 0); } } SendMessage(hwndDlg, M_UPDATE_SHUTDOWNDESC, 0, (LPARAM)hwndCombo); } /* check if proto is installed that supports instant messages and check if a message dialog plugin is installed */ if (!AnyProtoHasCaps(PF1_IMRECV) || !ServiceExists(MS_MSG_SENDMESSAGE)) { /* no srmessage present? */ CheckDlgButton(hwndDlg, IDC_CHECK_MESSAGE, BST_UNCHECKED); EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_MESSAGE), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_MESSAGE), FALSE); } /* check if proto is installed that supports file transfers and check if a file transfer dialog is available */ if (!AnyProtoHasCaps(PF1_FILESEND) && !AnyProtoHasCaps(PF1_FILERECV)) { /* no srfile present? */ CheckDlgButton(hwndDlg, IDC_CHECK_FILETRANSFER, BST_UNCHECKED); EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_FILETRANSFER), FALSE); } /* check if cpu usage can be detected */ if (!PollCpuUsage(DisplayCpuUsageProc, (LPARAM)GetDlgItem(hwndDlg, IDC_TEXT_CURRENTCPU), 1800)) { CheckDlgButton(hwndDlg, IDC_CHECK_CPUUSAGE, BST_UNCHECKED); EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_CPUUSAGE), FALSE); } } SendMessage(hwndDlg, M_ENABLE_SUBCTLS, 0, 0); Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, "AutoShutdown", "SettingsDlg_"); return TRUE; /* default focus */ case WM_DESTROY: Utils_SaveWindowPosition(hwndDlg, NULL, "AutoShutdown", "SettingsDlg_"); { HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_TEXT_HEADER, WM_GETFONT, 0, 0); SendDlgItemMessage(hwndDlg, IDC_TEXT_HEADER, WM_SETFONT, 0, FALSE); /* no return value */ if (hFont != NULL) DeleteObject(hFont); hwndSettingsDlg = NULL; } return TRUE; case WM_CTLCOLORSTATIC: switch (GetDlgCtrlID((HWND)lParam)) { case IDC_ICON_HEADER: SetBkMode((HDC)wParam, TRANSPARENT); case IDC_RECT_HEADER: /* need to set COLOR_WINDOW manually for Win9x */ SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); case IDC_TEXT_HEADER: case IDC_TEXT_HEADERDESC: SetBkMode((HDC)wParam, TRANSPARENT); return (INT_PTR)GetStockObject(NULL_BRUSH); } break; case M_ENABLE_SUBCTLS: { BOOL checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK_MESSAGE) != 0; EnableDlgItem(hwndDlg, IDC_EDIT_MESSAGE, checked); checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK_SPECIFICTIME) != 0; EnableDlgItem(hwndDlg, IDC_RADIO_STTIME, checked); EnableDlgItem(hwndDlg, IDC_RADIO_STCOUNTDOWN, checked); checked = (IsDlgButtonChecked(hwndDlg, IDC_CHECK_SPECIFICTIME) && IsDlgButtonChecked(hwndDlg, IDC_RADIO_STTIME)); EnableDlgItem(hwndDlg, IDC_TIME_TIMESTAMP, checked); EnableDlgItem(hwndDlg, IDC_DATE_TIMESTAMP, checked); checked = (IsDlgButtonChecked(hwndDlg, IDC_CHECK_SPECIFICTIME) && IsDlgButtonChecked(hwndDlg, IDC_RADIO_STCOUNTDOWN)); EnableDlgItem(hwndDlg, IDC_EDIT_COUNTDOWN, checked); EnableDlgItem(hwndDlg, IDC_SPIN_COUNTDOWN, checked); EnableDlgItem(hwndDlg, IDC_COMBO_COUNTDOWNUNIT, checked); checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK_IDLE) != 0; EnableDlgItem(hwndDlg, IDC_URL_IDLE, checked); checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK_CPUUSAGE) != 0; EnableDlgItem(hwndDlg, IDC_EDIT_CPUUSAGE, checked); EnableDlgItem(hwndDlg, IDC_SPIN_CPUUSAGE, checked); EnableDlgItem(hwndDlg, IDC_TEXT_PERCENT, checked); EnableDlgItem(hwndDlg, IDC_TEXT_CURRENTCPU, checked); checked = (IsDlgButtonChecked(hwndDlg, IDC_CHECK_SPECIFICTIME) || IsDlgButtonChecked(hwndDlg, IDC_CHECK_MESSAGE) || IsDlgButtonChecked(hwndDlg, IDC_CHECK_IDLE) || IsDlgButtonChecked(hwndDlg, IDC_CHECK_STATUS) || IsDlgButtonChecked(hwndDlg, IDC_CHECK_FILETRANSFER) || IsDlgButtonChecked(hwndDlg, IDC_CHECK_CPUUSAGE)); EnableDlgItem(hwndDlg, IDOK, checked); } return TRUE; case M_UPDATE_SHUTDOWNDESC: /* lParam=(LPARAM)(HWND)hwndCombo */ { BYTE shutdownType = (BYTE)SendMessage((HWND)lParam, CB_GETITEMDATA, SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0), 0); SetDlgItemText(hwndDlg, IDC_TEXT_SHUTDOWNTYPE, (TCHAR*)ServiceGetTypeDescription(shutdownType, GSTDF_LONGDESC | GSTDF_TCHAR)); } return TRUE; case WM_TIMECHANGE: /* system time changed */ SendMessage(hwndDlg, M_CHECK_DATETIME, 0, 0); return TRUE; case M_CHECK_DATETIME: { SYSTEMTIME st, stBuf; time_t timestamp; DateTime_GetSystemtime(GetDlgItem(hwndDlg, IDC_DATE_TIMESTAMP), &stBuf); DateTime_GetSystemtime(GetDlgItem(hwndDlg, IDC_TIME_TIMESTAMP), &st); st.wDay = stBuf.wDay; st.wDayOfWeek = stBuf.wDayOfWeek; st.wMonth = stBuf.wMonth; st.wYear = stBuf.wYear; GetLocalTime(&stBuf); if (SystemTimeToTimeStamp(&st, ×tamp)) { /* set to current date if earlier */ if (timestamp < time(NULL)) { st.wDay = stBuf.wDay; st.wDayOfWeek = stBuf.wDayOfWeek; st.wMonth = stBuf.wMonth; st.wYear = stBuf.wYear; if (SystemTimeToTimeStamp(&st, ×tamp)) { /* step one day up if still earlier */ if (timestamp < time(NULL)) { timestamp += 24 * 60 * 60; TimeStampToSystemTime(timestamp, &st); } } } } DateTime_SetRange(GetDlgItem(hwndDlg, IDC_DATE_TIMESTAMP), GDTR_MIN, &stBuf); DateTime_SetRange(GetDlgItem(hwndDlg, IDC_TIME_TIMESTAMP), GDTR_MIN, &stBuf); DateTime_SetSystemtime(GetDlgItem(hwndDlg, IDC_DATE_TIMESTAMP), GDT_VALID, &st); DateTime_SetSystemtime(GetDlgItem(hwndDlg, IDC_TIME_TIMESTAMP), GDT_VALID, &st); } return TRUE; case WM_NOTIFY: switch (((NMHDR*)lParam)->idFrom) { case IDC_TIME_TIMESTAMP: case IDC_DATE_TIMESTAMP: switch (((NMHDR*)lParam)->code) { case DTN_CLOSEUP: case NM_KILLFOCUS: PostMessage(hwndDlg, M_CHECK_DATETIME, 0, 0); return TRUE; } } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_CHECK_MESSAGE: case IDC_CHECK_FILETRANSFER: case IDC_CHECK_IDLE: case IDC_CHECK_CPUUSAGE: case IDC_CHECK_STATUS: case IDC_CHECK_SPECIFICTIME: case IDC_RADIO_STTIME: case IDC_RADIO_STCOUNTDOWN: SendMessage(hwndDlg, M_ENABLE_SUBCTLS, 0, 0); return TRUE; case IDC_EDIT_COUNTDOWN: if (HIWORD(wParam) == EN_KILLFOCUS) { if ((int)GetDlgItemInt(hwndDlg, IDC_EDIT_COUNTDOWN, NULL, TRUE) < 1) { SendDlgItemMessage(hwndDlg, IDC_SPIN_COUNTDOWN, UDM_SETPOS, 0, MAKELPARAM(1, 0)); SetDlgItemInt(hwndDlg, IDC_EDIT_COUNTDOWN, 1, FALSE); } return TRUE; } break; case IDC_EDIT_CPUUSAGE: if (HIWORD(wParam) == EN_KILLFOCUS) { WORD val = (WORD)GetDlgItemInt(hwndDlg, IDC_EDIT_CPUUSAGE, NULL, FALSE); if (val < 1) val = 1; else if (val>100) val = 100; SendDlgItemMessage(hwndDlg, IDC_SPIN_CPUUSAGE, UDM_SETPOS, 0, MAKELPARAM(val, 0)); SetDlgItemInt(hwndDlg, IDC_EDIT_CPUUSAGE, val, FALSE); return TRUE; } break; case IDC_URL_IDLE: { OPENOPTIONSDIALOG ood; ood.cbSize = sizeof(ood); ood.pszGroup = "Status"; /* autotranslated */ ood.pszPage = "Idle"; /* autotranslated */ ood.pszTab = NULL; Options_Open(&ood); return TRUE; } case IDC_COMBO_SHUTDOWNTYPE: if (HIWORD(wParam) == CBN_SELCHANGE) SendMessage(hwndDlg, M_UPDATE_SHUTDOWNDESC, 0, lParam); return TRUE; case IDOK: /* save settings and start watcher */ ShowWindow(hwndDlg, SW_HIDE); /* message text */ { HWND hwndEdit = GetDlgItem(hwndDlg, IDC_EDIT_MESSAGE); int len = GetWindowTextLength(hwndEdit) + 1; TCHAR *pszText = (TCHAR*)mir_alloc(len*sizeof(TCHAR)); if (pszText != NULL && GetWindowText(hwndEdit, pszText, len + 1)) { TrimString(pszText); db_set_ts(NULL, "AutoShutdown", "Message", pszText); } mir_free(pszText); /* does NULL check */ } /* timestamp */ { SYSTEMTIME st; time_t timestamp; DateTime_GetSystemtime(GetDlgItem(hwndDlg, IDC_TIME_TIMESTAMP), &st); /* time gets synchronized */ if (!SystemTimeToTimeStamp(&st, ×tamp)) timestamp = time(NULL); db_set_dw(NULL, "AutoShutdown", "TimeStamp", (DWORD)timestamp); } /* shutdown type */ { int index = SendDlgItemMessage(hwndDlg, IDC_COMBO_SHUTDOWNTYPE, CB_GETCURSEL, 0, 0); if (index != LB_ERR) db_set_b(NULL, "AutoShutdown", "ShutdownType", (BYTE)SendDlgItemMessage(hwndDlg, IDC_COMBO_SHUTDOWNTYPE, CB_GETITEMDATA, (WPARAM)index, 0)); index = SendDlgItemMessage(hwndDlg, IDC_COMBO_COUNTDOWNUNIT, CB_GETCURSEL, 0, 0); if (index != LB_ERR) db_set_dw(NULL, "AutoShutdown", "CountdownUnit", (DWORD)SendDlgItemMessage(hwndDlg, IDC_COMBO_COUNTDOWNUNIT, CB_GETITEMDATA, (WPARAM)index, 0)); db_set_dw(NULL, "AutoShutdown", "Countdown", (DWORD)GetDlgItemInt(hwndDlg, IDC_EDIT_COUNTDOWN, NULL, FALSE)); db_set_b(NULL, "AutoShutdown", "CpuUsageThreshold", (BYTE)GetDlgItemInt(hwndDlg, IDC_EDIT_CPUUSAGE, NULL, FALSE)); } /* watcher type */ { WORD watcherType = (WORD)(IsDlgButtonChecked(hwndDlg, IDC_RADIO_STTIME) ? SDWTF_ST_TIME : SDWTF_ST_COUNTDOWN); if (IsDlgButtonChecked(hwndDlg, IDC_CHECK_SPECIFICTIME)) watcherType |= SDWTF_SPECIFICTIME; if (IsDlgButtonChecked(hwndDlg, IDC_CHECK_MESSAGE)) watcherType |= SDWTF_MESSAGE; if (IsDlgButtonChecked(hwndDlg, IDC_CHECK_FILETRANSFER)) watcherType |= SDWTF_FILETRANSFER; if (IsDlgButtonChecked(hwndDlg, IDC_CHECK_IDLE)) watcherType |= SDWTF_IDLE; if (IsDlgButtonChecked(hwndDlg, IDC_CHECK_STATUS)) watcherType |= SDWTF_STATUS; if (IsDlgButtonChecked(hwndDlg, IDC_CHECK_CPUUSAGE)) watcherType |= SDWTF_CPUUSAGE; db_set_w(NULL, "AutoShutdown", "WatcherFlags", watcherType); ServiceStartWatcher(0, watcherType); } DestroyWindow(hwndDlg); return TRUE; // fall through case IDCANCEL: /* WM_CLOSE */ DestroyWindow(hwndDlg); SetShutdownToolbarButton(false); SetShutdownMenuItem(false); return TRUE; } break; } return FALSE; }
INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: { opt_clui_changed = 0; TranslateDialogDefault(hwndDlg); CheckDlgButton(hwndDlg, IDC_BRINGTOFRONT, cfg::getByte("CList", "BringToFront", SETTING_BRINGTOFRONT_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_ALWAYSHIDEONTASKBAR, cfg::getByte("CList", "AlwaysHideOnTB", 1) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_ONTOP, cfg::getByte("CList", "OnTop", SETTING_ONTOP_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_SHOWMAINMENU, cfg::getByte("CLUI", "ShowMainMenu", SETTING_SHOWMAINMENU_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_CLIENTDRAG, cfg::getByte("CLUI", "ClientAreaDrag", SETTING_CLIENTDRAG_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_FADEINOUT, cfg::dat.fadeinout ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_AUTOSIZE, cfg::dat.autosize ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_DROPSHADOW, cfg::getByte("CList", "WindowShadow", 0) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_ONDESKTOP, cfg::getByte("CList", "OnDesktop", 0) ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage(hwndDlg, IDC_BORDERSTYLE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Title bar")); SendDlgItemMessage(hwndDlg, IDC_BORDERSTYLE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Tool Window")); SendDlgItemMessage(hwndDlg, IDC_BORDERSTYLE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Thin border")); SendDlgItemMessage(hwndDlg, IDC_BORDERSTYLE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("No border")); SendDlgItemMessage(hwndDlg, IDC_BORDERSTYLE, CB_SETCURSEL, cfg::getByte("CLUI", "WindowStyle", SETTING_WINDOWSTYLE_TOOLWINDOW), 0); SendDlgItemMessage(hwndDlg, IDC_MAXSIZESPIN, UDM_SETRANGE, 0, MAKELONG(100, 0)); SendDlgItemMessage(hwndDlg, IDC_MAXSIZESPIN, UDM_SETPOS, 0, cfg::getByte("CLUI", "MaxSizeHeight", 75)); SendDlgItemMessage(hwndDlg, IDC_CLIPBORDERSPIN, UDM_SETRANGE, 0, MAKELONG(10, 0)); SendDlgItemMessage(hwndDlg, IDC_CLIPBORDERSPIN, UDM_SETPOS, 0, cfg::dat.bClipBorder); SendDlgItemMessage(hwndDlg, IDC_CLEFTSPIN, UDM_SETRANGE, 0, MAKELONG(255, 0)); SendDlgItemMessage(hwndDlg, IDC_CRIGHTSPIN, UDM_SETRANGE, 0, MAKELONG(255, 0)); SendDlgItemMessage(hwndDlg, IDC_CTOPSPIN, UDM_SETRANGE, 0, MAKELONG(255, 0)); SendDlgItemMessage(hwndDlg, IDC_CBOTTOMSPIN, UDM_SETRANGE, 0, MAKELONG(255, 0)); SendDlgItemMessage(hwndDlg, IDC_CLEFTSPIN, UDM_SETPOS, 0, cfg::dat.bCLeft - (cfg::dat.dwFlags & CLUI_FRAME_CLISTSUNKEN ? 3 : 0)); SendDlgItemMessage(hwndDlg, IDC_CRIGHTSPIN, UDM_SETPOS, 0, cfg::dat.bCRight - (cfg::dat.dwFlags & CLUI_FRAME_CLISTSUNKEN ? 3 : 0)); SendDlgItemMessage(hwndDlg, IDC_CTOPSPIN, UDM_SETPOS, 0, cfg::dat.bCTop); SendDlgItemMessage(hwndDlg, IDC_CBOTTOMSPIN, UDM_SETPOS, 0, cfg::dat.bCBottom); CheckDlgButton(hwndDlg, IDC_AUTOSIZEUPWARD, cfg::getByte("CLUI", "AutoSizeUpward", 0) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_AUTOHIDE, cfg::getByte("CList", "AutoHide", SETTING_AUTOHIDE_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage(hwndDlg, IDC_HIDETIMESPIN, UDM_SETRANGE, 0, MAKELONG(900, 1)); SendDlgItemMessage(hwndDlg, IDC_HIDETIMESPIN, UDM_SETPOS, 0, MAKELONG(cfg::getWord("CList", "HideTime", SETTING_HIDETIME_DEFAULT), 0)); Utils::enableDlgControl(hwndDlg, IDC_HIDETIME, IsDlgButtonChecked(hwndDlg, IDC_AUTOHIDE)); Utils::enableDlgControl(hwndDlg, IDC_HIDETIMESPIN, IsDlgButtonChecked(hwndDlg, IDC_AUTOHIDE)); Utils::enableDlgControl(hwndDlg, IDC_STATIC01, IsDlgButtonChecked(hwndDlg, IDC_AUTOHIDE)); if (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_AUTOSIZE)) { Utils::enableDlgControl(hwndDlg, IDC_STATIC21, FALSE); Utils::enableDlgControl(hwndDlg, IDC_STATIC22, FALSE); Utils::enableDlgControl(hwndDlg, IDC_MAXSIZEHEIGHT, FALSE); Utils::enableDlgControl(hwndDlg, IDC_MAXSIZESPIN, FALSE); Utils::enableDlgControl(hwndDlg, IDC_AUTOSIZEUPWARD, FALSE); } { DBVARIANT dbv; if (!cfg::getTString(NULL, "CList", "TitleText", &dbv)) { SetDlgItemText(hwndDlg, IDC_TITLETEXT, dbv.ptszVal); db_free(&dbv); } else SetDlgItemTextA(hwndDlg, IDC_TITLETEXT, MIRANDANAME); } CheckDlgButton(hwndDlg, IDC_TRANSPARENT, cfg::dat.isTransparent ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_FULLTRANSPARENT, cfg::dat.bFullTransparent ? BST_CHECKED : BST_UNCHECKED); if (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_TRANSPARENT)) { Utils::enableDlgControl(hwndDlg, IDC_STATIC11, FALSE); Utils::enableDlgControl(hwndDlg, IDC_STATIC12, FALSE); Utils::enableDlgControl(hwndDlg, IDC_TRANSACTIVE, FALSE); Utils::enableDlgControl(hwndDlg, IDC_TRANSINACTIVE, FALSE); Utils::enableDlgControl(hwndDlg, IDC_ACTIVEPERC, FALSE); Utils::enableDlgControl(hwndDlg, IDC_INACTIVEPERC, FALSE); } SendDlgItemMessage(hwndDlg, IDC_TRANSACTIVE, TBM_SETRANGE, FALSE, MAKELONG(1, 255)); SendDlgItemMessage(hwndDlg, IDC_TRANSINACTIVE, TBM_SETRANGE, FALSE, MAKELONG(1, 255)); SendDlgItemMessage(hwndDlg, IDC_TRANSACTIVE, TBM_SETPOS, TRUE, cfg::dat.alpha); SendDlgItemMessage(hwndDlg, IDC_TRANSINACTIVE, TBM_SETPOS, TRUE, cfg::dat.autoalpha); SendMessage(hwndDlg, WM_HSCROLL, 0x12345678, 0); CheckDlgButton(hwndDlg, IDC_ROUNDEDBORDER, cfg::dat.dwFlags & CLUI_FRAME_ROUNDEDFRAME ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage(hwndDlg, IDC_FRAMEGAPSPIN, UDM_SETRANGE, 0, MAKELONG(10, 0)); SendDlgItemMessage(hwndDlg, IDC_FRAMEGAPSPIN, UDM_SETPOS, 0, (LPARAM)cfg::dat.gapBetweenFrames); } return TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDC_AUTOHIDE) { Utils::enableDlgControl(hwndDlg, IDC_HIDETIME, IsDlgButtonChecked(hwndDlg, IDC_AUTOHIDE)); Utils::enableDlgControl(hwndDlg, IDC_HIDETIMESPIN, IsDlgButtonChecked(hwndDlg, IDC_AUTOHIDE)); Utils::enableDlgControl(hwndDlg, IDC_STATIC01, IsDlgButtonChecked(hwndDlg, IDC_AUTOHIDE)); } else if (LOWORD(wParam) == IDC_TRANSPARENT) { Utils::enableDlgControl(hwndDlg, IDC_STATIC11, IsDlgButtonChecked(hwndDlg, IDC_TRANSPARENT)); Utils::enableDlgControl(hwndDlg, IDC_STATIC12, IsDlgButtonChecked(hwndDlg, IDC_TRANSPARENT)); Utils::enableDlgControl(hwndDlg, IDC_TRANSACTIVE, IsDlgButtonChecked(hwndDlg, IDC_TRANSPARENT)); Utils::enableDlgControl(hwndDlg, IDC_TRANSINACTIVE, IsDlgButtonChecked(hwndDlg, IDC_TRANSPARENT)); Utils::enableDlgControl(hwndDlg, IDC_ACTIVEPERC, IsDlgButtonChecked(hwndDlg, IDC_TRANSPARENT)); Utils::enableDlgControl(hwndDlg, IDC_INACTIVEPERC, IsDlgButtonChecked(hwndDlg, IDC_TRANSPARENT)); } else if (LOWORD(wParam) == IDC_AUTOSIZE) { Utils::enableDlgControl(hwndDlg, IDC_STATIC21, IsDlgButtonChecked(hwndDlg, IDC_AUTOSIZE)); Utils::enableDlgControl(hwndDlg, IDC_STATIC22, IsDlgButtonChecked(hwndDlg, IDC_AUTOSIZE)); Utils::enableDlgControl(hwndDlg, IDC_MAXSIZEHEIGHT, IsDlgButtonChecked(hwndDlg, IDC_AUTOSIZE)); Utils::enableDlgControl(hwndDlg, IDC_MAXSIZESPIN, IsDlgButtonChecked(hwndDlg, IDC_AUTOSIZE)); Utils::enableDlgControl(hwndDlg, IDC_AUTOSIZEUPWARD, IsDlgButtonChecked(hwndDlg, IDC_AUTOSIZE)); } if ((LOWORD(wParam) == IDC_FRAMEGAP || LOWORD(wParam) == IDC_HIDETIME || LOWORD(wParam) == IDC_CLIPBORDER || LOWORD(wParam) == IDC_TITLETEXT || LOWORD(wParam) == IDC_MAXSIZEHEIGHT || LOWORD(wParam) == IDC_CLEFT || LOWORD(wParam) == IDC_CRIGHT || LOWORD(wParam) == IDC_CTOP || LOWORD(wParam) == IDC_CBOTTOM) && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0; if (LOWORD(wParam) == IDC_BORDERSTYLE && (HIWORD(wParam) != CBN_SELCHANGE || (HWND)lParam != GetFocus())) return 0; SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); opt_clui_changed = 1; break; case WM_HSCROLL: { char str[10]; mir_snprintf(str, SIZEOF(str), "%d%%", 100 * SendDlgItemMessage(hwndDlg, IDC_TRANSINACTIVE, TBM_GETPOS, 0, 0) / 255); SetDlgItemTextA(hwndDlg, IDC_INACTIVEPERC, str); mir_snprintf(str, SIZEOF(str), "%d%%", 100 * SendDlgItemMessage(hwndDlg, IDC_TRANSACTIVE, TBM_GETPOS, 0, 0) / 255); SetDlgItemTextA(hwndDlg, IDC_ACTIVEPERC, str); } if (wParam != 0x12345678) { SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); opt_clui_changed = 1; } break; case WM_NOTIFY: if (((LPNMHDR)lParam)->code == PSN_APPLY) { BOOL translated; BYTE oldFading; BYTE windowStyle = (BYTE)SendDlgItemMessage(hwndDlg, IDC_BORDERSTYLE, CB_GETCURSEL, 0, 0); if (!opt_clui_changed) return TRUE; cfg::writeByte("CLUI", "FadeInOut", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_FADEINOUT)); cfg::dat.fadeinout = IsDlgButtonChecked(hwndDlg, IDC_FADEINOUT) ? 1 : 0; oldFading = cfg::dat.fadeinout; cfg::dat.fadeinout = FALSE; cfg::writeByte("CLUI", "WindowStyle", windowStyle); cfg::dat.gapBetweenFrames = GetDlgItemInt(hwndDlg, IDC_FRAMEGAP, &translated, FALSE); cfg::writeDword("CLUIFrames", "GapBetweenFrames", cfg::dat.gapBetweenFrames); cfg::writeByte("CList", "OnTop", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ONTOP)); SetWindowPos(pcli->hwndContactList, IsDlgButtonChecked(hwndDlg, IDC_ONTOP) ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); cfg::dat.bCLeft = (BYTE)SendDlgItemMessage(hwndDlg, IDC_CLEFTSPIN, UDM_GETPOS, 0, 0); cfg::dat.bCRight = (BYTE)SendDlgItemMessage(hwndDlg, IDC_CRIGHTSPIN, UDM_GETPOS, 0, 0); cfg::dat.bCTop = (BYTE)SendDlgItemMessage(hwndDlg, IDC_CTOPSPIN, UDM_GETPOS, 0, 0); cfg::dat.bCBottom = (BYTE)SendDlgItemMessage(hwndDlg, IDC_CBOTTOMSPIN, UDM_GETPOS, 0, 0); cfg::writeDword("CLUI", "clmargins", MAKELONG(MAKEWORD(cfg::dat.bCLeft, cfg::dat.bCRight), MAKEWORD(cfg::dat.bCTop, cfg::dat.bCBottom))); SendMessage(pcli->hwndContactList, WM_SIZE, 0, 0); cfg::writeByte("CList", "BringToFront", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_BRINGTOFRONT)); cfg::writeByte("CList", "AlwaysHideOnTB", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ALWAYSHIDEONTASKBAR)); if (windowStyle != SETTING_WINDOWSTYLE_DEFAULT) { LONG style; // Window must be hidden to dynamically remove the taskbar button. // See http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/shell_int/shell_int_programming/taskbar.asp WINDOWPLACEMENT p; p.length = sizeof(p); GetWindowPlacement(pcli->hwndContactList, &p); ShowWindow(pcli->hwndContactList, SW_HIDE); style = GetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE); style |= WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE; style &= ~WS_EX_APPWINDOW; SetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE, style); SetWindowPlacement(pcli->hwndContactList, &p); ShowWindow(pcli->hwndContactList, SW_SHOW); } else { LONG style; style = GetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE); style &= ~(WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE); if (cfg::getByte("CList", "AlwaysHideOnTB", 1)) style &= ~WS_EX_APPWINDOW; else { style |= WS_EX_APPWINDOW; AddToTaskBar(pcli->hwndContactList); } SetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE, style); } cfg::dat.bClipBorder = (BYTE)GetDlgItemInt(hwndDlg, IDC_CLIPBORDER, &translated, FALSE); cfg::writeDword("CLUI", "Frameflags", cfg::dat.dwFlags); cfg::writeByte("CLUI", "clipborder", cfg::dat.bClipBorder); cfg::writeByte("CLUI", "ShowMainMenu", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SHOWMAINMENU)); cfg::writeByte("CLUI", "ClientAreaDrag", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CLIENTDRAG)); ApplyCLUIBorderStyle(); if (BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_SHOWMAINMENU)) SetMenu(pcli->hwndContactList, NULL); else SetMenu(pcli->hwndContactList, pcli->hMenuMain); { TCHAR title[256]; GetDlgItemText(hwndDlg, IDC_TITLETEXT, title, SIZEOF(title)); cfg::writeTString(NULL, "CList", "TitleText", title); SetWindowText(pcli->hwndContactList, title); } cfg::dat.dwFlags = IsDlgButtonChecked(hwndDlg, IDC_ROUNDEDBORDER) ? cfg::dat.dwFlags | CLUI_FRAME_ROUNDEDFRAME : cfg::dat.dwFlags & ~CLUI_FRAME_ROUNDEDFRAME; cfg::writeByte("CLUI", "AutoSize", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOSIZE)); if ((cfg::dat.autosize = IsDlgButtonChecked(hwndDlg, IDC_AUTOSIZE) ? 1 : 0)) { SendMessage(pcli->hwndContactList, WM_SIZE, 0, 0); SendMessage(pcli->hwndContactTree, WM_SIZE, 0, 0); } cfg::writeByte("CLUI", "MaxSizeHeight", (BYTE)GetDlgItemInt(hwndDlg, IDC_MAXSIZEHEIGHT, NULL, FALSE)); cfg::writeByte("CLUI", "AutoSizeUpward", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOSIZEUPWARD)); cfg::writeByte("CList", "AutoHide", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTOHIDE)); cfg::writeWord("CList", "HideTime", (WORD)SendDlgItemMessage(hwndDlg, IDC_HIDETIMESPIN, UDM_GETPOS, 0, 0)); cfg::writeByte("CList", "Transparent", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_TRANSPARENT)); cfg::dat.isTransparent = IsDlgButtonChecked(hwndDlg, IDC_TRANSPARENT) ? 1 : 0; cfg::writeByte("CList", "Alpha", (BYTE)SendDlgItemMessage(hwndDlg, IDC_TRANSACTIVE, TBM_GETPOS, 0, 0)); cfg::dat.alpha = (BYTE)SendDlgItemMessage(hwndDlg, IDC_TRANSACTIVE, TBM_GETPOS, 0, 0); cfg::writeByte("CList", "AutoAlpha", (BYTE)SendDlgItemMessage(hwndDlg, IDC_TRANSINACTIVE, TBM_GETPOS, 0, 0)); cfg::dat.autoalpha = (BYTE)SendDlgItemMessage(hwndDlg, IDC_TRANSINACTIVE, TBM_GETPOS, 0, 0); cfg::writeByte("CList", "WindowShadow", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DROPSHADOW)); cfg::writeByte("CList", "OnDesktop", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ONDESKTOP)); cfg::writeDword("CLUI", "Frameflags", cfg::dat.dwFlags); cfg::dat.bFullTransparent = IsDlgButtonChecked(hwndDlg, IDC_FULLTRANSPARENT) ? 1 : 0; cfg::writeByte("CLUI", "fulltransparent", (BYTE)cfg::dat.bFullTransparent); if (cfg::dat.bLayeredHack) SetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE, GetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE) | WS_EX_LAYERED); if (g_CLUISkinnedBkColorRGB) cfg::dat.colorkey = g_CLUISkinnedBkColorRGB; else if (cfg::dat.bClipBorder == 0 && !(cfg::dat.dwFlags & CLUI_FRAME_ROUNDEDFRAME)) cfg::dat.colorkey = cfg::getDword("CLC", "BkColour", CLCDEFAULT_BKCOLOUR); else { SendMessage(pcli->hwndContactList, WM_SIZE, 0, 0); cfg::dat.colorkey = RGB(255, 0, 255); } if (cfg::dat.isTransparent || cfg::dat.bFullTransparent) { SetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE, GetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE) & ~WS_EX_LAYERED); SetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE, GetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE) | WS_EX_LAYERED); SetLayeredWindowAttributes(pcli->hwndContactList, 0, 255, LWA_ALPHA | LWA_COLORKEY); SetLayeredWindowAttributes(pcli->hwndContactList, (COLORREF)(cfg::dat.bFullTransparent ? cfg::dat.colorkey : 0), (BYTE)(cfg::dat.isTransparent ? cfg::dat.autoalpha : 255), (DWORD)((cfg::dat.isTransparent ? LWA_ALPHA : 0L) | (cfg::dat.bFullTransparent ? LWA_COLORKEY : 0L))); } else { SetLayeredWindowAttributes(pcli->hwndContactList, RGB(0, 0, 0), (BYTE)255, LWA_ALPHA); if (!cfg::dat.bLayeredHack) SetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE, GetWindowLongPtr(pcli->hwndContactList, GWL_EXSTYLE) & ~WS_EX_LAYERED); } ConfigureCLUIGeometry(1); ShowWindow(pcli->hwndContactList, SW_SHOW); SendMessage(pcli->hwndContactList, WM_SIZE, 0, 0); SetWindowPos(pcli->hwndContactList, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); RedrawWindow(pcli->hwndContactList, NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW); cfg::dat.fadeinout = oldFading; opt_clui_changed = 0; pcli->pfnClcOptionsChanged(); pcli->pfnClcBroadcast(CLM_AUTOREBUILD, 0, 0); return TRUE; } break; } return FALSE; }
BOOL CALLBACK vncPropertiesPoll::DialogProcPoll(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { // We use the dialog-box's USERDATA to store a _this pointer // This is set only once WM_INITDIALOG has been recieved, though! vncPropertiesPoll *_this = helper::SafeGetWindowUserData<vncPropertiesPoll>(hwnd); switch (uMsg) { case WM_INITDIALOG: { // Retrieve the Dialog box parameter and use it as a pointer // to the calling vncPropertiesPoll object helper::SafeSetWindowUserData(hwnd, lParam); _this = (vncPropertiesPoll *) lParam; _this->m_dlgvisible = TRUE; if (_this->m_fUseRegistry) { _this->Load(_this->m_usersettings); // Set the dialog box's title to indicate which Properties we're editting if (_this->m_usersettings) { SetWindowText(hwnd, sz_ID_CURRENT_USER_PROP); } else { SetWindowText(hwnd, sz_ID_DEFAULT_SYST_PROP); } } else { //LoadFromIniFile(); } // Modif sf@2002 SetDlgItemInt(hwnd, IDC_MAXCPU, _this->m_server->MaxCpu(), false); HWND hTurboMode = GetDlgItem(hwnd, IDC_TURBOMODE); SendMessage(hTurboMode, BM_SETCHECK, _this->m_server->TurboMode(), 0); // Set the polling options HWND hDriver = GetDlgItem(hwnd, IDC_DRIVER); SendMessage(hDriver, BM_SETCHECK, _this->m_server->Driver(),0); HWND hHook = GetDlgItem(hwnd, IDC_HOOK); SendMessage(hHook, BM_SETCHECK, _this->m_server->Hook(), 0); HWND hPollFullScreen = GetDlgItem(hwnd, IDC_POLL_FULLSCREEN); SendMessage(hPollFullScreen, BM_SETCHECK, _this->m_server->PollFullScreen(), 0); HWND hPollForeground = GetDlgItem(hwnd, IDC_POLL_FOREGROUND); SendMessage(hPollForeground, BM_SETCHECK, _this->m_server->PollForeground(), 0); HWND hPollUnderCursor = GetDlgItem(hwnd, IDC_POLL_UNDER_CURSOR); SendMessage(hPollUnderCursor, BM_SETCHECK, _this->m_server->PollUnderCursor(), 0); HWND hPollConsoleOnly = GetDlgItem(hwnd, IDC_CONSOLE_ONLY); SendMessage(hPollConsoleOnly, BM_SETCHECK, _this->m_server->PollConsoleOnly(), 0); EnableWindow(hPollConsoleOnly, _this->m_server->PollUnderCursor() || _this->m_server->PollForeground() ); HWND hPollOnEventOnly = GetDlgItem(hwnd, IDC_ONEVENT_ONLY); SendMessage(hPollOnEventOnly, BM_SETCHECK, _this->m_server->PollOnEventOnly(), 0); EnableWindow(hPollOnEventOnly, _this->m_server->PollUnderCursor() || _this->m_server->PollForeground() ); // [v1.0.2-jp2 fix-->] HWND hSingleWindow = GetDlgItem(hwnd, IDC_SINGLE_WINDOW); SendMessage(hSingleWindow, BM_SETCHECK, _this->m_server->SingleWindow(), 0); HWND hWindowName = GetDlgItem(hwnd, IDC_NAME_APPLI); if ( _this->m_server->GetWindowName() != NULL){ SetDlgItemText(hwnd, IDC_NAME_APPLI,_this->m_server->GetWindowName()); } EnableWindow(hWindowName, _this->m_server->SingleWindow()); // [<--v1.0.2-jp2 fix] SetForegroundWindow(hwnd); return FALSE; // Because we've set the focus } case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: case IDC_APPLY: { int maxcpu = GetDlgItemInt(hwnd, IDC_MAXCPU, NULL, FALSE); _this->m_server->MaxCpu(maxcpu); // Modif sf@2002 HWND hTurboMode = GetDlgItem(hwnd, IDC_TURBOMODE); _this->m_server->TurboMode(SendMessage(hTurboMode, BM_GETCHECK, 0, 0) == BST_CHECKED); // Handle the polling stuff HWND hDriver = GetDlgItem(hwnd, IDC_DRIVER); bool result=(SendMessage(hDriver, BM_GETCHECK, 0, 0) == BST_CHECKED); if (result) { _this->m_server->Driver(CheckVideoDriver(0)); } else _this->m_server->Driver(false); HWND hHook = GetDlgItem(hwnd, IDC_HOOK); _this->m_server->Hook( SendMessage(hHook, BM_GETCHECK, 0, 0) == BST_CHECKED ); HWND hPollFullScreen = GetDlgItem(hwnd, IDC_POLL_FULLSCREEN); _this->m_server->PollFullScreen( SendMessage(hPollFullScreen, BM_GETCHECK, 0, 0) == BST_CHECKED ); HWND hPollForeground = GetDlgItem(hwnd, IDC_POLL_FOREGROUND); _this->m_server->PollForeground( SendMessage(hPollForeground, BM_GETCHECK, 0, 0) == BST_CHECKED ); HWND hPollUnderCursor = GetDlgItem(hwnd, IDC_POLL_UNDER_CURSOR); _this->m_server->PollUnderCursor( SendMessage(hPollUnderCursor, BM_GETCHECK, 0, 0) == BST_CHECKED ); HWND hPollConsoleOnly = GetDlgItem(hwnd, IDC_CONSOLE_ONLY); _this->m_server->PollConsoleOnly( SendMessage(hPollConsoleOnly, BM_GETCHECK, 0, 0) == BST_CHECKED ); HWND hPollOnEventOnly = GetDlgItem(hwnd, IDC_ONEVENT_ONLY); _this->m_server->PollOnEventOnly( SendMessage(hPollOnEventOnly, BM_GETCHECK, 0, 0) == BST_CHECKED ); // [v1.0.2-jp2 fix-->] Move to vncpropertiesPoll.cpp HWND hSingleWindow = GetDlgItem(hwnd, IDC_SINGLE_WINDOW); _this->m_server->SingleWindow(SendMessage(hSingleWindow, BM_GETCHECK, 0, 0) == BST_CHECKED); char szName[32]; if (GetDlgItemText(hwnd, IDC_NAME_APPLI, (LPSTR) szName, 32) == 0){ vnclog.Print(LL_INTINFO,VNCLOG("Error while reading Window Name %d \n"), GetLastError()); } else{ _this->m_server->SetSingleWindowName(szName); } // [<--v1.0.2-jp2 fix] Move to vncpropertiesPoll.cpp // Save the settings if (_this->m_fUseRegistry) _this->Save(); else _this->SaveToIniFile(); // Was ok pressed? if (LOWORD(wParam) == IDOK) { // Yes, so close the dialog vnclog.Print(LL_INTINFO, VNCLOG("enddialog (OK)\n")); _this->m_returncode_valid = TRUE; EndDialog(hwnd, IDOK); _this->m_dlgvisible = FALSE; } _this->m_server->SetHookings(); return TRUE; } // [v1.0.2-jp2 fix-->] Move to vncpropertiesPoll.cpp case IDC_SINGLE_WINDOW: { HWND hSingleWindow = GetDlgItem(hwnd, IDC_SINGLE_WINDOW); BOOL fSingleWindow = (SendMessage(hSingleWindow, BM_GETCHECK,0, 0) == BST_CHECKED); HWND hWindowName = GetDlgItem(hwnd, IDC_NAME_APPLI); EnableWindow(hWindowName, fSingleWindow); } return TRUE; // [<--v1.0.2-jp2 fix] Move to vncpropertiesPoll.cpp case IDCANCEL: vnclog.Print(LL_INTINFO, VNCLOG("enddialog (CANCEL)\n")); _this->m_returncode_valid = TRUE; EndDialog(hwnd, IDCANCEL); _this->m_dlgvisible = FALSE; return TRUE; case IDC_POLL_FOREGROUND: case IDC_POLL_UNDER_CURSOR: // User has clicked on one of the polling mode buttons // affected by the pollconsole and pollonevent options { // Get the poll-mode buttons HWND hPollForeground = GetDlgItem(hwnd, IDC_POLL_FOREGROUND); HWND hPollUnderCursor = GetDlgItem(hwnd, IDC_POLL_UNDER_CURSOR); // Determine whether to enable the modifier options BOOL enabled = (SendMessage(hPollForeground, BM_GETCHECK, 0, 0) == BST_CHECKED) || (SendMessage(hPollUnderCursor, BM_GETCHECK, 0, 0) == BST_CHECKED); HWND hPollConsoleOnly = GetDlgItem(hwnd, IDC_CONSOLE_ONLY); EnableWindow(hPollConsoleOnly, enabled); HWND hPollOnEventOnly = GetDlgItem(hwnd, IDC_ONEVENT_ONLY); EnableWindow(hPollOnEventOnly, enabled); } return TRUE; case IDC_CHECKDRIVER: { CheckVideoDriver(1); } return TRUE; } break; } return 0; }
void SaveEffect(HWND dialog, EditEffect *data) { Effect *e = &data->e; // CB_ERR is returned from no selection. this shows that CB_ERR == -1. //MessageBox(dialog, std::string("CB_ERR").append(toString<int>(CB_ERR)).c_str(), "Effect Editor", MB_OKCANCEL); // that means that when an item is not selected in a combobox, // CB_GETCURSEL saves -1. I think that this is the default value for // unused fields in AoK. However, what about Azzzru's panel having no // value? That is different as what he does shortens the SCX file. // How does AoKTS load his scenarios then? This means that a -1 // value for panel should not give error to aokts. int newtype = SendDlgItemMessage(dialog, IDC_E_TYPE, CB_GETCURSEL, 0, 0); if (newtype != CB_ERR) { e->type = newtype; GetWindowText(GetDlgItem(dialog, IDC_E_SOUND), e->sound); e->soundid = GetDlgItemInt(dialog, IDC_E_SOUNDID, NULL, TRUE); BOOL translated = NULL; int panel = GetDlgItemInt(dialog, IDC_E_PANEL, &translated, TRUE); if (!translated) { SString panelname; GetWindowText(GetDlgItem(dialog, IDC_E_PANEL), panelname); panel = SendDlgItemMessage(dialog, IDC_E_PANEL, CB_FINDSTRING, -1, (LPARAM) (LPCTSTR)panelname.c_str()); if (panel == CB_ERR) panel = -1; } e->panel = panel; GetWindowText(GetDlgItem(dialog, IDC_E_TEXT), e->text); e->disp_time = GetDlgItemInt(dialog, IDC_E_DTIME, NULL, TRUE); e->pUnit = (UnitLink*)LCombo_GetSelPtr(dialog, IDC_E_UCNST); e->textid = GetDlgItemInt(dialog, IDC_E_TEXTID, NULL, TRUE); e->s_player = SendDlgItemMessage(dialog, IDC_E_SPLAY, CB_GETCURSEL, 0, 0); e->t_player = SendDlgItemMessage(dialog, IDC_E_TPLAY, CB_GETCURSEL, 0, 0); e->diplomacy = (enum Diplomacy)SendDlgItemMessage(dialog, IDC_E_DSTATE, CB_GETCURSEL, 0, 0); e->location.x = GetDlgItemInt(dialog, IDC_E_LOCX, NULL, TRUE); e->location.y = GetDlgItemInt(dialog, IDC_E_LOCY, NULL, TRUE); e->area.left = GetDlgItemInt(dialog, IDC_E_AREAX1, NULL, TRUE); e->area.bottom = GetDlgItemInt(dialog, IDC_E_AREAY1, NULL, TRUE); e->area.right = GetDlgItemInt(dialog, IDC_E_AREAX2, NULL, TRUE); e->area.top = GetDlgItemInt(dialog, IDC_E_AREAY2, NULL, TRUE); e->pTech = (TechLink*)LCombo_GetSelPtr(dialog, IDC_E_RESEARCH); e->ai_goal = GetDlgItemInt(dialog, IDC_E_AIGOAL, NULL, TRUE); e->amount = GetDlgItemInt(dialog, IDC_E_AMOUNT, NULL, TRUE); e->res_type = LCombo_GetSelId(dialog, IDC_E_RESTYPE); //get the data, not the index, for these e->trig_index = Combo_GetSelData(GetDlgItem(dialog, IDC_E_TRIG)); e->group = Combo_GetSelData(GetDlgItem(dialog, IDC_E_GROUP)); e->utype = Combo_GetSelData(GetDlgItem(dialog, IDC_E_UTYPE)); } }
LRESULT CALLBACK FilterboxDlgHandler( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { int t; // ,z; char newname[25],sztemp[30]; static int acttype; static int dinit=FALSE; static FidFilter * tempf=NULL,* newf=NULL; FILTEROBJ * st; st = (FILTEROBJ *) actobject; if ((st==NULL)||(st->type!=OB_FILTER)) return(FALSE); switch( message ) { case WM_INITDIALOG: dinit=TRUE; SendMessage(GetDlgItem(hDlg, IDC_FILTERTYPECOMBO), CB_RESETCONTENT,0,0); for (t = 0; t < FILTERTYPES; t++) SendMessage( GetDlgItem(hDlg, IDC_FILTERTYPECOMBO), CB_ADDSTRING, 0, (LPARAM) (LPSTR) FILTERTYPE[t].tname) ; SetDlgItemText(hDlg,IDC_FILTERTYPECOMBO, FILTERTYPE[st->filtertype].tname); SetDlgItemText(hDlg,IDC_FILTERNEWNAME, st->name); SetDlgItemInt(hDlg,IDC_FROMFREQ, st->dispfrom,0); SetDlgItemInt(hDlg,IDC_TOFREQ, st->dispto,0); SetDlgItemInt(hDlg,IDC_FILTERPAR0, st->par0,0); sprintf(sztemp,"%.5f",st->par1); SetDlgItemText(hDlg,IDC_FILTERPAR1, sztemp); sprintf(sztemp,"%.5f",st->par2); SetDlgItemText(hDlg,IDC_FILTERPAR2, sztemp); acttype=st->filtertype; dinit=FALSE; newf=do_filt_design(hDlg,acttype); if (newf) tempf=newf; update_filterdialog(hDlg,st->filtertype); return TRUE; case WM_CLOSE: EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_FILTERTYPECOMBO: acttype=SendMessage( GetDlgItem(hDlg, IDC_FILTERTYPECOMBO), CB_GETCURSEL, 0, 0 ) ; update_filterdialog(hDlg,acttype); case IDC_FILTERPAR0: case IDC_FILTERPAR1: case IDC_FILTERPAR2: case IDC_FROMFREQ: case IDC_TOFREQ: if (!dinit) { newf=do_filt_design(hDlg,acttype); if (newf) tempf=newf; InvalidateRect(hDlg,NULL,TRUE); } break; case IDC_FILTERSTORE: if (newf) { GetDlgItemText(hDlg, IDC_FILTERNEWNAME,newname,sizeof(newname)); st->filtertype=acttype; st->par0=GetDlgItemInt(hDlg,IDC_FILTERPAR0, NULL, 0); GetDlgItemText(hDlg,IDC_FILTERPAR1,sztemp,sizeof(sztemp)); sscanf(sztemp,"%f",&st->par1); GetDlgItemText(hDlg,IDC_FILTERPAR2,sztemp,sizeof(sztemp)); st->dispfrom=GetDlgItemInt(hDlg, IDC_FROMFREQ, NULL, 0); st->dispto=GetDlgItemInt(hDlg, IDC_TOFREQ, NULL, 0); sscanf(sztemp,"%f",&st->par2); strcpy(st->name,newname); st->filt=do_filt_design(hDlg, acttype); st->run= fid_run_new(st->filt, &(st->funcp)); if (st->fbuf!=NULL) { fid_run_freebuf(st->fbuf); st->fbuf=fid_run_newbuf(st->run); } } break; } return(TRUE); case WM_PAINT: { PAINTSTRUCT ps; HDC hdc; RECT rect; HPEN tpen; HBRUSH tbrush; int height; int f1,f2; float fstep,val,x; hdc = BeginPaint (hDlg, &ps); GetClientRect(hDlg, &rect); tpen = CreatePen (PS_SOLID,1,0); SelectObject (hdc, tpen); tbrush = CreateSolidBrush(RGB(240,240,240)); SelectObject(hdc,tbrush); rect.top+=80; rect.bottom -= 18; height= rect.bottom-rect.top; Rectangle(hdc,rect.left,rect.top-1,rect.right,rect.bottom+20); Rectangle(hdc,rect.left,rect.top-1,rect.right,rect.bottom); Rectangle(hdc,rect.left,rect.bottom-(int)(height/1.3),rect.right,rect.bottom); DeleteObject(tbrush); DeleteObject(tpen); tpen = CreatePen (PS_SOLID,1,RGB(0,100,0)); SelectObject (hdc, tpen); f1=GetDlgItemInt(hDlg, IDC_FROMFREQ, NULL, 0); f2=GetDlgItemInt(hDlg, IDC_TOFREQ, NULL, 0); fstep=(float)(f2-f1)/(rect.right-rect.left); MoveToEx(hdc,rect.left+1,rect.bottom-(int)(height*fid_response(tempf, (float)f1/256.0)/1.3),NULL); for (t=rect.left; t<rect.right; t++) { MoveToEx(hdc,1+t,rect.bottom,NULL); LineTo(hdc,1+t,rect.bottom-(int)(height*fid_response(tempf, (((float)f1+fstep*(t-rect.left))/PACKETSPERSECOND))/1.3)); } SelectObject(hdc, DRAW.scaleFont); wsprintf(sztemp,"1.0"); ExtTextOut( hdc, rect.left+2,rect.top+(int)(height*0.2308), 0, &rect,sztemp, strlen(sztemp), NULL ) ; val=(f2-f1)/10.0f; fstep=((rect.right-25)-rect.left)/10.0f; for (t=0; t<=10; t++) { x=f1+val*t; wsprintf(sztemp,"%d.%d",(int)x,(int)(x*10)%10); ExtTextOut( hdc, rect.left+2+(int)(fstep*t),rect.bottom+2, 0, &rect,sztemp, strlen(sztemp), NULL ) ; } DeleteObject(tpen); EndPaint(hDlg, &ps ); } break; case WM_SIZE: case WM_MOVE: update_toolbox_position(hDlg); break; return(TRUE); } return FALSE; }
/// <summary> /// Called when [bn execute_ clicked]. /// </summary> void CGhjDlg::OnBnExecute_Clicked() { DWORD textLength = m_tbWorkSpace.GetWindowTextLengthW(); if(textLength==0) { AfxMessageBox(L"Please enter workspace path", MB_OK); return; } textLength = m_tbFileR.GetWindowTextLengthW(); if(textLength==0) { AfxMessageBox(L"Please enter path for R relation", MB_OK); return; } textLength = m_tbKeyPosR.GetWindowTextLengthW(); if(textLength==0) { AfxMessageBox(L"Please enter key attribute for R relation", MB_OK); return; } textLength = m_tbFileS.GetWindowTextLengthW(); if(textLength==0) { AfxMessageBox(L"Please enter path for S relation", MB_OK); return; } textLength = m_tbKeyPosS.GetWindowTextLengthW(); if(textLength==0) { AfxMessageBox(L"Please enter key attribute for S relation", MB_OK); return; } textLength = m_tbPoolSize.GetWindowTextLengthW(); if(textLength==0) { AfxMessageBox(L"Please enter buffer pool size", MB_OK); return; } GHJ_PARAMS ghjParams; m_tbWorkSpace.GetWindowTextW(ghjParams.WORK_SPACE_PATH, MAX_PATH); UINT poolSize = GetDlgItemInt(IDC_TB_GHJ_BUFFER_POOL_SIZE, FALSE, FALSE); ghjParams.BUFFER_POOL_SIZE = poolSize * SSD_PAGE_SIZE * 256; m_tbFileR.GetWindowTextW(ghjParams.RELATION_R_PATH, MAX_PATH); _wsplitpath(ghjParams.RELATION_R_PATH, NULL, NULL, ghjParams.RELATION_R_NO_EXT, NULL); ghjParams.R_KEY_POS = GetDlgItemInt(IDC_TB_GHJ_KEY_POS_1, FALSE, FALSE); m_tbFileS.GetWindowTextW(ghjParams.RELATION_S_PATH, MAX_PATH); _wsplitpath( ghjParams.RELATION_S_PATH, NULL, NULL, ghjParams.RELATION_S_NO_EXT, NULL); ghjParams.S_KEY_POS = GetDlgItemInt(IDC_TB_GHJ_KEY_POS_2, FALSE, FALSE); INT selectedIndex =-1; selectedIndex = m_cbbReadBufferSize.GetCurSel(); for(UINT i = 0; i < g_ComboBoxBufferItems.size(); i++) { if(selectedIndex==i) { ghjParams.READ_BUFFER_SIZE = g_ComboBoxBufferItems[i]->Value; break; } } selectedIndex = m_cbbWriteBufferSize.GetCurSel(); for(UINT i = 0; i < g_ComboBoxBufferItems.size(); i++) { if(selectedIndex==i) { ghjParams.WRITE_BUFFER_SIZE = g_ComboBoxBufferItems[i]->Value; break; } } ghjParams.FUDGE_FACTOR = 1.2; ghjParams.BUCKET_SIZE = 4096 * 64; // 256 KB m_btExecute.EnableWindow(FALSE); ThreadParams *myParams = new ThreadParams; myParams->_this = this; myParams->ghjParams = ghjParams; m_hGhjThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)RunEx, myParams, CREATE_SUSPENDED, NULL); SetThreadPriority(m_hGhjThread, THREAD_PRIORITY_NORMAL); m_Requestor.RequestNotification(m_hGhjThread, this, OP_GHJ); ResumeThread(m_hGhjThread); }
void CGeneratorDlg::OnBnClickedButtonBingo() { CONNECT_INFO Config_Info = {0}; SERVICE_INFO Service_Info = {0}; GENERATOR_CONFIG generateConfig; UpdateWindow(); //得到连接地址 GetDlgItemTextA(m_hWnd,IDC_EDIT_CONADDR, Config_Info.szAddr,sizeof(Config_Info.szAddr)); generateConfig.serverIP = CString(Config_Info.szAddr); // //得到安装目录 // GetDlgItemTextW(IDC_EDIT_INSTALLPATH,Service_Info.szInstalPath,sizeof(Service_Info.szInstalPath)/sizeof(TCHAR)); // generateConfig.serviceInstallpath = Service_Info.szInstalPath; lstrcpy(Service_Info.szInstalPath,config.serviceInstallpath); // //得到服务名 // GetDlgItemTextA(m_hWnd,IDC_EDIT_SERVICENAME, Service_Info.szServiceName,sizeof(Service_Info.szServiceName)); // generateConfig.serviceName = CString(Service_Info.szServiceName); lstrcpyA(Service_Info.szServiceName,CStringA(config.serviceName).GetBuffer()); // //得到服务DisplayName // GetDlgItemTextA(m_hWnd,IDC_EDIT_DISPLAYNAME,Service_Info.szDisplayName,sizeof(Service_Info.szDisplayName)); // generateConfig.serviceDisplayName = CString(Service_Info.szDisplayName); lstrcpyA(Service_Info.szDisplayName,CStringA(config.serviceDisplayName).GetBuffer()); // //得到服务描述 // GetDlgItemTextA(m_hWnd,IDC_EDIT_SERVICEDEC,Service_Info.szServiceDecript,sizeof(Service_Info.szServiceDecript)); // generateConfig.serviceDescription = CString(Service_Info.szServiceDecript); lstrcpyA(Service_Info.szServiceDecript,CStringA(config.serviceDescription).GetBuffer()); // //得到代理地址 // GetDlgItemTextA(m_hWnd,IDC_EDIT_PROXYADDR,Config_Info.szProxyAddr,sizeof(Config_Info.szProxyAddr)); // //得到代理用户名 // GetDlgItemTextA(m_hWnd,IDC_EDIT_PROXYUSER,Config_Info.szProxyUsername,sizeof(Config_Info.szProxyUsername)); // //得到代理用户密码 // GetDlgItemTextA(m_hWnd,IDC_EDIT_PROXYPASS,Config_Info.szProxyPassword,sizeof(Config_Info.szProxyPassword)); //得到组名 GetDlgItemTextA(m_hWnd,IDC_EDIT_GROUP,Config_Info.szGroups,sizeof(Config_Info.szProxyPassword)); //得到通信方式 int nSel = m_DefaultComm.GetCurSel(); Config_Info.nDefaultCommType = m_DefaultComm.GetItemData(nSel); generateConfig.commType = m_DefaultComm.GetCurSel(); //得到尝试连接间隔 Config_Info.nTryConnectIntervalM = GetDlgItemInt(IDC_EDIT_TRY_INTERVALM); generateConfig.connectTryIntervalM = Config_Info.nTryConnectIntervalM; //得到首次连接时间 Config_Info.nFirstConnectHour = GetDlgItemInt(IDC_EDIT_FIRSTCONNECT_HOUR); generateConfig.firstConnectHour = Config_Info.nFirstConnectHour; Config_Info.nFirstConnectMinute = GetDlgItemInt(IDC_EDIT_FIRSTCONNECT_MINUTE); generateConfig.firstConnectMinute = Config_Info.nFirstConnectMinute; // //得到下载SVT时间和间隔 // Config_Info.nFirstDownSvtOffsetS = GetDlgItemInt(IDC_EDIT_FIRST_SVT_OFFSET); // generateConfig.downSvtOffsetS = Config_Info.nFirstDownSvtOffsetS; // Config_Info.nDownSvtIntervalS = GetDlgItemInt(IDC_EDIT_SVT_INTERVAL); // generateConfig.downSvtIntervalS = Config_Info.nDownSvtIntervalS; //得到连接类型和代理方式 Config_Info.nConnectType = m_ConnectType.GetCurSel(); // Config_Info.nProxyType = m_ProxyType.GetCurSel(); //得到是否随机安装和生成方式 // Service_Info.bUseChameleon = (m_SetupType.GetCurSel() == 0); // generateConfig.setupType = m_SetupType.GetCurSel(); Config_Info.nProxyPort = GetDlgItemInt(IDC_EDIT_PROXYPORT); //得到端口 Config_Info.nPort = GetDlgItemInt(IDC_EDIT_PORT); generateConfig.port = GetDlgItemInt(IDC_EDIT_PORT); // BOOL bCarrier = ((CButton*)GetDlgItem(IDC_RADIO_CARRIER))->GetCheck(); // BOOL bSetup = ((CButton*)GetDlgItem(IDC_RADIO_SETUP))->GetCheck(); // BOOL bPassUAC = ((CButton*)GetDlgItem(IDC_RADIO_PASSUAC))->GetCheck(); // BOOL bHijack = ((CButton*)GetDlgItem(IDC_RADIO_HIJACK))->GetCheck(); generateConfig.packetType = PACKET_TYPE_SETUP; // if (bPassUAC) generateConfig.packetType = PACKET_TYPE_PASSUAC; // if (bHijack) generateConfig.packetType = PACKET_TYPE_HIJACK; Config_Info.nFlag = CONNECT_FLAG; Service_Info.nFlag = SERVICE_FLAG; CString strError; // if (bCarrier && WriteCarrier(Config_Info,Service_Info,strError)) // { // MessageBox(_T("Carrier生成成功!")); // } // else if (bSetup && WriteSetup(Config_Info,Service_Info,strError)) // { // MessageBox(_T("Setup生成成功!")); // // CString exploreParameter; // // exploreParameter.Format(_T("/e,/select,\"%ssetup.exe\""), GetModFilePath(NULL)); // // ::ShellExecute(NULL, _T("open"), _T("explorer.exe"), exploreParameter, NULL, SW_SHOW); // } // else if (bPassUAC && WriteBypassUAC(Config_Info,Service_Info,strError)) // { // MessageBox(L"BypassUAC生成成功!"); // // CString exploreParameter; // // exploreParameter.Format(_T("/e,/select,\"%ssetup.exe\""), GetModFilePath(NULL)); // // ::ShellExecute(NULL, _T("open"), _T("explorer.exe"), exploreParameter, NULL, SW_SHOW); // } // else if(bHijack && WriteHijack(Config_Info,Service_Info,strError)) // { // MessageBox(_T("Hijack生成成功!")); // // CString exploreParameter; // // exploreParameter.Format(_T("/e,/select,\"%shijack\\RsTray.exe\""), GetModFilePath(NULL)); // // ::ShellExecute(NULL, _T("open"), _T("explorer.exe"), exploreParameter, NULL, SW_SHOW); // } if ( WriteSetup(Config_Info,Service_Info,strError)) { MessageBox(_T("Setup生成成功!")); // CString exploreParameter; // exploreParameter.Format(_T("/e,/select,\"%ssetup.exe\""), GetModFilePath(NULL)); // ::ShellExecute(NULL, _T("open"), _T("explorer.exe"), exploreParameter, NULL, SW_SHOW); } else { MessageBox(strError); } SaveGeneratorConfig(generateConfig); }