Click here to Skip to main content
15,891,253 members
Articles / Programming Languages / C

BasicAdmin - Personal Organizer

Rate me:
Please Sign up or sign in to vote.
4.94/5 (14 votes)
1 Aug 2009CPOL6 min read 50.9K   5.6K   60  
Finance, contacts, notes organizer
// 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.

// BasicAdmin.cpp : define los comportamientos de las clases para la aplicaci�n.
//

#include "stdafx.h"
#include "afxwinappex.h"
#include "BasicAdmin.h"
#include "MainFrm.h"
#include "Globals.h"
#include "SQLite/CppSQLite3.h"
#include "Utils/DiskObject.h"

#include "BasicAdminDoc.h"
#include "BasicAdminView.h"
#include "AboutDlg.h"
#include "DataStructure.h"
#include "Dialogos/Modals/Utils/FrmPWD.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

CTime tstart;

// CBasicAdminApp

BEGIN_MESSAGE_MAP(CBasicAdminApp, CWinAppEx)
	ON_COMMAND(ID_APP_ABOUT, &CBasicAdminApp::OnAppAbout)
	// Comandos de documento est�ndar basados en archivo
	ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew)
	ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen)
	// Comando de configuraci�n de impresi�n est�ndar
	ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinAppEx::OnFilePrintSetup)
	
END_MESSAGE_MAP()


// Construcci�n de CBasicAdminApp

CppSQLite3DB dbAdmin;
CString PathApplication;
TCHAR DecimalSep;
TCHAR ThousandSep;
TCHAR DateSep;
CString PathBaseDatos;
int IdBuscar;
BOOL AppInited;
CInfoFormat info;
BOOL MarcoPassword;

CBasicAdminApp::CBasicAdminApp()
{
	tstart = 0;
	m_bHiColorIcons = TRUE;
	EnableHtmlHelp();

	// TODO: agregar aqu� el c�digo de construcci�n,
	// Colocar toda la inicializaci�n importante en InitInstance
}

// El �nico objeto CBasicAdminApp

CBasicAdminApp theApp;


// Inicializaci�n de CBasicAdminApp

BOOL CBasicAdminApp::InitInstance()
{
	// Windows XP requiere InitCommonControlsEx() si un manifiesto de
	// aplicaci�n especifica el uso de ComCtl32.dll versi�n 6 o posterior para habilitar
	// estilos visuales. De lo contrario, se generar� un error al crear ventanas.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Establecer para incluir todas las clases de control comunes que desee utilizar
	// en la aplicaci�n.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinAppEx::InitInstance();
	m_pIconList[0] = LoadIcon (MAKEINTRESOURCE(IDR_MAINFRAME));
	m_pIconList[1] = LoadIcon (MAKEINTRESOURCE(IDR_MAINFRAME));
	m_pIconList[2] = LoadIcon (MAKEINTRESOURCE(IDR_MAINFRAME));
	AppInited = FALSE;
	// Inicializar bibliotecas OLE
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}
	
	SetRegistryKey(_T("BasicAdminApp"));
	
	theApp.m_nAppLook = theApp.GetInt(_T("ApplicationLook"), ID_VIEW_APPLOOK_OFF_2007_BLUE);
	
	/*MarcoPassword = FALSE;
	CFrmPWD frmpwd;
	frmpwd.DoModal();
	if (!MarcoPassword) exit(0);*/

	/*CAboutDlg* dlginicio = new CAboutDlg();
	dlginicio->Create(IDD_ABOUTBOX);
	dlginicio->ModifyStyle(WS_SYSMENU,0);
	dlginicio->SetWindowTextA("Inicio de BasicAdmin");
	dlginicio->ShowWindow(SW_SHOW);
	dlginicio->UpdateWindow();
	Sleep(800);*/

	AfxEnableControlContainer();
	// Inicializaci�n est�ndar
	// Si no utiliza estas caracter�sticas y desea reducir el tama�o
	// del archivo ejecutable final, debe quitar
	// las rutinas de inicializaci�n espec�ficas que no necesite
	// Cambie la clave del Registro en la que se almacena la configuraci�n
	// TODO: debe modificar esta cadena para que contenga informaci�n correcta
	// como el nombre de su compa��a u organizaci�n
	
	LoadPath();
	LoadConfig();
	OpenCreateDb();

	LoadStdProfileSettings(0);  // Load standard INI file options

	InitContextMenuManager();
	InitShellManager();

	InitKeyboardManager();

	InitTooltipManager();
	CMFCToolTipInfo ttParams;
	ttParams.m_bVislManagerTheme = TRUE;
	theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
		RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);

	// Registrar las plantillas de documento de la aplicaci�n. Las plantillas de documento
	//  sirven como conexi�n entre documentos, ventanas de marco y vistas
	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CBasicAdminDoc),
		RUNTIME_CLASS(CMainFrame),       // Ventana de marco SDI principal
		RUNTIME_CLASS(CBasicAdminView));
	if (!pDocTemplate)
		return FALSE;

	AddDocTemplate(pDocTemplate);
	m_nCmdShow = SW_MAXIMIZE;
	
	//dlginicio->DestroyWindow();

	// Analizar l�nea de comandos para comandos Shell est�ndar, DDE, Archivo Abrir
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Enviar comandos especificados en la l�nea de comandos. Devolver� FALSE si
	// la aplicaci�n se inici� con los modificadores /RegServer, /Register, /Unregserver o /Unregister.
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;
	// Se ha inicializado la �nica ventana; mostrarla y actualizarla
	CString str;
	str.LoadString(IDR_MAINFRAME);
	m_pMainWnd->SetWindowTextA(str);
	m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
	m_pMainWnd->UpdateWindow();
	// Llamar a DragAcceptFiles s�lo si existe un sufijo
	//  En una aplicaci�n SDI, esto debe ocurrir despu�s de ProcessShellCommand
	AppInited = TRUE;
	CInfoFormat info;
	return TRUE;
}

// Cuadro de di�logo CAboutDlg utilizado para el comando Acerca de

// Comando de la aplicaci�n para ejecutar el cuadro de di�logo
void CBasicAdminApp::OnAppAbout()
{
	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}

// CBasicAdminApp customization load/save methods

void CBasicAdminApp::PreLoadState()
{
	BOOL bNameValid;
	CString strName;
	bNameValid = strName.LoadString(IDS_EDIT_MENU);
	ASSERT(bNameValid);
	GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT);
}

void CBasicAdminApp::LoadCustomState()
{
}

void CBasicAdminApp::SaveCustomState()
{
}
void CBasicAdminApp::LoadConfig()
{
	// Get the system's decimal point	
	if (::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, NULL, 0))
		::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, &DecimalSep, sizeof(DecimalSep));
	
	// Get the system's group separator
	if (::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, NULL, 0))
		::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, &ThousandSep, sizeof(ThousandSep));
	
	if (::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDATE, NULL, 0))
		::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDATE, &DateSep, sizeof(DateSep));
}
void CBasicAdminApp::OpenCreateDb()
{
	CDiskObject dbobj;
	
	CString strNomdb = theApp.GetString("NombreBase");
	if (strNomdb == "" || !dbobj.FileExists(strNomdb))
		strNomdb = PathApplication + "BasicAdmin.db";
	CDiskObject testFile;
	CDataStructure cdb;
	cdb.OpenCreateDB(strNomdb);
}
void CBasicAdminApp::LoadPath()
{
	char temp[200];
	GetModuleFileName(AfxGetApp()->m_hInstance,temp,200);
	CString strDir = temp;
	strDir = strDir.Trim();
	CString strApp = AfxGetAppName();
	strDir = strDir.Left(strDir.GetLength() - 4 - strApp.GetLength());
	PathApplication = "";
	PathApplication.Append(strDir);
}
//BOOL CBasicAdminApp::OnIdle(LONG lCount)
//{
//	if (tstart == 0)
//		tstart = CTime::GetCurrentTime();
//	else
//	{
//		CTimeSpan tsp;
//		tsp = CTime::GetCurrentTime() - tstart;
//		if (tsp.GetSeconds() > 3)
//		{
//			MarcoPassword = FALSE;
//			CFrmPWD frmpwd;
//			frmpwd.DoModal();
//			if (!MarcoPassword) exit(0);
//			tstart = 0;
//			return TRUE;
//		}
//	}
//	return CWinAppEx::OnIdle(lCount);
//}


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