📄 mainfrm.h
字号:
pMMI->ptMinTrackSize.x = FRAME_MIN_WIDTH;
pMMI->ptMinTrackSize.y = FRAME_MIN_HEIGHT;
return 0;
}
LRESULT OnPopupManager(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
ShowWindow(SW_SHOWNORMAL);
SetForegroundWindow(m_hWnd);
return 0;
}
LRESULT OnDisable(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
g_Global.m_bDisable = !g_Global.m_bDisable;
UISetCheck(ID_DISABLE, g_Global.m_bDisable);
InstallTrayIcon(TRUE, !g_Global.m_bDisable);
//modify registry
CString sCommand;
sCommand.Format(_T("regsvr32 /s %s \"%sSHBHO.dll\""),
g_Global.m_bDisable ? _T("/u") : _T(""), g_Global.m_sWorkDir);
STARTUPINFO startupInfo;
PROCESS_INFORMATION processInfo;
memset(&startupInfo,0,sizeof(STARTUPINFO));
startupInfo.cb = sizeof(STARTUPINFO);
if (CreateProcess(NULL, (LPTSTR)(LPCTSTR)sCommand, NULL, NULL,
FALSE, 0, NULL, NULL, &startupInfo, &processInfo))
{
CloseHandle(processInfo.hThread);
CloseHandle(processInfo.hProcess);
}
return 0;
}
LRESULT OnConfigure(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
CConfigSheet sheet;
sheet.m_GeneralPage.m_dwIeWindowSettings = g_Global.m_dwIeWindowSettings;
sheet.m_GeneralPage.m_bAutorun = g_Global.m_bAutorun;
sheet.m_GeneralPage.m_bEnableSound = g_Global.m_bEnableSound;
sheet.m_GeneralPage.m_nKeyDisable = g_Global.m_nKeyDisable;
sheet.m_GeneralPage.m_nKeyHideIE = g_Global.m_nKeyHideIE;
sheet.m_GeneralPage.m_nKeyShowIE = g_Global.m_nKeyShowIE;
sheet.m_FilterPage.m_lWindowSizeThreshold = g_Global.m_lWindowSizeThreshold;
sheet.m_FilterPage.m_dwFilterSettings = g_Global.m_dwFilterSettings;
sheet.m_ClearPage.m_bClearAtExit = g_Global.m_bClearAtExit;
sheet.m_ClearPage.m_dwClearSettings = g_Global.m_dwClearSettings;
if (sheet.DoModal(GetDesktopWindow()) == IDOK)
{
InterlockedExchange((long*)(&g_Global.m_dwIeWindowSettings),
sheet.m_GeneralPage.m_dwIeWindowSettings);
InterlockedExchange((long*)(&g_Global.m_dwFilterSettings),
sheet.m_FilterPage.m_dwFilterSettings);
InterlockedExchange((long*)(&g_Global.m_lWindowSizeThreshold),
sheet.m_FilterPage.m_lWindowSizeThreshold);
g_Global.m_bAutorun = sheet.m_GeneralPage.m_bAutorun;
g_Global.m_bEnableSound = sheet.m_GeneralPage.m_bEnableSound;
g_Global.m_bClearAtExit = sheet.m_ClearPage.m_bClearAtExit;
g_Global.m_dwClearSettings = sheet.m_ClearPage.m_dwClearSettings;
g_Global.UpdateAutorun();
CString sMsg;
if (g_Global.m_nKeyDisable != sheet.m_GeneralPage.m_nKeyDisable)
{
UnregisterHotKey(m_hWnd, HOTKEY_DISABLE);
g_Global.m_nKeyDisable = sheet.m_GeneralPage.m_nKeyDisable;
if (! RegisterHotKey(m_hWnd, HOTKEY_DISABLE, MOD_WIN,
g_Global.m_nKeyDisable))
{
sMsg.LoadString(IDS_REG_DISABLE_KEY_FAILED);
::MessageBox(NULL, sMsg, APP_NAME, MB_OK | MB_ICONERROR);
}
}
if (g_Global.m_nKeyHideIE != sheet.m_GeneralPage.m_nKeyHideIE)
{
UnregisterHotKey(m_hWnd, HOTKEY_HIDE_IE);
g_Global.m_nKeyHideIE = sheet.m_GeneralPage.m_nKeyHideIE;
if (! RegisterHotKey(m_hWnd, HOTKEY_HIDE_IE, MOD_WIN,
g_Global.m_nKeyHideIE))
{
sMsg.LoadString(IDS_REG_HIDE_IE_KEY_FAILED);
::MessageBox(NULL, sMsg, APP_NAME, MB_OK | MB_ICONERROR);
}
}
if (g_Global.m_nKeyShowIE != sheet.m_GeneralPage.m_nKeyShowIE)
{
UnregisterHotKey(m_hWnd, HOTKEY_SHOW_IE);
g_Global.m_nKeyShowIE = sheet.m_GeneralPage.m_nKeyShowIE;
if (! RegisterHotKey(m_hWnd, HOTKEY_SHOW_IE, MOD_WIN | MOD_SHIFT,
g_Global.m_nKeyShowIE))
{
sMsg.LoadString(IDS_REG_SHOW_IE_KEY_FAILED);
::MessageBox(NULL, sMsg, APP_NAME, MB_OK | MB_ICONERROR);
}
}
}
return 0;
}
LRESULT OnClearHistory(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
g_Global.ClearHistory();
CString sMsg;
sMsg.LoadString(IDS_CLEAR_COMPLETE);
::MessageBox(NULL, sMsg, APP_NAME, MB_OK | MB_ICONINFORMATION);
return 0;
}
LRESULT OnHelp(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
CString sCommand;
sCommand.Format(_T("Notepad \"%sReadme.txt\""), g_Global.m_sWorkDir);
STARTUPINFO startupInfo;
PROCESS_INFORMATION processInfo;
memset(&startupInfo,0,sizeof(STARTUPINFO));
startupInfo.cb = sizeof(STARTUPINFO);
if (CreateProcess(NULL, (LPTSTR)(LPCTSTR)sCommand, NULL, NULL,
FALSE, 0, NULL, NULL, &startupInfo, &processInfo))
{
CloseHandle(processInfo.hThread);
CloseHandle(processInfo.hProcess);
}
return 0;
}
LRESULT OnHotKey(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if (wParam == HOTKEY_DISABLE)
{
BOOL bTemp;
OnDisable(0, 0, NULL, bTemp);
}
else if (wParam == HOTKEY_HIDE_IE)
{
EnumWindows(HideIeWindowsProc, TRUE);
}
else if (wParam == HOTKEY_SHOW_IE)
{
EnumWindows(HideIeWindowsProc, FALSE);
}
return 0;
}
LRESULT OnHideIE(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
EnumWindows(HideIeWindowsProc, TRUE);
return 0;
}
LRESULT OnShowIE(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
EnumWindows(HideIeWindowsProc, FALSE);
return 0;
}
void LoadWindowPos(LPCTSTR pszFilePath)
{
CRect rcWindowPos;
rcWindowPos.left = GetPrivateProfileInt(
APP_NAME, _T("Left"), 0, pszFilePath);
rcWindowPos.top = GetPrivateProfileInt(
APP_NAME, _T("Top"), 0, pszFilePath);
rcWindowPos.right = GetPrivateProfileInt(
APP_NAME, _T("Right"), 0, pszFilePath);
rcWindowPos.bottom = GetPrivateProfileInt(
APP_NAME, _T("Bottom"), 0, pszFilePath);
int cxScreen = GetSystemMetrics(SM_CXSCREEN);
int cyScreen = GetSystemMetrics(SM_CYSCREEN);
if (!(rcWindowPos.left >= 0 && rcWindowPos.left < cxScreen &&
rcWindowPos.top >= 0 && rcWindowPos.top < cyScreen &&
rcWindowPos.right > 0 && rcWindowPos.right <= cxScreen &&
rcWindowPos.bottom > 0 && rcWindowPos.bottom <= cyScreen))
{
rcWindowPos.left = (cxScreen - FRAME_MIN_WIDTH) / 2;
rcWindowPos.top = (cyScreen - FRAME_MIN_HEIGHT) / 2;
rcWindowPos.right = rcWindowPos.left + FRAME_MIN_WIDTH;
rcWindowPos.bottom = rcWindowPos.top + FRAME_MIN_HEIGHT;
}
::SetWindowPos(m_hWnd, HWND_TOP,
rcWindowPos.left, rcWindowPos.top,
rcWindowPos.right - rcWindowPos.left,
rcWindowPos.bottom - rcWindowPos.top, SWP_HIDEWINDOW);
}
void SaveWindowPos(LPCTSTR pszFilePath)
{
WINDOWPLACEMENT wndpl;
wndpl.length = sizeof(WINDOWPLACEMENT);
::GetWindowPlacement(m_hWnd, &wndpl);
CString sTemp;
sTemp.Format(_T("%ld"), wndpl.rcNormalPosition.left);
WritePrivateProfileString(APP_NAME, _T("Left"), sTemp, pszFilePath);
sTemp.Format(_T("%ld"), wndpl.rcNormalPosition.top);
WritePrivateProfileString(APP_NAME, _T("Top"), sTemp, pszFilePath);
sTemp.Format(_T("%ld"), wndpl.rcNormalPosition.right);
WritePrivateProfileString(APP_NAME, _T("Right"), sTemp, pszFilePath);
sTemp.Format(_T("%ld"), wndpl.rcNormalPosition.bottom);
WritePrivateProfileString(APP_NAME, _T("Bottom"), sTemp, pszFilePath);
}
LRESULT OnPopupAdd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
m_view.m_PopupManagerTab.AddPopupFilter(NULL);
return 0;
}
LRESULT OnPopupImport(WORD /*wNotifyCode*/, WORD /*wID*/, HWND hWndCtl, BOOL& /*bHandled*/)
{
CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST,
_T("Popup Filter Files (*.flt)\0*.flt\0"), m_hWnd);
if(dlg.DoModal() == IDOK)
{
CString sErrorMsg;
if (g_Global.ReadFilter(dlg.m_szFileName, &sErrorMsg))
{
m_view.m_PopupManagerTab.m_TitleDlg.FillFilterList();
m_view.m_PopupManagerTab.m_UrlDlg.FillFilterList();
sErrorMsg.LoadString(IDS_IMPORT_SUCCESS);
::MessageBox(NULL, sErrorMsg, NULL, MB_OK | MB_ICONINFORMATION);
}
else
{
::MessageBox(NULL, sErrorMsg, NULL, MB_OK | MB_ICONERROR);
}
}
return 0;
}
LRESULT OnPopupExport(WORD /*wNotifyCode*/, WORD /*wID*/, HWND hWndCtl, BOOL& /*bHandled*/)
{
CFileDialog dlg(FALSE, _T("flt"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
_T("Popup Filter Files (*.flt)\0*.flt\0"), m_hWnd);
if(dlg.DoModal() == IDOK)
{
CString sErrorMsg;
if (g_Global.WriteFilter(dlg.m_szFileName, &sErrorMsg))
{
sErrorMsg.LoadString(IDS_EXPORT_SUCCESS);
::MessageBox(NULL, sErrorMsg, NULL, MB_OK | MB_ICONINFORMATION);
}
else
{
::MessageBox(NULL, sErrorMsg, NULL, MB_OK | MB_ICONERROR);
}
}
return 0;
}
LRESULT OnPopupSaveLog(WORD /*wNotifyCode*/, WORD /*wID*/, HWND hWndCtl, BOOL& /*bHandled*/)
{
CFileDialog dlg(FALSE, _T("txt"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
_T("Log Files (*.txt)\0*.txt\0"), m_hWnd);
if(dlg.DoModal() == IDOK)
{
CString sErrorMsg;
if (! g_Global.SaveLog(dlg.m_szFileName, &sErrorMsg))
{
::MessageBox(NULL, sErrorMsg, NULL, MB_OK | MB_ICONERROR);
}
}
return 0;
}
void InstallTrayIcon(BOOL bMidify, BOOL bEnable)
{
m_nid.cbSize = sizeof(NOTIFYICONDATA);
m_nid.hWnd = m_hWnd;
m_nid.uID = IDR_TRAY;
m_nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
m_nid.uCallbackMessage = WM_TRAY_NOTIFY;
m_nid.hIcon = AtlLoadIcon(bEnable ? IDI_TRAY_ENABLE : IDI_TRAY_DISABLE);
_tcscpy(m_nid.szTip, APP_NAME);
Shell_NotifyIcon(bMidify ? NIM_MODIFY : NIM_ADD, &m_nid);
DestroyIcon(m_nid.hIcon);
}
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__941B89B2_0DF4_412B_9374_346CE0B2F788__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -