?? exmisdlg.cpp
字號:
// ExMISDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ExMIS.h"
#include "ExMISDlg.h"
//添加的
#include "LoginDlg.h"
#include "DataDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
//狀態欄,字符串
static UINT indicators[] =
{
IDS_STATUS_DATA, //添加的自定義自符串
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
IDS_STATUS_SPACE, //加空格
};
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); //創建圖像列表框,32色,48X48象素
m_ToolBar.EnableAutomation();
m_ToolBar.Create(WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,IDR_TOOLBAR);
//向IMAGELIST對象添加資源圖標
for(i=IDI_ICON1;i<=IDI_ICON8;i++)
{
m_ImageList.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(i)));
}
m_ToolBar.SetImageList(&m_ImageList);
//如果此處循環錯誤則不能正常顯示文字
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);
//為第一個字符再加一個'\0',用于向工具欄里加字符串
nStringLength=string.GetLength()+1;
pString=string.GetBufferSetLength(nStringLength);
button[i].iString=m_ToolBar.AddStrings(pString);
string.ReleaseBuffer();
}
//將工具欄的命令ID與菜單綁定
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;
//添加分隔條,應該從后向前添加,這樣不用考慮添加后的影響
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); //更改風格
//*狀態欄
//獲取客戶區大小
CRect rect;
GetClientRect(rect);
//定義狀態欄
m_wndStatusBar.Create(this);
m_wndStatusBar.SetIndicators(indicators,sizeof(indicators)/sizeof(UINT));
//在底部顯示狀態欄
m_wndStatusBar.MoveWindow(0,rect.bottom-20,rect.right,20);
m_wndStatusBar.SetPaneStyle(2,SBPS_STRETCH);
//調登錄對話框
OnMenuitemRelogin();
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::OnMenuitemRelogin()
{
// TODO: Add your command handler code here
//打開登錄窗口
CLoginDlg dlg;
dlg.DoModal();
//將登錄時選擇的數據庫類型傳到主窗體
m_pRS.m_strDBType=dlg.m_pRS.m_strDBType;
}
void CExMISDlg::OnMenuitemData()
{
// TODO: Add your command handler code here
//打開數據管理窗口
CDataDlg dlg;
//將數據庫類型傳到數據管理窗體
dlg.m_pRS.m_strDBType=m_pRS.m_strDBType;
dlg.DoModal();
}
void CExMISDlg::OnMenuitemCal()
{
// TODO: Add your command handler code here
AfxMessageBox("計算器");
}
void CExMISDlg::OnMenuitemNotepad()
{
// TODO: Add your command handler code here
AfxMessageBox("NOTEPAD");
}
void CExMISDlg::OnMenuitemStat()
{
// TODO: Add your command handler code here
AfxMessageBox("STAT");
}
void CExMISDlg::OnMenuitemUser()
{
// TODO: Add your command handler code here
AfxMessageBox("USER");
}
void CExMISDlg::OnMenuitemHelp()
{
// TODO: Add your command handler code here
AfxMessageBox("help");
}
void CExMISDlg::OnMenuitemQuit()
{
// TODO: Add your command handler code here
AfxMessageBox("QUIT");
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -