【VC开源代码栏目提醒】:网学会员为广大网友收集整理了,DlgSDIDlg.cpp,希望对大家有所帮助!
// DlgSDIDlg.cpp : implementation file
//
#include "stdafx.h"
#include "DlgSDI.h"
#include "DlgSDIDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define IDS_STATUS 100
#define IDB_TOOLBAR 101
/////////////////////////////////////////////////////////////////////////////
// CDlgSDIDlg dialog
CDlgSDIDlg::CDlgSDIDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDlgSDIDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgSDIDlg)
// 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 CDlgSDIDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgSDIDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgSDIDlg, CDialog)
//{{AFX_MSG_MAP(CDlgSDIDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgSDIDlg message handlers
BOOL CDlgSDIDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 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
TBBUTTON ptoolbar[30]={{STD_HELP,MU_ONE,TBSTATE_ENABLED,TBSTYLE_BUTTON, 0, 0},
{0,0,TBSTATE_ENABLED,TBSTYLE_SEP,0,0}};
TBADDBITMAP tab;
HWND hDlg=GetSafeHwnd();
HINSTANCE hInstance=AfxGetInstanceHandle();
HWND hStatusWindow=CreateStatusWindow(WS_CHILD|WS_VISIBLE|WS_BORDER,
TEXT("状态栏"),
hDlg,
IDS_STATUS);
HWND hToolsWindow=CreateToolbarEx(hDlg,
WS_CHILD|WS_VISIBLE|TBSTYLE_WRAPABLE|TBSTYLE_TOOLTIPS|TBSTYLE_FLAT|CCS_ADJUSTABLE,
IDB_TOOLBAR,
30,
HINST_COMMCTRL,
IDB_STD_SMALL_COLOR,
ptoolbar,
2,
0,0,0,0,
sizeof(TBBUTTON));
tab.hInst=hInstance;
tab.nID=IDR_TOOLBAR1;
int iBmp=::SendMessage(hToolsWindow,TB_ADDBITMAP,(WPARAM)3,(LPARAM)&tab);
TBBUTTON tb;
tb.iBitmap=iBmp+0;
tb.idCommand=MU_TWO;
tb.fsState=TBSTATE_ENABLED;
tb.fsStyle=TBSTYLE_BUTTON;
tb.dwData=0;
tb.iString=0;
::SendMessage(hToolsWindow,TB_ADDBUTTONS,(WPARAM)1,(LPARAM)&tb);
tb.fsStyle=TBSTYLE_SEP;
::SendMessage(hToolsWindow,TB_ADDBUTTONS,(WPARAM)1,(LPARAM)&tb);
int pint[4]={110,250,300,-1};//110,250,300设定间隔
::SendMessage(hStatusWindow,SB_SETPARTS,4,(LPARAM)pint);
::SendMessage(hStatusWindow,SB_SETTEXT,1,(LPARAM)TEXT("信息一"));
::SendMessage(hStatusWindow,SB_SETTEXT,2,(LPARAM)TEXT("信息二"));
::SendMessage(hStatusWindow,SB_SETTEXT,3,(LPARAM)TEXT("信息三"));
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 CDlgSDIDlg::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 CDlgSDIDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
上一篇:
DlgSDI.cpp
下一篇:
不规则零件优化排样的神经网络混合优化算法