?? demodlg.cpp
字號:
// DemoDlg.cpp : implementation file
//
#include "stdafx.h"
#include <afxpriv.h> // for WM_KICKIDLE
// and WM_IDLEUPDATECMDUI
#include "ToolbarDialog.h"
#include "DemoDlg.h"
#include "DrawDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDemoDlg dialog
CDemoDlg::CDemoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDemoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDemoDlg)
m_nX = 0;
m_nY = 0;
m_nShape = -1;
//}}AFX_DATA_INIT
}
void CDemoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDemoDlg)
DDX_Control(pDX, IDC_SHAPE, m_cmbShape);
DDX_Control(pDX, IDC_Y, m_edtY);
DDX_Control(pDX, IDC_X, m_edtX);
DDX_Text(pDX, IDC_X, m_nX);
DDX_Text(pDX, IDC_Y, m_nY);
DDX_CBIndex(pDX, IDC_SHAPE, m_nShape);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDemoDlg, CDialog)
//{{AFX_MSG_MAP(CDemoDlg)
ON_COMMAND(ID_DRAW_SQUARE, OnDrawSquare)
ON_COMMAND(ID_DRAW_CIRCLE, OnDrawCircle)
ON_MESSAGE_VOID(WM_KICKIDLE, OnKickIdle)
ON_UPDATE_COMMAND_UI(ID_DRAW_SQUARE, OnUpdateDrawSquare)
ON_UPDATE_COMMAND_UI(ID_DRAW_CIRCLE, OnUpdateDrawCircle)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDemoDlg message handlers
BOOL CDemoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 1 - Create the toolbar
if (!m_wndToolBar.Create(this) ||
!m_wndToolBar.LoadToolBar(IDR_DLG_TOOLBAR))
{
TRACE0("Failed to create dialog toolbar\n");
EndDialog( IDCANCEL );
}
// 2 - Figure out how big the control bar(s) are.
CRect rcClientStart;
CRect rcClientNow;
GetClientRect(rcClientStart);
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST,
0, reposQuery, rcClientNow);
// 3 - Move all the controls so they are in the same
// relative position within the remaining client area as
// they would be with no control bar(s).
CPoint ptOffset(rcClientNow.left - rcClientStart.left,
rcClientNow.top - rcClientStart.top);
CRect rcChild;
CWnd* pwndChild = GetWindow(GW_CHILD);
while (pwndChild)
{
pwndChild->GetWindowRect(rcChild);
ScreenToClient(rcChild);
rcChild.OffsetRect(ptOffset);
pwndChild->MoveWindow(rcChild, FALSE);
pwndChild = pwndChild->GetNextWindow();
}
// 4 - Adjust the dialog window dimensions to make room
// for the control bar(s)
CRect rcWindow;
GetWindowRect(rcWindow);
rcWindow.right += rcClientStart.Width() - rcClientNow.Width();
rcWindow.bottom += rcClientStart.Height() - rcClientNow.Height();
MoveWindow(rcWindow, FALSE);
// 5 - Position the control bar(s)
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
// 6 - Center the dialog on the screen
// (this would not happen automatically because the
// dialog window's size changed during the WM_INITDIALOG
// processing)
CenterWindow();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDemoDlg::OnDrawSquare()
{
m_cmbShape.SetCurSel( CDrawDoc::SQUARE );
}
void CDemoDlg::OnDrawCircle()
{
m_cmbShape.SetCurSel( CDrawDoc::CIRCLE );
}
void CDemoDlg::OnKickIdle()
{
SendMessageToDescendants( WM_IDLEUPDATECMDUI );
}
void CDemoDlg::OnUpdateDrawSquare(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck( m_cmbShape.GetCurSel() == CDrawDoc::SQUARE );
}
void CDemoDlg::OnUpdateDrawCircle(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck( m_cmbShape.GetCurSel() == CDrawDoc::CIRCLE );
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -