Commit 3f9bfc86 authored by Clinton Stimpson's avatar Clinton Stimpson

STYLE: Update examples with vtkMFCWindow changes and other changes provided by Ingo.

parent 945354ed
/*=========================================================================
Program: Visualization Toolkit
Module: ChildFrm.cpp
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// ChildFrm.cpp : implementation of the CChildFrame class
//
#include "stdafx.h"
#include "vtkMDI.h"
......@@ -20,49 +7,32 @@
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChildFrame
IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
//{{AFX_MSG_MAP(CChildFrame)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChildFrame construction/destruction
CChildFrame::CChildFrame()
{
// TODO: add member initialization code here
}
CChildFrame::~CChildFrame()
{
}
BOOL CChildFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
CCreateContext* pContext)
{
return m_wndSplitter.Create( this,
2, 2, // TODO: adjust the number of rows, columns
CSize( 10, 10 ), // TODO: adjust the minimum pane size
pContext );
}
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
// TODO: Modify the Window class or styles here by modifying the CREATESTRUCT cs
if( !CMDIChildWnd::PreCreateWindow(cs) )
return FALSE;
......@@ -70,8 +40,6 @@ BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
}
/////////////////////////////////////////////////////////////////////////////
// CChildFrame diagnostics
#ifdef _DEBUG
......@@ -87,5 +55,5 @@ void CChildFrame::Dump(CDumpContext& dc) const
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CChildFrame message handlers
/*=========================================================================
// ChildFrm.h : interface of the CChildFrame class
//
Program: Visualization Toolkit
Module: ChildFrm.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#if !defined(AFX_CHILDFRM_H__9673648E_AF88_44D8_94B9_62E13DF8E65E__INCLUDED_)
#define AFX_CHILDFRM_H__9673648E_AF88_44D8_94B9_62E13DF8E65E__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CChildFrame : public CMDIChildWnd
......@@ -28,20 +12,13 @@ public:
CChildFrame();
// Attributes
protected:
CSplitterWnd m_wndSplitter;
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CChildFrame)
public:
virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
......@@ -53,16 +30,5 @@ public:
// Generated message map functions
protected:
//{{AFX_MSG(CChildFrame)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CHILDFRM_H__9673648E_AF88_44D8_94B9_62E13DF8E65E__INCLUDED_)
/*=========================================================================
Program: Visualization Toolkit
Module: MainFrm.cpp
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "vtkMDI.h"
......@@ -20,21 +8,15 @@
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code !
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
......@@ -45,19 +27,19 @@ static UINT indicators[] =
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
......@@ -78,9 +60,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
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
// 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);
......@@ -98,7 +78,7 @@ BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
......@@ -114,6 +94,6 @@ void CMainFrame::Dump(CDumpContext& dc) const
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
/*=========================================================================
// MainFrm.h : interface of the CMainFrame class
//
Program: Visualization Toolkit
Module: MainFrm.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#if !defined(AFX_MAINFRM_H__C7C67B1E_9620_47F7_9451_9A194867F274__INCLUDED_)
#define AFX_MAINFRM_H__C7C67B1E_9620_47F7_9451_9A194867F274__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMainFrame : public CMDIFrameWnd
{
DECLARE_DYNAMIC(CMainFrame)
......@@ -33,10 +16,8 @@ public:
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
......@@ -52,17 +33,8 @@ protected: // control bar embedded members
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__C7C67B1E_9620_47F7_9451_9A194867F274__INCLUDED_)
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by VTKMDI.RC
// Used by vtkMDI.rc
//
#define IDD_ABOUTBOX 100
#define IDR_MAINFRAME 128
#define IDR_VTKMDITYPE 129
#define IDR_vtkMDITYPE 129
#define IDR_MANIFEST CREATEPROCESS_MANIFEST_RESOURCE_ID
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 130
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
......
// stdafx.cpp : source file that includes just the standard includes
// vtkMDI.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
// vtkMDI.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
......@@ -33,10 +33,20 @@
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
// Include the required header files for the vtk classes we are using
#include <vtkDataSetReader.h>
#include <vtkDataSetMapper.h>
#include <vtkActor.h>
#include <vtkActor2D.h>
#include <vtkTextMapper.h>
#include <vtkRenderer.h>
#include <vtkWin32OpenGLRenderWindow.h>
#include <vtkWin32RenderWindowInteractor.h>
#include <vtkTextProperty.h>
/*=========================================================================
Program: Visualization Toolkit
Module: vtkMDI.cpp
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// vtkMDI.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "vtkMDI.h"
#include "MainFrm.h"
#include "ChildFrm.h"
#include "vtkMDIDoc.h"
#include "vtkMDIView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CVtkMDIApp
BEGIN_MESSAGE_MAP(CVtkMDIApp, CWinApp)
//{{AFX_MSG_MAP(CVtkMDIApp)
// CvtkMDIApp
BEGIN_MESSAGE_MAP(CvtkMDIApp, CWinApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
......@@ -43,73 +25,72 @@ BEGIN_MESSAGE_MAP(CVtkMDIApp, CWinApp)
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVtkMDIApp construction
CVtkMDIApp::CVtkMDIApp()
// CvtkMDIApp construction
CvtkMDIApp::CvtkMDIApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CVtkMDIApp object
CVtkMDIApp theApp;
// The one and only CvtkMDIApp object
CvtkMDIApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CVtkMDIApp initialization
// CvtkMDIApp initialization
BOOL CVtkMDIApp::InitInstance()
BOOL CvtkMDIApp::InitInstance()
{
AfxEnableControlContainer();
// InitCommonControls() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
InitCommonControls();
CWinApp::InitInstance();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
// Change the registry key under which our settings are stored.
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
// such as the name of your company or organization
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
LoadStdProfileSettings(4); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
// serve as the connection between documents, frame windows and views
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_VTKMDITYPE,
RUNTIME_CLASS(CVtkMDIDoc),
pDocTemplate = new CMultiDocTemplate(IDR_vtkMDITYPE,
RUNTIME_CLASS(CvtkMDIDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CVtkMDIView));
RUNTIME_CLASS(CvtkMDIView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
// call DragAcceptFiles only if there's a suffix
// In an MDI app, this should occur immediately after setting m_pMainWnd
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
// Dispatch commands specified on the command line. Will return FALSE if
// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The main window has been initialized, so show and update it.
// The main window has been initialized, so show and update it
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
......@@ -118,50 +99,35 @@ public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}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()
// App command to run the dialog
void CVtkMDIApp::OnAppAbout()
void CvtkMDIApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CVtkMDIApp message handlers
// CvtkMDIApp message handlers
/*=========================================================================
Program: Visualization Toolkit
Module: vtkMDI.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#if !defined(AFX_VTKMDI_H__FBE4E818_EBEB_45D3_8269_3C4D8E2E5179__INCLUDED_)
#define AFX_VTKMDI_H__FBE4E818_EBEB_45D3_8269_3C4D8E2E5179__INCLUDED_
#if _MSC_VER > 1000
// vtkMDI.h : main header file for the vtkMDI application
//
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
......@@ -26,36 +8,24 @@
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CVtkMDIApp:
// CvtkMDIApp:
// See vtkMDI.cpp for the implementation of this class
//
class CVtkMDIApp : public CWinApp
class CvtkMDIApp : public CWinApp
{
public:
CVtkMDIApp();
CvtkMDIApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CVtkMDIApp)
public:
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CVtkMDIApp)
afx_msg void OnAppAbout();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_VTKMDI_H__FBE4E818_EBEB_45D3_8269_3C4D8E2E5179__INCLUDED_)
extern CvtkMDIApp theApp;
This diff is collapsed.
/*=========================================================================
Program: Visualization Toolkit
Module: vtkMDIDoc.cpp
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// vtkMDIDoc.cpp : implementation of the CvtkMDIDoc class
//
#include "stdafx.h"
#include "vtkMDI.h"
......@@ -20,36 +8,30 @@
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CVtkMDIDoc
IMPLEMENT_DYNCREATE(CVtkMDIDoc, CDocument)
// CvtkMDIDoc
BEGIN_MESSAGE_MAP(CVtkMDIDoc, CDocument)
//{{AFX_MSG_MAP(CVtkMDIDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
IMPLEMENT_DYNCREATE(CvtkMDIDoc, CDocument)
BEGIN_MESSAGE_MAP(CvtkMDIDoc, CDocument)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVtkMDIDoc construction/destruction
CVtkMDIDoc::CVtkMDIDoc(): HasAFile(false)
// CvtkMDIDoc construction/destruction
CvtkMDIDoc::CvtkMDIDoc()
{
this->Reader = vtkDataSetReader::New();
// TODO: add one-time construction code here
this->pvtkDataSetReader = NULL;
}
CVtkMDIDoc::~CVtkMDIDoc()
CvtkMDIDoc::~CvtkMDIDoc()
{
this->Reader->Delete();
}
BOOL CVtkMDIDoc::OnNewDocument()
BOOL CvtkMDIDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
......@@ -62,10 +44,10 @@ BOOL CVtkMDIDoc::OnNewDocument()
/////////////////////////////////////////////////////////////////////////////
// CVtkMDIDoc serialization
void CVtkMDIDoc::Serialize(CArchive& ar)
// CvtkMDIDoc serialization
void CvtkMDIDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
......@@ -77,31 +59,39 @@ void CVtkMDIDoc::Serialize(CArchive& ar)
}
}
/////////////////////////////////////////////////////////////////////////////
// CVtkMDIDoc diagnostics
// CvtkMDIDoc diagnostics
#ifdef _DEBUG
void CVtkMDIDoc::AssertValid() const
void CvtkMDIDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CVtkMDIDoc::Dump(CDumpContext& dc) const
void CvtkMDIDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////