Click here to Skip to main content
15,878,959 members
Articles / Web Development / HTML

A Comprehensive CE Class Library to Replace ATL and MFC

Rate me:
Please Sign up or sign in to vote.
4.48/5 (14 votes)
4 Oct 2000CPOL 277.7K   998   70  
A collection of classes for CE that do not use ATL or MFC, plus an FTP client, database viewer, and sample application that solves beam deflection equations.
// BeamEx.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "resource.h"

#include "BeamEx.h"
#include "BeamExMain.h"

#include <objbase.h>

HINSTANCE g_hInst = NULL;
CeBeamExMain g_wndMain;

#define CEAPP
#include <CeModule.h>

class CBeamExApp: public CeAppModule
{
	virtual int OnInitInstance(HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow);
	virtual int OnExitInstance();
}
theApp;


///////////////////////////////////////////////////////////////////////////////
//
// OnInitInstance - entry point
//
///////////////////////////////////////////////////////////////////////////////

int CBeamExApp::OnInitInstance(HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
	LPCTSTR lpszTitle = _T("BeamEx");

	INITCOMMONCONTROLSEX initCtrl;
	initCtrl.dwSize = sizeof INITCOMMONCONTROLSEX;
	initCtrl.dwICC = ICC_WIN95_CLASSES | ICC_DATE_CLASSES | ICC_COOL_CLASSES;

	BOOL bRet = InitCommonControlsEx(&initCtrl);

#ifdef __PPC__
	SHInitExtraControls();
#endif

	//Check if we're running. If it's running then focus on the window
	HWND hGenWnd = FindWindow(WC_CEGENERICWNDCLASS, lpszTitle);
	if (hGenWnd)
	{
		SetForegroundWindow (hGenWnd);    
		return 1;
	}

	g_hInst = m_hInst;

	BOOL bCreated = g_wndMain.Create(
		NULL,
		NULL,
		NULL,
		lpszTitle,
		WS_VISIBLE,
		0,
		NULL
	);

	if (! bCreated)
		return 1;

	g_wndMain.ShowWindow(nCmdShow);
	g_wndMain.UpdateWindow();

	CeDb db;
	if (! db.Open(_T("BeamEx Materials")))
	{
		if (! db.Create(_T("BeamEx Materials"), 0xa55aa55a) || ! db.Open())
		{
			MessageBox(NULL, _T("Error Creating Materials Database"),
				_T("CeDBError"), MB_OK);
		}
		else
		{
			CeDbRecord rec;

			rec.AddProp(BEAMID_NAME, CEVT_LPWSTR);
			rec.AddProp(BEAMID_ELASTICITY, CEVT_LPWSTR);

			rec.SetIdVal(BEAMID_NAME, _T("Polycarbonate"));
			rec.SetIdVal(BEAMID_ELASTICITY, _T("0.350"));
			db.AddRec(rec);

			rec.SetIdVal(BEAMID_NAME, _T("Nylon"));
			rec.SetIdVal(BEAMID_ELASTICITY, _T("0.400"));
			db.AddRec(rec);

			rec.SetIdVal(BEAMID_NAME, _T("Polystyrene"));
			rec.SetIdVal(BEAMID_ELASTICITY, _T("0.450"));
			db.AddRec(rec);

			rec.SetIdVal(BEAMID_NAME, _T("White Oak"));
			rec.SetIdVal(BEAMID_ELASTICITY, _T("1.800"));
			db.AddRec(rec);

			rec.SetIdVal(BEAMID_NAME, _T("Douglas Fir"));
			rec.SetIdVal(BEAMID_ELASTICITY, _T("1.900"));
			db.AddRec(rec);

			rec.SetIdVal(BEAMID_NAME, _T("Concrete (medium strength)"));
			rec.SetIdVal(BEAMID_ELASTICITY, _T("3.600"));
			db.AddRec(rec);

			rec.SetIdVal(BEAMID_NAME, _T("Glass (98% silica)"));
			rec.SetIdVal(BEAMID_ELASTICITY, _T("9.600"));
			db.AddRec(rec);

			rec.SetIdVal(BEAMID_NAME, _T("Gray cast Iron"));
			rec.SetIdVal(BEAMID_ELASTICITY, _T("10.000"));
			db.AddRec(rec);

			rec.SetIdVal(BEAMID_NAME, _T("Titanium"));
			rec.SetIdVal(BEAMID_ELASTICITY, _T("16.500"));
			db.AddRec(rec);

			rec.SetIdVal(BEAMID_NAME, _T("Stainless Steel (AISI 302 CRS)"));
			rec.SetIdVal(BEAMID_ELASTICITY, _T("28.000"));
			db.AddRec(rec);
		}
	}

	return 0;
}


///////////////////////////////////////////////////////////////////////////////
//
// OnExitInstance
//
///////////////////////////////////////////////////////////////////////////////

int CBeamExApp::OnExitInstance()
{
	return 0;
}

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
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