void RestoreWindowPos(HWND hwnd) { HKEY hKey; WINDOWPLACEMENT p; if (OpenRegSettingsKey(hKey)) { DWORD l = sizeof(p); DWORD t; if ((RegQueryValueEx(hKey,REGLOC,NULL,&t,(LPBYTE)&p,&l)==ERROR_SUCCESS)&&(t == REG_BINARY)&&(l==sizeof(p))) { int width, height; int windowWidth, windowHeight; width = GetSystemMetrics(SM_CXFULLSCREEN); height = GetSystemMetrics(SM_CYFULLSCREEN); height += GetSystemMetrics(SM_CYCAPTION); windowWidth = p.rcNormalPosition.right-p.rcNormalPosition.left; if(windowWidth > width) { p.rcNormalPosition.left = 0; p.rcNormalPosition.right = width; } else if(p.rcNormalPosition.right > width) { p.rcNormalPosition.left = width - windowWidth; p.rcNormalPosition.right = width; } else if(p.rcNormalPosition.left < 0) { p.rcNormalPosition.left = 0; p.rcNormalPosition.right = windowWidth; } windowHeight = p.rcNormalPosition.bottom-p.rcNormalPosition.top; if(windowHeight > height) { p.rcNormalPosition.top = 0; p.rcNormalPosition.bottom = height; } else if(p.rcNormalPosition.bottom > height) { p.rcNormalPosition.top = height - windowHeight; p.rcNormalPosition.bottom = height; } else if(p.rcNormalPosition.top < 0) { p.rcNormalPosition.top = 0; p.rcNormalPosition.bottom = windowHeight; } p.length = sizeof(p); SetWindowPlacement(hwnd, &p); } RegCloseKey(hKey); } }
void SaveCompressor() { HKEY hKey; int n = (int)COMPRESSOR_SCRIPT; NCOMPRESSOR v = g_sdata.default_compressor; if(v >= COMPRESSOR_SCRIPT && v <= COMPRESSOR_BEST) { n = (int)v; } if (OpenRegSettingsKey(hKey, true)) { // compressor_names, even if Unicode is saved as BYTE* data. RegSetValueEx(hKey,REGCOMPRESSOR,0,REG_SZ,(const BYTE*)compressor_names[n], lstrlen(compressor_names[n])*sizeof(TCHAR)); RegCloseKey(hKey); } }
void RestoreCompressor() { HKEY hKey; NCOMPRESSOR v = COMPRESSOR_SCRIPT; if (OpenRegSettingsKey(hKey)) { TCHAR compressor_name[32]; if (RegReadString(hKey, REGCOMPRESSOR, compressor_name, sizeof(compressor_name))==ERROR_SUCCESS) { for(UINT i= (UINT)COMPRESSOR_SCRIPT; i <= (UINT)COMPRESSOR_BEST; i++) { if(!lstrcmpi(compressor_names[i], compressor_name)) { v = (NCOMPRESSOR)i; break; } } } RegCloseKey(hKey); } g_sdata.default_compressor = v; }
void SaveSymbolSet(TCHAR *name, TCHAR **symbols) { HKEY hKey; HKEY hSubKey; int n = 0; if (OpenRegSettingsKey(hKey, true)) { TCHAR subkey[1024]; if(name) { wsprintf(subkey,_T("%s\\%s"),REGSYMSUBKEY,name); } else { lstrcpy(subkey,REGSYMSUBKEY); } if (RegOpenKey(hKey,subkey,&hSubKey) == ERROR_SUCCESS) { TCHAR buf[8]; DWORD l; while(TRUE) { l = sizeof(buf); if (RegEnumValue(hSubKey,0, buf, &l,NULL,NULL,NULL,NULL)==ERROR_SUCCESS) { RegDeleteValue(hSubKey,buf); } else { break; } } RegCloseKey(hSubKey); } if(symbols) { if (RegCreateKey(hKey,subkey,&hSubKey) == ERROR_SUCCESS) { TCHAR buf[8]; n = 0; while(symbols[n]) { wsprintf(buf,_T("%d"),n); RegSetValueEx(hSubKey,buf,0,REG_SZ,(CONST BYTE *)symbols[n],(lstrlen(symbols[n])+1)*sizeof(TCHAR)); n++; } RegCloseKey(hSubKey); } } RegCloseKey(hKey); } }
void RestoreCompressor() { HKEY hKey; NCOMPRESSOR v = COMPRESSOR_SCRIPT; if (OpenRegSettingsKey(hKey)) { TCHAR compressor_name[32]; DWORD l = sizeof(compressor_name); DWORD t; if (RegQueryValueEx(hKey,REGCOMPRESSOR,NULL,&t,(LPBYTE)compressor_name,&l)==ERROR_SUCCESS) { int i; for(i=(int)COMPRESSOR_SCRIPT; i<= (int)COMPRESSOR_BEST; i++) { if(!lstrcmpi(compressor_names[i],compressor_name)) { v = (NCOMPRESSOR)i; break; } } } RegCloseKey(hKey); } g_sdata.default_compressor=v; }
void SaveMRUList() { HKEY hKey; HKEY hSubKey; int i = 0; if (OpenRegSettingsKey(hKey, true)) { if (RegCreateKey(hKey,REGMRUSUBKEY,&hSubKey) == ERROR_SUCCESS) { TCHAR buf[8]; for(i = 0; i < MRU_LIST_SIZE; i++) { wsprintf(buf,_T("%d"),i); if (*g_mru_list[i]) { // cbData must include the size of the terminating null character. RegSetValueEx(hSubKey,buf,0,REG_SZ,(const BYTE*)g_mru_list[i],(lstrlen(g_mru_list[i])+1)*sizeof(TCHAR)); } else { RegDeleteValue(hSubKey,buf); } } RegCloseKey(hSubKey); } RegCloseKey(hKey); } }
void RestoreMRUList() { HKEY hCfgKey, hMRUKey; UINT n = 0, i; if (OpenRegSettingsKey(hCfgKey)) { if (RegOpenKeyForReading(hCfgKey, REGMRUSUBKEY, &hMRUKey) == ERROR_SUCCESS) { for(int i=0; i<MRU_LIST_SIZE; i++) { TCHAR bufName[8]; wsprintf(bufName, _T("%d"), i); DWORD ec = RegReadString(hMRUKey, bufName, g_mru_list[n], sizeof(g_mru_list[n])); if(!ec && g_mru_list[n][0] != _T('\0')) { n++; } } RegCloseKey(hMRUKey); } RegCloseKey(hCfgKey); } for(i = n; i < MRU_LIST_SIZE; i++) { g_mru_list[i][0] = _T('\0'); } BuildMRUMenus(); }
INT_PTR CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_INITDIALOG: { HWND hwndEdit; HKEY hKey; EnableWindow(GetDlgItem(hwndDlg, IDC_DEL), FALSE); if (OpenRegSettingsKey(hKey)) { HKEY hSubKey; if (RegOpenKeyEx(hKey,REGSYMSUBKEY,0,KEY_READ,&hSubKey) == ERROR_SUCCESS) { TCHAR subkey[1024]; int i=0; while (RegEnumKey(hSubKey,i,subkey,sizeof(subkey)) == ERROR_SUCCESS) { SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_ADDSTRING, 0, (LPARAM)subkey); i++; } RegCloseKey(hSubKey); } RegCloseKey(hKey); } hwndEdit = FindWindowEx(GetDlgItem(hwndDlg, IDC_NAMES), 0, 0, 0); // Handle of list hwndEdit = FindWindowEx(GetDlgItem(hwndDlg, IDC_NAMES), hwndEdit, 0, 0); //Handle of edit box SendMessage(hwndEdit, EM_LIMITTEXT, (WPARAM)SYMBOL_SET_NAME_MAXLEN, 0); if(g_symbol_set_mode == 1) { //Load SetWindowText(hwndDlg, LOAD_SYMBOL_SET_DLG_NAME); SetWindowText(GetDlgItem(hwndDlg, IDOK), LOAD_BUTTON_TEXT); SendMessage(hwndEdit, EM_SETREADONLY, (WPARAM)TRUE, 0); } else { SetWindowText(hwndDlg, SAVE_SYMBOL_SET_DLG_NAME); SetWindowText(GetDlgItem(hwndDlg, IDOK), SAVE_BUTTON_TEXT); } break; } case WM_COMMAND: { switch (LOWORD(wParam)) { case IDOK: { HWND hwndEdit; TCHAR name[SYMBOL_SET_NAME_MAXLEN+1]; hwndEdit = FindWindowEx(GetDlgItem(hwndDlg, IDC_NAMES), 0, 0, 0); // Handle of list hwndEdit = FindWindowEx(GetDlgItem(hwndDlg, IDC_NAMES), hwndEdit, 0, 0); //Handle of edit box SendMessage(hwndEdit, WM_GETTEXT, (WPARAM)SYMBOL_SET_NAME_MAXLEN+1, (LPARAM)name); if(!lstrlen(name)) { if(g_symbol_set_mode == 1) { //Load MessageBox(hwndDlg,LOAD_SYMBOL_SET_MESSAGE,LOAD_SYMBOL_SET_DLG_NAME,MB_OK|MB_ICONEXCLAMATION); } else { MessageBox(hwndDlg,SAVE_SYMBOL_SET_MESSAGE,SAVE_SYMBOL_SET_DLG_NAME,MB_OK|MB_ICONEXCLAMATION); } } else { HWND hwndParent = GetParent(hwndDlg); if(g_symbol_set_mode == 1) { //Load SendMessage(hwndParent, WM_MAKENSIS_LOADSYMBOLSET, (WPARAM)name, (LPARAM)NULL); } else { SendMessage(hwndParent, WM_MAKENSIS_SAVESYMBOLSET, (WPARAM)name, (LPARAM)NULL); } EndDialog(hwndDlg, TRUE); } break; } case IDCANCEL: { EndDialog(hwndDlg, TRUE); break; } case IDC_DEL: { int n = SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_GETCURSEL, 0, 0); if(n != CB_ERR) { long len = SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_GETLBTEXTLEN, (WPARAM)n, 0); TCHAR *buf = (TCHAR*) MemAllocZI((len+1)*sizeof(TCHAR)); if(SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_GETLBTEXT, (WPARAM)n, (LPARAM)buf) != CB_ERR) { SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_DELETESTRING, n, 0); DeleteSymbolSet(buf); } MemFree(buf); } EnableWindow(GetDlgItem(hwndDlg, IDC_DEL), FALSE); break; } case IDC_NAMES: { if(HIWORD(wParam) == CBN_SELCHANGE) { int n = SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_GETCURSEL, 0, 0); EnableWindow(GetDlgItem(hwndDlg, IDC_DEL), CB_ERR != n); } else if(HIWORD(wParam) == CBN_DBLCLK) { int n = SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_GETCURSEL, 0, 0); if (n != CB_ERR) { SendDlgItemMessage(hwndDlg, IDOK, BM_CLICK, 0, 0); } } break; } } break; } } return FALSE; }