📄 page2.cpp
字号:
// Page2.cpp : implementation file
//
#include "stdafx.h"
#include "Page.h"
#include "Page2.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPage2 property page
IMPLEMENT_DYNCREATE(CPage2, CPropertyPage)
CPage2::CPage2() : CPropertyPage(CPage2::IDD)
{
//{{AFX_DATA_INIT(CPage2)
m_check_minimize =(::GetPrivateProfileInt("Settings","bMinimized",0,".\\Settings.ini")==0 ?false:true);
m_bTopMost = (::GetPrivateProfileInt("Settings","bTopMost",1,".\\Settings.ini")==0? false:true);
//}}AFX_DATA_INIT
}
CPage2::~CPage2()
{
}
void CPage2::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPage2)
DDX_Control(pDX, IDC_HOTKEY1, m_hotkey);
DDX_Check(pDX, IDC_CHECK_MINIMIZE, m_check_minimize);
DDX_Check(pDX, IDC_CHECK_TOPMOST, m_bTopMost);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPage2, CPropertyPage)
//{{AFX_MSG_MAP(CPage2)
ON_BN_CLICKED(IDC_CHECK_TOPMOST, OnCheckTopmost)
ON_BN_CLICKED(IDC_CHECK_MINIMIZE, OnCheckMinimize)
ON_WM_LBUTTONDOWN()
ON_BN_CLICKED(IDC_SAVE, OnSave)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
void CPage2::OnCheckTopmost()
{
UpdateData(true);
if(m_bTopMost)
{
AfxGetMainWnd()->SetWindowPos(&CWnd::wndTopMost,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE);
m_bTopMost=true;
}
else
{
AfxGetMainWnd()->SetWindowPos(&CWnd::wndNoTopMost ,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE);
m_bTopMost=false;
}
::WritePrivateProfileString("Settings","bTopMost",m_bTopMost ? "1":"0",".\\Settings.ini");
}
void CPage2::OnCheckMinimize()
{
UpdateData(true);
::WritePrivateProfileString("Settings","bMinimized",m_check_minimize? "1":"0",".\\Settings.ini");
}
void CPage2::OnLButtonDown(UINT nFlags, CPoint point)
{
AfxGetMainWnd()->SendMessage(WM_NCLBUTTONDOWN,HTCAPTION,0);
CPropertyPage::OnLButtonDown(nFlags, point);
}
void CPage2::OnSave()
{
UpdateData(TRUE);
WORD virtualKey, systemKey;
m_hotkey.GetHotKey(virtualKey, systemKey);
CString strVirtualKey,strSystemKey;
strVirtualKey.Format("%d",virtualKey);
strSystemKey.Format("%d",systemKey);
::WritePrivateProfileString("HotKey","HotkeyVK",strVirtualKey,".\\Settings.ini");
::WritePrivateProfileString("HotKey","HotkeySystem",strSystemKey,".\\Settings.ini");
UINT fsModifiers = 0;
if (systemKey & HOTKEYF_ALT)
{
fsModifiers |= MOD_ALT;
}
if (systemKey & HOTKEYF_CONTROL)
{
fsModifiers |= MOD_CONTROL;
}
if (systemKey & HOTKEYF_SHIFT)
{
fsModifiers |= MOD_SHIFT;
}
RegisterHotKey(AfxGetMainWnd()->m_hWnd, 400, fsModifiers, virtualKey);
}
BOOL CPage2::OnInitDialog()
{
CPropertyPage::OnInitDialog();
WORD virtualKey=::GetPrivateProfileInt("HotKey","HotkeyVK",0,".\\Settings.ini");
WORD systemKey=::GetPrivateProfileInt("HotKey","HotkeySystem",0,".\\Settings.ini");
m_hotkey.SetHotKey(virtualKey, systemKey);
UpdateData(false);
// 添加消息提示
{
m_tooltip.Create(this);
m_tooltip.SetDelayTime(100);
m_tooltip.Activate(TRUE);
m_tooltip.AddTool(GetDlgItem(IDC_CHECK_TOPMOST),"设置窗体是否总在最前面");
m_tooltip.AddTool(GetDlgItem(IDC_CHECK_MINIMIZE),"启动时最小化就是隐藏窗体到任务栏通知区");
m_tooltip.AddTool(GetDlgItem(IDC_HOTKEY1),"设置热键,用于显示和隐藏窗体");
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CPage2::PreTranslateMessage(MSG* pMsg)
{
CToolTipCtrl m_tooltip;
return CPropertyPage::PreTranslateMessage(pMsg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -