Click here to Skip to main content
15,892,746 members
Articles / Desktop Programming / MFC

Easy way to mix the MFC Document/View and MS Access database applications.

Rate me:
Please Sign up or sign in to vote.
4.00/5 (2 votes)
21 Nov 20015 min read 93K   1.6K   37  
Technique of using the MFC Adapter for MS Access
  • howtomix_demo.zip
    • diblook
      • DIBAPI.CPP
      • DIBAPI.H
      • DIBDOC.CPP
      • DIBDOC.H
      • DIBLOOK.CLW
      • DIBLOOK.CPP
      • Diblook.dsp
      • Diblook.dsw
      • DIBLOOK.H
      • DIBLOOK.MAK
      • diblook.mdb
      • DIBLOOK.RC
      • DIBLOOK.RCM
      • DIBVIEW.CPP
      • DIBVIEW.H
      • L.JPN
        • DIBLOOK.RC
      • MAINFRM.CPP
      • MAINFRM.H
      • MAKEFILE
      • mfc4acc.bmp
      • MYFILE.CPP
      • RES
        • DIBDOC.ICO
        • DIBLOOK.ICO
        • TOOLBAR.BMP
      • RESOURCE.H
      • STDAFX.CPP
      • STDAFX.H
    • Include
      • MFC4ACC.DEF
      • MFC4ACC.H
    • Lib
      • mfc4acc.lib
      • mfc4accd.lib
      • mfc4accds.lib
      • mfc4accs.lib
      • mfc4accu.lib
      • mfc4accud.lib
      • mfc4accuds.lib
      • mfc4accus.lib
// mainfrm.cpp : implementation of the CMainFrame class
//
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) 1992-1998 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.

#include "stdafx.h"
#include "diblook.h"

#include "mainfrm.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CMDIFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_WM_PALETTECHANGED()
	ON_WM_QUERYNEWPALETTE()
	ON_WM_CLOSE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// arrays of IDs used to initialize control bars

// toolbar buttons - IDs are command buttons
static UINT BASED_CODE buttons[] =
{
	// same order as in the bitmap 'toolbar.bmp'
	ID_FILE_NEW,
	ID_FILE_OPEN,
	ID_FILE_SAVE,
		ID_SEPARATOR,
	ID_EDIT_CUT,
	ID_EDIT_COPY,
	ID_EDIT_PASTE,
		ID_SEPARATOR,
	ID_FILE_PRINT,
	ID_APP_ABOUT,
};

static UINT BASED_CODE indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
//-->>	if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
//-->>		return -1;

	if (!m_wndToolBar.Create(this) ||
		!m_wndToolBar.LoadBitmap(IDR_MAINFRAME) ||
		!m_wndToolBar.SetButtons(buttons,
		  sizeof(buttons)/sizeof(UINT)))
	{
		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
	}

		LPDISPATCH lpAppDisp = (LPDISPATCH)lpCreateStruct;

	return 0;
}


/////////////////////////////////////////////////////////////////////////////
// CMainFrame commands


void CMainFrame::OnPaletteChanged(CWnd* pFocusWnd)
{
	CMDIFrameWnd::OnPaletteChanged(pFocusWnd);

	// always realize the palette for the active view
	CMDIChildWnd* pMDIChildWnd = MDIGetActive();
	if (pMDIChildWnd == NULL)
		return; // no active MDI child frame
	CView* pView = pMDIChildWnd->GetActiveView();
//	ASSERT(pView != NULL);

	// notify all child windows that the palette has changed
	if(pView) SendMessageToDescendants(WM_DOREALIZE, (WPARAM)pView->m_hWnd);
}



BOOL CMainFrame::OnQueryNewPalette()
{
	// always realize the palette for the active view
	CMDIChildWnd* pMDIChildWnd = MDIGetActive();
	if (pMDIChildWnd == NULL)
		return FALSE; // no active MDI child frame (no new palette)
	CView* pView = pMDIChildWnd->GetActiveView();
//	ASSERT(pView != NULL);

	// just notify the target view
	if(pView) pView->SendMessage(WM_DOREALIZE, (WPARAM)pView->m_hWnd);
	return TRUE;
}

void CMainFrame::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	
//-->>	CMDIFrameWnd::OnClose();

}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions