Click here to Skip to main content
15,893,487 members
Articles / Programming Languages / C++

BasicAdmin2 - Personal Finance Software

Rate me:
Please Sign up or sign in to vote.
4.58/5 (8 votes)
4 Nov 2011CPOL3 min read 39K   5.9K   33  
Utility to keep track of your finances
// This MFC Samples source code demonstrates using MFC Microsoft Office Fluent User Interface 
// (the "Fluent UI") and is provided only as referential material to supplement the 
// Microsoft Foundation Classes Reference and related electronic documentation 
// included with the MFC C++ library software.  
// License terms to copy, use or distribute the Fluent UI are available separately.  
// To learn more about our Fluent UI licensing program, please visit 
// http://msdn.microsoft.com/officeui.
//
// Copyright (C) Microsoft Corporation
// All rights reserved.

// ChildFrm.cpp : implementation of the CChildFrame class
//

#include "stdafx.h"
#include "BasicAdmin2.h"

#include "ChildFrm.h"
#include "Globals.h"
#include "MainFrm.h"
#include "../BasicAdmin2_Database/Managers/ManArrays.h"
#include "../BasicAdmin2_Database/Managers/ManCurrency.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// CChildFrame

IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWndEx)

BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWndEx)
	ON_COMMAND(ID_FILE_CLOSE, &CChildFrame::OnFileClose)
	ON_WM_SETFOCUS()
	ON_WM_CREATE()
	ON_WM_THEMECHANGED()
	
END_MESSAGE_MAP()

// CChildFrame construction/destruction

CChildFrame::CChildFrame()
{
	// TODO: add member initialization code here
}

CChildFrame::~CChildFrame()
{
}
/*void CChildFrame::ActivateTopLevelFrame()
{

}*/

BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying the CREATESTRUCT cs
	if( !CMDIChildWndEx::PreCreateWindow(cs) )
		return FALSE;

	cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
	cs.lpszClass = AfxRegisterWndClass(0);
	return TRUE;
}

// CChildFrame diagnostics

#ifdef _DEBUG
void CChildFrame::AssertValid() const
{
	CMDIChildWndEx::AssertValid();
}

void CChildFrame::Dump(CDumpContext& dc) const
{
	CMDIChildWndEx::Dump(dc);
}
#endif //_DEBUG

// CChildFrame message handlers
void CChildFrame::OnFileClose() 
{
	// To close the frame, just send a WM_CLOSE, which is the equivalent
	// choosing close from the system menu.
	SendMessage(WM_CLOSE);
}

int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CMDIChildWndEx::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	//SetFont(&param.fuentes.font);
	return 0;
}

void CChildFrame::OnSetFocus(CWnd* pOldWnd) 
{
	CMDIChildWndEx::OnSetFocus(pOldWnd);

	if (handles.m_WndGrid == 0) return;

	if (handles.m_WndGrid->IsWindowVisible())
	{
		if (handles.m_WndTreeView != 0)
			handles.m_WndTreeView->SetFocus();
		else
			handles.m_WndGrid->SetFocus();
	}
	else
		handles.m_WndDialog->SetFocus();
	if (handles.m_WndGrid != 0)
	{
		CGenGridView* gv = (CGenGridView*)handles.m_WndGrid;
		gv->RefreshStatusBar();
	}
}

BOOL CChildFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
{
	return CMDIChildWndEx::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}

LRESULT CChildFrame::OnThemeChanged()
{
	// This feature requires Windows XP or greater.
	// The symbol _WIN32_WINNT must be >= 0x0501.
	// TODO: Add your message handler code here and/or call default
	param.settings.m_nAppLook = theApp.m_nAppLook;
	return 1;
}

void CChildFrame::InitHandlesAndContext(CCreateContext& context)
{
	handles.m_WndDialog = 0;
	handles.m_WndDialogTreeSearch = 0;
	handles.m_WndGrid = 0;
	handles.m_WndTreeView = 0;

	context.m_pCurrentDoc=NULL;
	context.m_pNewDocTemplate=NULL;
	context.m_pLastView=NULL;
	context.m_pCurrentFrame=NULL;
}

BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
	InitHandlesAndContext(context);
	return CMDIChildWndEx::OnCreateClient(lpcs, pContext);
}
void CChildFrame::CreateDialogs()
{
	/*CString a;
	a.Format(L"%d",tabtype);
	AfxMessageBox(a);*/
	int value = (int)handles.tabtype;

	SetFinanceParams();
	SetNotesParams();
	SetContactsParams();
	SetConfigParams();
		
	switch(value)
	{
		case TabTypeEnum::TabTypeCurrencies:	finman.OnCreateCurrencies(); break;
		case TabTypeEnum::TabTypeAccounts:		finman.OnCreateAccounts(); break;
		case TabTypeEnum::TabTypeDailyInput:	finman.OnCreateDailyInput(); break;
		case TabTypeEnum::TabTypeStats:			finman.OnCreateDailyStats(); break;
		case TabTypeEnum::TabTypeValues:		finman.OnCreateCurValues(); break;

		case TabTypeEnum::TabTypeNoteGroup:		notesman.OnCreateNoteGroups(); break;
		case TabTypeEnum::TabTypeNotes:			notesman.OnCreateNotes(); break;
		case TabTypeEnum::TabTypeContactGroup:	conman.OnCreateContactGroups(); break;
		case TabTypeEnum::TabTypeContact:		conman.OnCreateContacts(); break;
		case TabTypeEnum::TabTypeFontColor:		configman.OnCreateFontColors(); break;
	}
}
void CChildFrame::SetFinanceParams()
{
	finman.context = &context;
	finman.frmchild = this;
	finman.handles = &handles;
	finman.param = &param;
}
void CChildFrame::SetNotesParams()
{
	notesman.context = &context;
	notesman.frmchild = this;
	notesman.handles = &handles;
	notesman.param = &param;
}
void CChildFrame::SetContactsParams()
{
	conman.context = &context;
	conman.frmchild = this;
	conman.handles = &handles;
	conman.param = &param;
}
void CChildFrame::SetConfigParams()
{
	configman.context = &context;
	configman.frmchild = this;
	configman.handles = &handles;
	configman.param = &param;
}

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
Argentina Argentina
System developer from Argentina.

Programmed in VB 5,6,.NET, C#, Java, PL-SQL, Transac-SQL, C, C++ and even some "calculator" language.

Love to build small, useful applications.
Usually building big and complicated apps based on solid, reliable components.

Hobbies: reading, photography, chess, paddle, running.

Comments and Discussions