📄 protel_increasedlg.cpp
字号:
// protel_increaseDlg.cpp : implementation file
//
#include "stdafx.h"
#include "protel_increase.h"
#include "protel_increaseDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define MYWM_NOTIFYICON WM_USER+1
/////////////////////////////////////////////////////////////////////////////
// CProtel_increaseDlg dialog
CProtel_increaseDlg::CProtel_increaseDlg(CWnd* pParent /*=NULL*/)
: CDialog(CProtel_increaseDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CProtel_increaseDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CProtel_increaseDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CProtel_increaseDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CProtel_increaseDlg, CDialog)
//{{AFX_MSG_MAP(CProtel_increaseDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_DESTROY()
ON_BN_CLICKED(IDC_BUTTON_MINIMIZE, OnButtonMinimize)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CProtel_increaseDlg message handlers
BOOL CProtel_increaseDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
m_tnid.cbSize=sizeof(NOTIFYICONDATA); //定义结构的成员变量
m_tnid.hWnd=this->m_hWnd;
m_tnid.uFlags=NIF_MESSAGE|NIF_ICON|NIF_TIP;
m_tnid.uCallbackMessage=MYWM_NOTIFYICON; //用户定义的回调消息
_tcscpy(m_tnid.szTip, _T("Protel Increaser"));
m_tnid.uID=IDR_MAINFRAME;
m_tnid.hIcon=m_hIcon;
if(m_hIcon)::DestroyIcon(m_hIcon);
Shell_NotifyIcon(NIM_ADD,&m_tnid);
PostMessage(WM_SYSCOMMAND,SC_MINIMIZE,0);
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CProtel_increaseDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CProtel_increaseDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CProtel_increaseDlg::OnDestroy()
{
CDialog::OnDestroy();
Shell_NotifyIcon(NIM_DELETE, &m_tnid);
// TODO: Add your message handler code here
}
LRESULT CProtel_increaseDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
static bool IsShowWnd = TRUE;
if((message==WM_SYSCOMMAND)&&(wParam==SC_MINIMIZE)) //如果是系统消息
{
this->ShowWindow(SW_MINIMIZE);
this->ShowWindow(SW_HIDE);
IsShowWnd = FALSE;
return true;
}
else if((message==MYWM_NOTIFYICON)&&((lParam==WM_LBUTTONDOWN)||(lParam==WM_RBUTTONUP))) //如果是用户定义的消息
{
if(!IsShowWnd)
{
this->ShowWindow(SW_SHOW);
this->ShowWindow(SW_NORMAL);
this->SetActiveWindow(); //双击并且出现在最上面
}
else
{
this->ShowWindow(SW_MINIMIZE);
this->ShowWindow(SW_HIDE);
}
IsShowWnd = !IsShowWnd;
return true;
}
return CDialog::WindowProc(message, wParam, lParam);
}
void CProtel_increaseDlg::OnButtonMinimize()
{
PostMessage(WM_SYSCOMMAND,SC_MINIMIZE,0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -