?? exmisdlg.cpp
字號(hào):
// ExMISDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ExMIS.h"
#include "ExMISDlg.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()
/////////////////////////////////////////////////////////////////////////////
// CExMISDlg dialog
CExMISDlg::CExMISDlg(CWnd* pParent /*=NULL*/)
: CDialog(CExMISDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CExMISDlg)
// 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 CExMISDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CExMISDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CExMISDlg, CDialog)
//{{AFX_MSG_MAP(CExMISDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_COMMAND(ID_MENUITEM_CAL, OnMenuitemCal)
ON_COMMAND(ID_MENUITEM_DATA, OnMenuitemData)
ON_COMMAND(ID_MENUITEM_HELP, OnMenuitemHelp)
ON_COMMAND(ID_MENUITEM_NOTEPAD, OnMenuitemNotepad)
ON_COMMAND(ID_MENUITEM_QUIT, OnMenuitemQuit)
ON_COMMAND(ID_MENUITEM_RELOGIN, OnMenuitemRelogin)
ON_COMMAND(ID_MENUITEM_STAT, OnMenuitemStat)
ON_COMMAND(ID_MENUITEM_USER, OnMenuitemUser)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExMISDlg message handlers
BOOL CExMISDlg::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
//添加3: 工具欄
TBBUTTON button[10];
int i=0,nStringLength;
CString string;
TCHAR * pString;
m_ImageList.Create(42,42,ILC_COLOR32|ILC_MASK,0,0); //創(chuàng)建圖像列表框,32色,48X48象素
m_ToolBar.EnableAutomation();
m_ToolBar.Create(WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,IDR_TOOLBAR);
//向IMAGELIST對(duì)象添加資源圖標(biāo)
for(i=IDI_ICON1;i<=IDI_ICON8;i++)
{
m_ImageList.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(i)));
}
m_ToolBar.SetImageList(&m_ImageList);
//如果此處循環(huán)錯(cuò)誤則不能正常顯示文字
for(i=0;i<8;i++)
{
button[i].dwData=0;
button[i].fsState=TBSTATE_ENABLED;
button[i].fsStyle=TBSTYLE_BUTTON;
button[i].iBitmap=i;
string.LoadString(i+IDS_STRING102);
//為第一個(gè)字符再加一個(gè)'\0',用于向工具欄里加字符串
nStringLength=string.GetLength()+1;
pString=string.GetBufferSetLength(nStringLength);
button[i].iString=m_ToolBar.AddStrings(pString);
string.ReleaseBuffer();
}
//將工具欄的命令I(lǐng)D與菜單綁定
button[0].idCommand=ID_MENUITEM_RELOGIN;
button[1].idCommand=ID_MENUITEM_DATA;
button[2].idCommand=ID_MENUITEM_STAT;
button[3].idCommand=ID_MENUITEM_USER;
button[4].idCommand=ID_MENUITEM_NOTEPAD;
button[5].idCommand=ID_MENUITEM_CAL;
button[6].idCommand=ID_MENUITEM_HELP;
button[7].idCommand=ID_MENUITEM_QUIT;
m_ToolBar.AddButtons(8,button);
button[0].fsStyle=TBSTYLE_SEP;
//添加分隔條,應(yīng)該從后向前添加
m_ToolBar.InsertButton(7,&button[0]);
m_ToolBar.InsertButton(6,&button[0]);
m_ToolBar.InsertButton(4,&button[0]);
m_ToolBar.InsertButton(1,&button[0]);
m_ToolBar.AutoSize;
m_ToolBar.SetStyle(TBSTYLE_FLAT|CCS_TOP); //更改風(fēng)格
//*狀態(tài)欄
m_StatusBar.EnableAutomation();
m_StatusBar.Create(WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,IDR_STATUSBAR);
int xpos=::GetSystemMetrics(SM_CXSCREEN);
int width[3];
width[1]=xpos*0.2;
width[2]=xpos*0.67;
width[3]=xpos;
CString sText;
CString OP="MRKJ";
sText="操作員:【"+OP+"】";
m_StatusBar.SetParts(3,&width[1]);
m_StatusBar.SetText("華東理工大學(xué)出版社",0,SBT_NOBORDERS);
m_StatusBar.SetText(sText,2,SBT_NOBORDERS);
return TRUE; // return TRUE unless you set the focus to a control
}
void CExMISDlg::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 CExMISDlg::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 CExMISDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CExMISDlg::OnMenuitemCal()
{
// TODO: Add your command handler code here
AfxMessageBox("計(jì)算器");
}
void CExMISDlg::OnMenuitemData()
{
// TODO: Add your command handler code here
AfxMessageBox("DATA");
}
void CExMISDlg::OnMenuitemHelp()
{
// TODO: Add your command handler code here
AfxMessageBox("help");
}
void CExMISDlg::OnMenuitemNotepad()
{
// TODO: Add your command handler code here
AfxMessageBox("NOTEPAD");
}
void CExMISDlg::OnMenuitemQuit()
{
// TODO: Add your command handler code here
AfxMessageBox("QUIT");
}
void CExMISDlg::OnMenuitemRelogin()
{
// TODO: Add your command handler code here
AfxMessageBox("RELOGIN");
}
void CExMISDlg::OnMenuitemStat()
{
// TODO: Add your command handler code here
AfxMessageBox("STAT");
}
void CExMISDlg::OnMenuitemUser()
{
// TODO: Add your command handler code here
AfxMessageBox("USER");
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -