📄 maindlg.cpp
字号:
// MainDlg.cpp : implementation file
//
#include "stdafx.h"
#include "商品库存管理系统.h"
#include "MainDlg.h"
#include "RxGrid.h"
#include "DWare.h"
#include "DClime.h"
#include "DUser.h"
#include "DUnit.h"
#include "DClient.h"
#include "DProvider.h"
#include "DInput.h"
#include "DOutPut.h"
#include "DAdjust.h"
#include "DCheck.h"
#include "DAbate.h"
#include "DAbout.h"
#include "DStore.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern _ConnectionPtr cnn;
extern CString UserName;
/////////////////////////////////////////////////////////////////////////////
// CMainDlg dialog
CMainDlg::CMainDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMainDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMainDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDI_ICON4);
}
void CMainDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMainDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMainDlg, CDialog)
//{{AFX_MSG_MAP(CMainDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_COMMAND(ID_MENUITEM32807, OnMenuitem32807)
ON_COMMAND(ID_MENUITEM32808, OnMenuitem32808)
ON_COMMAND(ID_MENUITEM32817, OnMenuitem32817)
ON_COMMAND(ID_MENUITEM32822, OnMenuitem32822)
ON_COMMAND(ID_MENUITEM32824, OnMenuitem32824)
ON_COMMAND(ID_MENUITEM32825, OnMenuitem32825)
ON_COMMAND(ID_MENUITEM32811, OnMenuitem32811)
ON_COMMAND(ID_MENUITEM32812, OnMenuitem32812)
ON_COMMAND(ID_MENUITEM32813, OnMenuitem32813)
ON_COMMAND(ID_MENUITEM32815, OnMenuitem32815)
ON_COMMAND(ID_MENUITEM32816, OnMenuitem32816)
ON_COMMAND(ID_MENUITEM32823, OnMenuitem32823)
ON_COMMAND(ID_MENUITEM32826, OnMenuitem32826)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMainDlg message handlers
BOOL CMainDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
TBBUTTON button[10];
int i=0,nStringLength;
CString string;
TCHAR * pString;
//建立ImageList对象及ToolBar对象
m_ImageList.Create(32,32,ILC_COLOR32|ILC_MASK,0,0); //创建一个图象列表框
m_ToolBar.EnableAutomation();
m_ToolBar.Create(WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,ID_TOOLBAR);
//向ImageList对象中添加资源图标
UINT Resource[10]={IDI_ICON1,IDI_ICON2,IDI_ICON3,IDI_ICON4,IDI_ICON4,IDI_ICON5,IDI_ICON6,IDI_ICON7,IDI_ICON7,IDI_ICON8};
for(i=0;i<10;i++)
{
m_ImageList.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(Resource[i]))); //向图像列表框中添加图片
}
m_ToolBar.SetImageList(&m_ImageList);
for(i=0;i<10;i++)
{
button[i].dwData=0;
button[i].fsState=TBSTATE_ENABLED;
if(i==4 ||i==8)
button[i].fsStyle=TBSTYLE_SEP ;
else
button[i].fsStyle=TBSTYLE_BUTTON ;
button[i].iBitmap=i;
string.LoadString(i + IDS_STRING1);//装载字符串资源
//为每一个字符串再加一个'\0',用于向工具栏里加字符串
nStringLength= string.GetLength() + 1;
pString = string.GetBufferSetLength(nStringLength);
//pString[nStringLength] = 0;
//返回刚加的字符串的编号
button[i].iString =m_ToolBar.AddStrings(pString);
string.ReleaseBuffer();
}
button[0].idCommand=ID_MENUITEM32807;
button[1].idCommand=ID_MENUITEM32808;
button[3].idCommand=ID_MENUITEM32817;
button[2].idCommand=ID_MENUITEM32822;
button[5].idCommand=ID_MENUITEM32811;
button[6].idCommand=ID_MENUITEM32812;
button[7].idCommand=ID_MENUITEM32813;
button[9].idCommand=ID_MENUITEM32815;
m_ToolBar.AddButtons(10,button);
m_ToolBar.AutoSize();
m_ToolBar.SetStyle(TBSTYLE_FLAT|CCS_TOP);
m_StatusBar.EnableAutomation();
m_StatusBar.Create(WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,ID_STATUSBAR);
CString TipText;
this->GetWindowText(TipText);
TipText=TipText+" 〖当前用户:"+UserName+ "〗";
this->SetWindowText(TipText);
int width[]={150,800};
m_StatusBar.SetParts(2, &width[0]);
m_StatusBar.SetText("长春市明日科技有限公司",0,0);
// m_StatusBar.SetText(StatusText,1,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 CMainDlg::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 CMainDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMainDlg::OnMenuitem32807()
{
CDWare dlg;
dlg.DoModal();
}
void CMainDlg::OnMenuitem32808()
{
CDClime dlg;
dlg.DoModal();
}
void CMainDlg::OnMenuitem32817()
{
CDUser dlg;
dlg.DoModal();
}
void CMainDlg::OnMenuitem32822()
{
CDUnit dlg;
dlg.DoModal();
}
void CMainDlg::OnMenuitem32824()
{
CDClient dlg;
dlg.DoModal();
}
void CMainDlg::OnMenuitem32825()
{
CDProvider dlg;
dlg.DoModal();
}
void CMainDlg::OnMenuitem32811()
{
CDInput dlg;
dlg.SetOP(UserName);
dlg.DoModal();
}
void CMainDlg::OnMenuitem32812()
{
CDOutPut dlg;
dlg.SetOP(UserName);
dlg.DoModal();
}
void CMainDlg::OnMenuitem32813()
{
CDAdjust dlg;
dlg.SetOP(UserName);
dlg.DoModal();
}
void CMainDlg::OnMenuitem32815()
{
CDCheck dlg;
dlg.DoModal();
}
void CMainDlg::OnMenuitem32816()
{
CDAbate dlg;
dlg.DoModal();
}
void CMainDlg::OnMenuitem32823()
{
CDAbout dlg;
dlg.DoModal();
}
void CMainDlg::OnMenuitem32826()
{
CDStore dlg;
dlg.DoModal();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -