📄 risingdlg.cpp
字号:
// risingDlg.cpp : implementation file
//
#include "stdafx.h"
#include "rising.h"
#include "risingDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRisingDlg dialog
CRisingDlg::CRisingDlg(CWnd* pParent /*=NULL*/)
: CDialog(CRisingDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CRisingDlg)
// 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 CRisingDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRisingDlg)
DDX_Control(pDX, IDC_TABRISING, m_tab);
//}}AFX_DATA_MAP
DDX_Control(pDX, IDC_BUTTON1, m_btnOperation);
DDX_Control(pDX, IDC_BUTTON2, m_btnView);
DDX_Control(pDX, IDC_BUTTON3, m_btnSet);
DDX_Control(pDX, IDC_BUTTON4, m_btnHelp);
DDX_Control(pDX, IDC_BUTTON5, m_btnMin);
DDX_Control(pDX, IDC_BUTTON6, m_btnClose);
}
BEGIN_MESSAGE_MAP(CRisingDlg, CDialog)
//{{AFX_MSG_MAP(CRisingDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_CLOSE()
ON_NOTIFY(TCN_SELCHANGE, IDC_TABRISING, OnSelchangeTabrising)
ON_WM_LBUTTONDOWN()
ON_WM_NCHITTEST()
ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRisingDlg message handlers
BOOL CRisingDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 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_bmpBackground.LoadBitmap(IDB_BITMAP1);
m_bmpTitleBar.LoadBitmap(IDB_BITMAP8);
m_btnOperation.SetMenu(IDR_MENU1, m_hWnd, TRUE, IDR_TOOLBAR1);
m_btnOperation.DrawTransparent(TRUE);
m_btnOperation.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(255, 255, 255));
m_btnOperation.SetColor(CButtonST::BTNST_COLOR_FG_OUT, RGB(255, 255, 255));
m_btnView.SetMenu(IDR_MENU2, m_hWnd);
m_btnView.DrawTransparent(TRUE);
m_btnView.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(255, 255, 255));
m_btnView.SetColor(CButtonST::BTNST_COLOR_FG_OUT, RGB(255, 255, 255));
m_btnSet.SetMenu(IDR_MENU3, m_hWnd);
m_btnSet.DrawTransparent(TRUE);
m_btnSet.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(255, 255, 255));
m_btnSet.SetColor(CButtonST::BTNST_COLOR_FG_OUT, RGB(255, 255, 255));
m_btnHelp.SetMenu(IDR_MENU4, m_hWnd);
m_btnHelp.DrawTransparent(TRUE);
m_btnHelp.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(255, 255, 255));
m_btnHelp.SetColor(CButtonST::BTNST_COLOR_FG_OUT, RGB(255, 255, 255));
m_btnMin.DrawTransparent(TRUE);
m_btnMin.SetFlat(TRUE);
m_btnMin.SetBitmaps(IDB_BITMAP10,RGB(0,0,0));
m_btnClose.DrawTransparent(TRUE);
m_btnClose.SetFlat(TRUE);
m_btnClose.SetBitmaps(IDB_BITMAP9,RGB(0,0,0));
m_tab.InsertItem(0, "首页");
m_tab.InsertItem(1, "杀毒");
m_tab.InsertItem(2, "监控");
m_first.Create(IDD_FIRST, GetDlgItem(IDC_TABRISING));
m_kill.Create(IDD_KILL, GetDlgItem(IDC_TABRISING));
m_keepUnder.Create(IDD_KEEPUNDER, GetDlgItem(IDC_TABRISING));
CRect rs;
m_tab.GetClientRect(&rs);
rs.top += 20;
//设置子对话框尺寸并移动到指定位置
m_first.MoveWindow(&rs);
m_kill.MoveWindow(&rs);
m_keepUnder.MoveWindow(&rs);
//分别设置隐藏和显示
m_first.ShowWindow(true);
m_kill.ShowWindow(false);
m_keepUnder.ShowWindow(false);
//设置默认的选项卡
m_tab.SetCurSel(0);
return TRUE; // return TRUE unless you set the focus to a control
}
void CRisingDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// 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 CRisingDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CDC memDC;
memDC.CreateCompatibleDC(&dc); //创建与对话框dc兼容的内存dc
CRect rect;
GetClientRect(&rect);
CBitmap *pbmpOld;
BITMAP bitMap;
m_bmpBackground.GetBitmap(&bitMap);
pbmpOld=memDC.SelectObject(&m_bmpBackground); //将背景位图选入内存dc中
dc.StretchBlt(0,0,rect.Width(),rect.Height(),&memDC,0,0,bitMap.bmWidth,bitMap.bmHeight,SRCCOPY);
memDC.SelectObject(pbmpOld);
//重画标题栏
m_bmpTitleBar.GetBitmap(&bitMap);
pbmpOld=memDC.SelectObject(&m_bmpTitleBar);
dc.StretchBlt(0,0, rect.right-rect.left, 30, &memDC, 0, 0, bitMap.bmWidth,
bitMap.bmHeight,SRCCOPY);
memDC.SelectObject(pbmpOld);
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CRisingDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CRisingDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
//释放菜单句柄
CDialog::OnClose();
}
void CRisingDlg::OnSelchangeTabrising(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CRect r;
m_tab.GetClientRect (&r);
int CurSel = m_tab.GetCurSel();
switch(CurSel)
{
case 0:
m_first.ShowWindow(true);
m_kill.ShowWindow(false);
m_keepUnder.ShowWindow(false);
break;
case 1:
m_first.ShowWindow(false);
m_kill.ShowWindow(true);
m_keepUnder.ShowWindow(false);
break;
case 2:
m_first.ShowWindow(false);
m_kill.ShowWindow(false);
m_keepUnder.ShowWindow(true);
break;
default:
;
}
*pResult = 0;
}
void CRisingDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//SendMessage(WM_NCLBUTTONDOWN,HTCAPTION); 功能同OnNcHitTest
CDialog::OnLButtonDown(nFlags, point);
}
UINT CRisingDlg::OnNcHitTest(CPoint point)
{
UINT nHitTest=CDialog::OnNcHitTest(point);
return (nHitTest==HTCLIENT)? HTCAPTION : nHitTest;
}
void CRisingDlg::OnButton6()
{
// TODO: Add your control notification handler code here
SendMessage(WM_CLOSE);
}
void CRisingDlg::OnButton5()
{
// TODO: Add your control notification handler code here
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -