Click here to Skip to main content
15,897,371 members
Articles / Database Development / SQL Server

A scripted SQL query generation framework with IDE: SQLpp (v1.4)

Rate me:
Please Sign up or sign in to vote.
4.98/5 (47 votes)
12 Sep 200311 min read 416.4K   5.4K   133  
A helper framework for generation of SQL queries in C++ and Lua
// MDIClientWnd.cpp : implementation file
//

#include "stdafx.h"
#include "ide2.h"
#include "MDIClientWnd.h"

#include "MainFrame.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMDIClientWnd

CMDIClientWnd::CMDIClientWnd()
{
}

CMDIClientWnd::~CMDIClientWnd()
{
}


BEGIN_MESSAGE_MAP(CMDIClientWnd, CWnd)
	//{{AFX_MSG_MAP(CMDIClientWnd)
	ON_MESSAGE(WM_MDISETMENU, OnMDISetMenu)
	ON_WM_ERASEBKGND()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CMDIClientWnd message handlers

LRESULT CMDIClientWnd::OnMDISetMenu(WPARAM wParam, LPARAM lParam)
{
	Default();

	ResetMenu();

	return 0;
}

void CMDIClientWnd::PreSubclassWindow() 
{
	// TODO: Add your specialized code here and/or call the base class
	VERIFY(m_menuBuild.LoadMenu(IDR_SUBMENU_BUILD));
	VERIFY(m_menuDebug.LoadMenu(IDR_SUBMENU_DEBUG));
	VERIFY(m_menuProject.LoadMenu(IDR_PROJECT_MENU));
	
	CWnd::PreSubclassWindow();
}

BOOL CMDIClientWnd::OnEraseBkgnd(CDC* pDC) 
{
/*      CBrush backBrush(RGB(58, 111, 165));

      // Save old brush
      CBrush* pOldBrush = pDC->SelectObject(&backBrush);

      CRect rect;
      pDC->GetClipBox(&rect);     // Erase the area needed

      pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(),
          PATCOPY);
      pDC->SelectObject(pOldBrush);
      return TRUE;
*/	
	return CWnd::OnEraseBkgnd(pDC);
}

void CMDIClientWnd::ResetMenu()
{
	CMenu* pMenu = AfxGetMainWnd()->GetMenu();

	CString strMenu;
	int nMenuItemCount = pMenu->GetMenuItemCount();

	for ( int i=0; i<nMenuItemCount; ++i )
	{
		pMenu->GetMenuString(i, strMenu, MF_BYPOSITION);
		if ( strMenu=="&Build" || strMenu=="&Debug" || strMenu=="&Project")
		{
			pMenu->RemoveMenu(i, MF_BYPOSITION);
			--i;
			--nMenuItemCount;
		}
	}

	pMenu->GetMenuString(1, strMenu, MF_BYPOSITION);
	int nPos = 2;
	if ( strMenu=="&Edit" )
		++nPos;

	CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
	if ( pFrame->GetMode() != pFrame->modeNoProject )
	{
		pMenu->InsertMenu(nPos, MF_BYPOSITION|MF_POPUP|MF_ENABLED, 
			(UINT)m_menuProject.GetSubMenu(0)->GetSafeHmenu(), "&Project");
		++nPos;
	}

	if ( pFrame->GetMode() == pFrame->modeBuild )
		pMenu->InsertMenu(nPos, MF_BYPOSITION|MF_POPUP|MF_ENABLED, 
			(UINT)m_menuBuild.GetSubMenu(0)->GetSafeHmenu(), "&Build");
	else if ( pFrame->GetMode()==pFrame->modeDebug || pFrame->GetMode()==pFrame->modeDebugBreak )
		pMenu->InsertMenu(nPos, MF_BYPOSITION|MF_POPUP|MF_ENABLED, 
			(UINT)m_menuDebug.GetSubMenu(0)->GetSafeHmenu(), "&Debug");
}

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
Engineer
United States United States
Jonathan de Halleux is Civil Engineer in Applied Mathematics. He finished his PhD in 2004 in the rainy country of Belgium. After 2 years in the Common Language Runtime (i.e. .net), he is now working at Microsoft Research on Pex (http://research.microsoft.com/pex).

Comments and Discussions