Click here to Skip to main content
15,896,606 members
Articles / Desktop Programming / MFC

SDI with split window

Rate me:
Please Sign up or sign in to vote.
4.85/5 (67 votes)
1 Jan 2007CPOL7 min read 330.9K   4.4K   106  
Create an SDI with split window without all the extra garbage of the Doc/View architecture.
// SplitDemo.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "SplitDemo.h"
#include "MainFrm.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CSplitDemoApp

BEGIN_MESSAGE_MAP(CSplitDemoApp, CWinApp)
	ON_COMMAND(ID_APP_ABOUT, &CSplitDemoApp::OnAppAbout)
END_MESSAGE_MAP()


// CSplitDemoApp construction

CSplitDemoApp::CSplitDemoApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}


// The one and only CSplitDemoApp object

CSplitDemoApp theApp;


// CSplitDemoApp initialization

BOOL CSplitDemoApp::InitInstance()
{
	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
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));
	// To create the main window, this code creates a new frame window
	// object and then sets it as the application's main window object
	CMainFrame* pFrame = new CMainFrame;
	if (!pFrame)
		return FALSE;
	m_pMainWnd = pFrame;
	// create and load the frame with its resources
	pFrame->LoadFrame(IDR_MAINFRAME,
		WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
		NULL);






	// The one and only window has been initialized, so show and update it
	pFrame->ShowWindow(SW_SHOW);
	pFrame->UpdateWindow();
	// call DragAcceptFiles only if there's a suffix
	//  In an SDI app, this should occur after ProcessShellCommand

	//Create and load the titlebar icon
	HICON hIcon;
	hIcon = LoadIcon(IDR_MAINFRAME);	
	AfxGetMainWnd()->SendMessage(WM_SETICON,TRUE,(LPARAM)hIcon);

	return TRUE;
}


// CSplitDemoApp message handlers




// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	enum { IDD = IDD_ABOUTBOX };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

// Implementation
protected:
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()

// App command to run the dialog
void CSplitDemoApp::OnAppAbout()
{
	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}


// CSplitDemoApp message handlers

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
I am a contract developer of windows based software written in C++.

Comments and Discussions