www.pudn.com > ManyControl.rar > MainFrm.cpp
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "MyDialog.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
///////////
#include "ModalDlg.h"
#include "MyWizardSheet.h"
#include "MyPropertySheet.h"
CMyWizardSheet* m_pWizardSheet;
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(ID_DIALOG_MODAL, OnDialogModal)
ON_COMMAND(ID_DIALOG_COLOR, OnDialogColor)
ON_COMMAND(ID_DIALOG_MODALLESS, OnDialogModalless)
ON_COMMAND(ID_DIALOG_FILE, OnDialogFile)
ON_COMMAND(ID_DIALOG_PROPERTY, OnDialogProperty)
ON_COMMAND(ID_DIALOG_WIZARD, OnDialogWizard)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
m_pModallessDlg=NULL;
}
CMainFrame::~CMainFrame()
{
delete m_pModallessDlg;
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::OnDialogModal()
{
// TODO: Add your command handler code here
CDC* pDC=GetDC();
//CDC* pDC=GetWindowDC( );
CModalDlg dlg;
if(dlg.DoModal()==IDOK)
{
pDC->TextOut(20,20,dlg.m_Text);
}
ReleaseDC(pDC);
}
void CMainFrame::OnDialogModalless()
{
// TODO: Add your command handler code here
if(m_pModallessDlg==NULL)
{
m_pModallessDlg=new CModallessDlg;
m_pModallessDlg->Create(IDD_DIALOG_MODALLESS,this);
}
m_pModallessDlg->ShowWindow(SW_SHOW);
}
void CMainFrame::OnDialogColor()
{
// TODO: Add your command handler code here
CColorDialog crDlg(0,0,NULL);
crDlg.DoModal();
}
void CMainFrame::OnDialogFile()
{
// TODO: Add your command handler code here
CFileDialog fileDlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,NULL,NULL);
fileDlg.DoModal();
}
void CMainFrame::OnDialogProperty()
{
// TODO: Add your command handler code here
OnProperties();//属性对话框
}
void CMainFrame::OnDialogWizard()
{
// TODO: Add your command handler code here
// AfxMessageBox("fuck!");
OnWizard();//向导对话框
}
void CMainFrame::OnWizard()
{
// TODO: The property sheet attached to your project
// via this function is not hooked up to any message
// handler. In order to actually use the property sheet,
// you will need to associate this function with a control
// in your project such as a menu item or tool bar button.
// CMyWizardSheet propSheet;
// propSheet.DoModal();
m_pWizardSheet=new CMyWizardSheet;
m_pWizardSheet->DoModal();
delete m_pWizardSheet;
//
// This is where you would retrieve information from the property
// sheet if propSheet.DoModal() returned IDOK. We aren't doing
// anything for simplicity.
}
void CMainFrame::OnProperties()
{
// TODO: The property sheet attached to your project
// via this function is not hooked up to any message
// handler. In order to actually use the property sheet,
// you will need to associate this function with a control
// in your project such as a menu item or tool bar button.
CMyPropertySheet propSheet;
propSheet.DoModal();
// This is where you would retrieve information from the property
// sheet if propSheet.DoModal() returned IDOK. We aren't doing
// anything for simplicity.
}