void LoadRegSysSettings() { HKEY hKey; RegCreateKeyEx(HKEY_CURRENT_USER, REGLOC, 0, 0, 0, KEY_READ, 0, &hKey, 0); GetSettingInt(hKey, _T("AddExplorer"), &g_fAddToExplorer, FALSE); GetSettingInt(hKey, _T("ReplaceNotepad"), &g_fReplaceNotepad, FALSE); RegCloseKey(hKey); }
CSIE9API void LogMessage( const char *text, ... ) { if (GetSettingInt(L"LogLevel")==0) return; wchar_t fname[_MAX_PATH]=L"%LOCALAPPDATA%\\ClassicIE9Log.txt"; DoEnvironmentSubst(fname,_countof(fname)); FILE *f; if (_wfopen_s(&f,fname,L"a+b")==0) { va_list args; va_start(args,text); vfprintf(f,text,args); va_end(args); fclose(f); } }
//*********************************************************************** BOOL CLGBApp::InitInstance() //*********************************************************************** { HGLOBAL hData; LPSTR lpTableData; // load the scene table lpTableData = GetResourceData(IDR_SCENETABLE, "gametbl", &hData); if (lpTableData) { CSceneTableParser parser(lpTableData); if (m_nScenes = parser.GetNumEntries()) { m_pSceneTable = new CSceneEntry[m_nScenes]; if (m_pSceneTable) parser.ParseTable((DWORD)m_pSceneTable); } } if (hData) { UnlockResource( hData ); FreeResource( hData ); } if (!m_pSceneTable) return(FALSE); m_Language = (Language)GetSettingInt("Language", English); m_nBookmark = GetSettingInt("Bookmark", 0); if (m_Language != English && m_Language != Spanish) m_Language = English; if (!CPHApp::InitInstance()) return(FALSE); m_hAccel = LoadAccelerators(GetInstance(), MAKEINTRESOURCE(IDR_ACCEL)); return TRUE; }
void LoadRegSettings() { HKEY hKey, hColKey; // open registry location for reading RegCreateKeyEx(HKEY_CURRENT_USER, REGLOC, 0, 0, 0, KEY_READ, 0, &hKey, 0); GetSettingInt(hKey, _T("FontSize"), &g_nFontSize, 10); GetSettingInt(hKey, _T("FontBold"), &g_fFontBold, FALSE); GetSettingStr(hKey, _T("FontName"), g_szFontName, LF_FACESIZE, _T("Courier New")); GetSettingInt(hKey, _T("FontSmooth"), &g_nFontSmoothing, DEFAULT_QUALITY); GetSettingInt(hKey, _T("PaddingAbove"), &g_nPaddingAbove, 0); GetSettingInt(hKey, _T("PaddingBelow"), &g_nPaddingBelow, 1); GetSettingInt(hKey, _T("PaddingFlags"), &g_fPaddingFlags, COURIERNEW|LUCIDACONS); GetSettingInt(hKey, _T("SelMargin"), &g_fSelMargin, TRUE); GetSettingInt(hKey, _T("LineNumbers"), &g_fLineNumbers, FALSE); GetSettingInt(hKey, _T("LongLines"), &g_fLongLines, TRUE); GetSettingInt(hKey, _T("LongLineLimit"), &g_nLongLineLimit, 80); GetSettingInt(hKey, _T("SaveOnExit"), &g_fSaveOnExit, TRUE); GetSettingInt(hKey, _T("HLCurLine"), &g_nHLCurLine, FALSE); GetSettingInt(hKey, _T("AddExplorer"), &g_fAddToExplorer, FALSE); GetSettingInt(hKey, _T("ReplaceNotepad"), &g_fReplaceNotepad, FALSE); GetSettingInt(hKey, _T("ShowStatusbar"), &g_fShowStatusbar, FALSE); // read the display colours RegCreateKeyEx(hKey, _T("Colours"), 0, 0, 0, KEY_READ, 0, &hColKey, 0); GetSettingInt(hColKey, _T("Foreground"), &g_rgbColourList[TXC_FOREGROUND], g_rgbAutoColourList[TXC_FOREGROUND] ); GetSettingInt(hColKey, _T("Background"), &g_rgbColourList[TXC_BACKGROUND], g_rgbAutoColourList[TXC_BACKGROUND] ); GetSettingInt(hColKey, _T("SelFG"), &g_rgbColourList[TXC_HIGHLIGHTTEXT], g_rgbAutoColourList[TXC_HIGHLIGHTTEXT] ); GetSettingInt(hColKey, _T("SelBG"), &g_rgbColourList[TXC_HIGHLIGHT], g_rgbAutoColourList[TXC_HIGHLIGHT] ); GetSettingInt(hColKey, _T("SelFG2"), &g_rgbColourList[TXC_HIGHLIGHTTEXT2], g_rgbAutoColourList[TXC_HIGHLIGHTTEXT2] ); GetSettingInt(hColKey, _T("SelBG2"), &g_rgbColourList[TXC_HIGHLIGHT2], g_rgbAutoColourList[TXC_HIGHLIGHT2] ); GetSettingInt(hColKey, _T("Margin1"), &g_rgbColourList[TXC_SELMARGIN1], g_rgbAutoColourList[TXC_SELMARGIN1] ); GetSettingInt(hColKey, _T("Margin2"), &g_rgbColourList[TXC_SELMARGIN2], g_rgbAutoColourList[TXC_SELMARGIN2] ); GetSettingInt(hColKey, _T("LinenoText"), &g_rgbColourList[TXC_LINENUMBERTEXT], g_rgbAutoColourList[TXC_LINENUMBERTEXT] ); GetSettingInt(hColKey, _T("Lineno"), &g_rgbColourList[TXC_LINENUMBER], g_rgbAutoColourList[TXC_LINENUMBER] ); GetSettingInt(hColKey, _T("LongLineText"), &g_rgbColourList[TXC_LONGLINETEXT], g_rgbAutoColourList[TXC_LONGLINETEXT] ); GetSettingInt(hColKey, _T("LongLine"), &g_rgbColourList[TXC_LONGLINE], g_rgbAutoColourList[TXC_LONGLINE] ); GetSettingInt(hColKey, _T("CurlineText"), &g_rgbColourList[TXC_CURRENTLINETEXT], g_rgbAutoColourList[TXC_CURRENTLINETEXT] ); GetSettingInt(hColKey, _T("Curline"), &g_rgbColourList[TXC_CURRENTLINE], g_rgbAutoColourList[TXC_CURRENTLINE] ); GetSettingBin(hColKey, _T("Custom"), g_rgbCustColours, sizeof(g_rgbCustColours)); RegCloseKey(hColKey); RegCloseKey(hKey); }
static LRESULT CALLBACK WindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData ) { if (uMsg==WM_WINDOWPOSCHANGING) { WINDOWPOS *pos=(WINDOWPOS*)lParam; if (pos->flags&SWP_SHOWWINDOW) { wchar_t title[256]; GetWindowText(hWnd,title,_countof(title)); if (_wcsicmp(title,g_TitleMove)==0 || _wcsicmp(title,g_TitleCopy)==0) { // file UI if (GetSettingBool(L"ReplaceFileUI")) { CString log; bool bLog=GetSettingInt(L"LogLevel")>0; CComPtr<IAccessible> pAcc; HRESULT h=AccessibleObjectFromWindow(hWnd,OBJID_WINDOW,IID_IAccessible,(void**)&pAcc); if (SUCCEEDED(h) && pAcc) { CClassicCopyFile copy; if (copy.Run(hWnd,pAcc,bLog?&log:NULL)) { pos->x=pos->y=-20000; pos->flags&=~(SWP_SHOWWINDOW|SWP_NOMOVE); } } else if (bLog) LogPrint(&log,L"AccessibleObjectFromWindow: error=0x%X, hWnd=0x%X",h,(DWORD)hWnd); if (bLog) { wchar_t fname[_MAX_PATH]=L"%LOCALAPPDATA%\\ExplorerLog.txt"; DoEnvironmentSubst(fname,_countof(fname)); if (!log.IsEmpty()) { FILE *f; if (_wfopen_s(&f,fname,L"wb")==0) { fwprintf(f,L"\xFEFF"); OSVERSIONINFOEX ver={sizeof(ver)}; GetVersionEx((OSVERSIONINFO*)&ver); fwprintf(f,L"version = %d.%d.%d - %d.%d\r\n\r\n",ver.dwMajorVersion,ver.dwMinorVersion,ver.dwBuildNumber,ver.wServicePackMajor,ver.wServicePackMinor); wchar_t languages[100]={0}; ULONG size=4; // up to 4 languages ULONG len=_countof(languages); GetThreadPreferredUILanguages(MUI_LANGUAGE_NAME,&size,languages,&len); for (const wchar_t *lang=languages;*lang;lang+=wcslen(lang)+1) fwprintf(f,L"language = %s\r\n",lang); fwprintf(f,L"\r\n"); fwprintf(f,L"g_ButtonMove = '%s'\r\n",g_ButtonMove); fwprintf(f,L"g_ButtonDontMove = '%s'\r\n",g_ButtonDontMove); fwprintf(f,L"g_ButtonCopy = '%s'\r\n",g_ButtonCopy); fwprintf(f,L"g_ButtonDontCopy = '%s'\r\n",g_ButtonDontCopy); fwprintf(f,L"g_ButtonCancel = '%s'\r\n",g_ButtonCancel); fwprintf(f,L"\r\n"); fwrite((const wchar_t*)log,log.GetLength(),2,f); fclose(f); } } else DeleteFile(fname); } } } else if (_wcsicmp(title,g_TitleFolder)==0) { // folder UI if (GetSettingBool(L"ReplaceFolderUI")) { CClassicCopyFolder copy; if (copy.Run(hWnd)) { pos->x=pos->y=-20000; pos->flags&=~(SWP_SHOWWINDOW|SWP_NOMOVE); } } } else { // look for progress bar if (GetSettingBool(L"EnableMore")) { HWND progress=FindChildWindow(hWnd,PROGRESS_CLASS); if (progress) { bool bDef; int delay=GetSettingInt(L"MoreProgressDelay",bDef); if (bDef) { delay=0; if (GetWinVersion()>=WIN_VER_WIN7) { BOOL comp; if (SUCCEEDED(DwmIsCompositionEnabled(&comp)) && comp) delay=500; } } SetTimer(hWnd,'CLEX',delay,NULL); return DefSubclassProc(hWnd,uMsg,wParam,lParam); } } } LRESULT res=DefSubclassProc(hWnd,uMsg,wParam,lParam); RemoveWindowSubclass(hWnd,WindowProc,uIdSubclass); return res; } } if (uMsg==WM_TIMER && wParam=='CLEX') { KillTimer(hWnd,wParam); CComPtr<IAccessible> pAcc; HRESULT h=AccessibleObjectFromWindow(hWnd,OBJID_WINDOW,IID_IAccessible,(void**)&pAcc); if (SUCCEEDED(h) && pAcc) { CComPtr<IAccessible> pMore=FindMoreButton(pAcc); if (pMore) pMore->accDoDefaultAction(CComVariant(CHILDID_SELF)); } LRESULT res=DefSubclassProc(hWnd,uMsg,wParam,lParam); RemoveWindowSubclass(hWnd,WindowProc,uIdSubclass); return res; } return DefSubclassProc(hWnd,uMsg,wParam,lParam); }
INT_PTR CALLBACK CClassicCopyFile::DialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) { if (uMsg==WM_INITDIALOG) { SetWindowText(hwndDlg,FindTranslation(L"Copy.Title",L"Confirm File Replace")); CClassicCopyFile *pThis=(CClassicCopyFile*)lParam; wchar_t text[_MAX_PATH*2]; if (pThis->m_bSystem) { Sprintf(text,_countof(text),FindTranslation(L"Copy.SubtitleSys",L"This folder already contains a system file named '%s'."),pThis->m_FileName); if (GetSettingInt(L"OverwriteAlertLevel")>=1) PlaySound(L".Default",NULL,SND_APPLICATION|SND_ALIAS|SND_ASYNC|SND_NODEFAULT|SND_SYSTEM); } else if (pThis->m_bReadOnly) { Sprintf(text,_countof(text),FindTranslation(L"Copy.SubtitleRO",L"This folder already contains a read-only file named '%s'."),pThis->m_FileName); if (GetSettingInt(L"OverwriteAlertLevel")>=2) PlaySound(L".Default",NULL,SND_APPLICATION|SND_ALIAS|SND_ASYNC|SND_NODEFAULT|SND_SYSTEM); } else Sprintf(text,_countof(text),FindTranslation(L"Copy.Subtitle",L"This folder already contains a file named '%s'."),pThis->m_FileName); SetDlgItemText(hwndDlg,IDC_STATICFNAME,text); // load icon for file conflict (146) from Shell32.dll HMODULE hShell32=GetModuleHandle(L"Shell32.dll"); pThis->m_Icon=LoadIcon(hShell32,MAKEINTRESOURCE(146)); if (pThis->m_Icon) SendDlgItemMessage(hwndDlg,IDC_STATICICON1,STM_SETICON,(LPARAM)pThis->m_Icon,0); // set the localized text SetDlgItemText(hwndDlg,IDC_STATICPROMPT1,FindTranslation(L"Copy.Prompt1",L"Do you want to replace the existing file:")); SetDlgItemText(hwndDlg,IDC_STATICDSTSIZE,pThis->m_DstSize); SetDlgItemText(hwndDlg,IDC_STATICDSTTIME,pThis->m_DstTime); SetDlgItemText(hwndDlg,IDC_STATICPROMPT2,FindTranslation(L"Copy.Prompt2",L"with this one?")); SendDlgItemMessage(hwndDlg,IDC_STATICDSTICON,STM_SETICON,(LPARAM)pThis->m_DstIcon,0); SetDlgItemText(hwndDlg,IDC_STATICSRCSIZE,pThis->m_SrcSize); SetDlgItemText(hwndDlg,IDC_STATICSRCTIME,pThis->m_SrcTime); SendDlgItemMessage(hwndDlg,IDC_STATICSRCICON,STM_SETICON,(LPARAM)pThis->m_SrcIcon,0); SetDlgItemText(hwndDlg,IDOK,FindTranslation(L"Copy.Yes",L"&Yes")); SetDlgItemText(hwndDlg,IDNO,FindTranslation(L"Copy.No",L"&No")); if (GetDlgItem(hwndDlg,IDYES)) SetDlgItemText(hwndDlg,IDYES,FindTranslation(L"Copy.YesAll",L"Yes to &All")); if (GetDlgItem(hwndDlg,IDCANCEL)) SetDlgItemText(hwndDlg,IDCANCEL,FindTranslation(L"Copy.Cancel",L"Cancel")); Sprintf(text,_countof(text),L"<a>%s</a>",FindTranslation(L"Copy.More",L"&More...")); SetDlgItemText(hwndDlg,IDC_LINKMORE,text); PostMessage(hwndDlg,WM_BRINGFOREGROUND,0,0); return TRUE; } if (uMsg==WM_BRINGFOREGROUND) { // bring window to front (sometimes on Windows7 it shows up behind Explorer) SetForegroundWindow(hwndDlg); return TRUE; } if (uMsg==WM_COMMAND && (wParam==IDOK || wParam==IDYES || wParam==IDNO || wParam==IDCANCEL)) { EndDialog(hwndDlg,wParam); return TRUE; } if (uMsg==WM_NOTIFY) { NMHDR *pHdr=(NMHDR*)lParam; if (pHdr->idFrom==IDC_LINKMORE && (pHdr->code==NM_CLICK || pHdr->code==NM_RETURN)) { EndDialog(hwndDlg,IDC_LINKMORE); return TRUE; } } return FALSE; }