📄 dialogdlg.cpp
字号:
// dialogDlg.cpp : implementation file
//
#include "stdafx.h"
#include "dialog.h"
#include "dialogDlg.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()
/////////////////////////////////////////////////////////////////////////////
// CDialogDlg dialog
CDialogDlg::CDialogDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDialogDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDialogDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_bShow=TRUE;
}
void CDialogDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialogDlg)
DDX_Control(pDX, IDC_FIND, m_cbFind);
DDX_Control(pDX, IDC_STATUSBAR, m_StatusBar);
DDX_Control(pDX, IDC_VIEW, m_View);
DDX_Control(pDX, IDC_HIDE, m_btnHide);
DDX_Control(pDX, IDC_TOOLBAR, m_ToolBar);
DDX_Control(pDX, IDC_PANEL, m_Panel);
DDX_Control(pDX, IDC_HELPME, m_btnHelp);
DDX_Control(pDX, IDC_BACK, m_btnBack);
DDX_Control(pDX, IDC_MENU, m_btnMenu);
DDX_Control(pDX, IDC_FORE, m_btnFore);
DDX_Control(pDX, IDC_DROPDOWN, m_btnDropDown);
DDX_Control(pDX, IDC_GO, m_btnGo);
DDX_Control(pDX, IDC_MAINTITLE, m_MainTitle);
DDX_Control(pDX, IDC_TAB, m_Tab);
DDX_Control(pDX, IDC_DOWN, m_btnDown);
DDX_Control(pDX, IDC_TITLE, m_Title);
DDX_Control(pDX, IDC_UP, m_btnUp);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialogDlg, CDialog)
//{{AFX_MSG_MAP(CDialogDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_SIZE()
ON_BN_CLICKED(IDC_HIDE, OnHide)
ON_BN_CLICKED(ID_SCHEME, OnScheme)
ON_WM_GETMINMAXINFO()
ON_COMMAND(ID_SCHEME_BLUE, OnSchemeBlue)
ON_COMMAND(ID_SCHEME_SLIVER, OnSchemeSliver)
ON_COMMAND(ID_SCHEME_DEFAULT, OnSchemeDefault)
ON_COMMAND(ID_SCHEME_GREEN, OnSchemeGreen)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialogDlg message handlers
BOOL CDialogDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//缺省设置
m_nMenuID=ID_SCHEME_DEFAULT;
LoadSkin("Themes\\DefaultTheme\\DefaultTheme.ini");
// 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
return TRUE; // return TRUE unless you set the focus to a control
}
void CDialogDlg::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 CDialogDlg::OnPaint()
{
CPaintDC dc(this);
if (IsIconic())
{
// 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
{
CRect rc;
GetClientRect(&rc);
m_bmpBottomBorder.ExtendDraw(&dc,CRect(0,rc.Height()-3 ,rc.Width(),rc.Height()),50,0);
m_bmpRightBorder.ExtendDraw(&dc,&CRect(rc.Width()-3 ,0,rc.Width(),rc.Height()),0,50);
rc.DeflateRect(3,3);
//主窗口背景
dc.FillSolidRect(&rc,m_MainWindowBackGround);
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CDialogDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CDialogDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
CRect rc;
//Panel
m_Panel.GetClientRect(rc);
m_Panel.SetWindowPos(NULL,0,40,187,cy-40-3, NULL);
m_Tab.SetWindowPos(NULL,0,10,10,10, SWP_NOSIZE);
m_Title.SetWindowPos(NULL,m_LeftTitleBarPos.cx ,m_LeftTitleBarPos.cy,154,26, NULL);
rc.top =176;
m_Panel.RedrawWindow(rc,NULL);
//maintitle
m_MainTitle.SetWindowPos(NULL,0,0,cx,40, NULL);
m_btnGo.SetWindowPos(NULL,cx+m_ButtonGoPos.cx ,m_ButtonGoPos.cy ,0,0, SWP_NOSIZE);
m_btnDropDown.SetWindowPos(NULL,cx+m_ButtonGoDropDownPos.cx ,m_ButtonGoDropDownPos.cy ,0,0, SWP_NOSIZE);
m_btnHelp.SetWindowPos(NULL,cx+m_ButtonHelpMePos.cx ,m_ButtonHelpMePos.cy,0,0, SWP_NOSIZE);
m_btnBack.SetWindowPos(NULL,cx+m_ButtonBackwardPos.cx ,m_ButtonBackwardPos.cy,0,0, SWP_NOSIZE);
m_btnFore.SetWindowPos(NULL,cx+m_ButtonForewardPos.cx ,m_ButtonForewardPos.cy,0,0, SWP_NOSIZE);
m_btnMenu.SetWindowPos(NULL,cx+m_ButtonMenusPos.cx ,m_ButtonMenusPos.cy,0,0, SWP_NOSIZE);
m_cbFind.ShowWindow(SW_HIDE);
m_cbFind.SetWindowPos(NULL,77 ,5,cx+m_ButtonGoPos.cx-80,15, NULL);
m_cbFind.ShowWindow(SW_SHOW);
m_MainTitle.RedrawWindow();
SetViewSize(cx, cy);
}
void CDialogDlg::OnHide()
{
CRect rc;
GetClientRect(rc);
// TODO: Add your control notification handler code here
CEnBitmap bmp;
if (m_bShow)
{
m_Panel.ShowWindow(SW_HIDE) ;
m_bShow=FALSE;
bmp.LoadImage(m_strPathName + "\\" +"ShowLeft.bmp");
}
else
{
m_Panel.ShowWindow(SW_SHOW) ;
m_bShow=TRUE;
bmp.LoadImage(m_strPathName + "\\" +"HideLeft.bmp");
}
m_btnHide.SetBitmap((HBITMAP)bmp.m_hObject);
SetViewSize(rc.Width(),rc.Height() );
}
void CDialogDlg::LoadSkin(CString strFileName)
{
CRect rc;
GetClientRect(&rc);
int cx=rc.Width();
int cy=rc.Height();
m_strPathName=GetPathName(strFileName);
static const char *ThemeMetrics = "ThemeMetrics";
static const char *ThemeColors = "ThemeColors";
static const char *ThemeColor = "ThemeColor";
char buf[MAX_PATH];
GetPrivateProfileString(ThemeColors,"MainWindowBackGround","",buf,MAX_PATH,strFileName);
m_MainWindowBackGround=GetColor(buf);
GetPrivateProfileString(ThemeColors,"ExplainViewBackGround","",buf,MAX_PATH,strFileName);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -