Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

A comprehensive CE class library to replace ATL and MFC

, 4 Oct 2000
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.
kgwince-old.zip
WinCe
BeamEx
app.ico
BeamEx.dsp
BeamEx.dsw
BeamEx.ini
BeamEx.plg
bitmap1.bmp
bmp00001.bmp
bmp00002.bmp
calc.bmp
calc16.bmp
circ_cross.ico
cir_cross.ico
cross_4.ico
help16.bmp
help4.bmp
ico00001.ico
ico00002.ico
ico00005.ico
ico00008.ico
ico00009.ico
ico00010.ico
icon1.ico
icon2.ico
icon4.ico
id_downl.bmp
Install
BeamEx.inf
BeamEx.ini
BeamEx.MIPS_PPCBW.CAB
BeamEx.MIPS_PPCColor.CAB
BeamEx.SH3_PPCColor.CAB
Setup.exe
i_cross.ico
l_cross.ico
magenic.ico
mssccprj.scc
obl_corss.ico
obl_cross.ico
options.bmp
options1.bmp
ping16.bmp
rect_cross.ico
scene_5.ico
scene_6.ico
tri_cross.ico
vssver.scc
CeLib
CeLabel.inl
CeLib.aps
CeLib.dsp
CeLib.dsw
CeLib.old
CeLib.plg
CeLib.vcp
CeMisc.inl
CeProperty.inl
CeTab.inl
CeWnd.inl
mssccprj.scc
vssver.scc
WinLib.dsp
WinLib.dsw
dbView
bitmap1.bmp
bmp00001.bmp
db5.bmp
dbView.aps
DbView.dsp
dbView.dsw
dbView.old
dbView.plg
DbView.vcp
deldb.bp2
deldb5.bmp
delrec.bp2
delrecor.bmp
help16.bmp
help4.bmp
icon1.ico
icon2.ico
Install
dbView.inf
dbView.ini
Setup.exe
magenic.bmp
magenic.ico
mssccprj.scc
vssver.scc
ftpView
appicon.ico
bitmap1.bmp
bitmap2.bmp
bitmap3.bmp
bitmap4.bmp
bmp00001.bmp
bmp00002.bmp
db5.bmp
deldb.bp2
delrec.bp2
FtpView.dsp
ftpView.dsw
FtpView.old
ftpView.plg
FtpView.vcl
FtpView.vcp
help16.bmp
help4.bmp
ico00001.ico
ico00002.ico
ico171.ico
ico35.ico
icon1.ico
icon2.ico
imagelis.bmp
IMAGES.bmp
Install
ftpView.inf
ftpView.ini
Setup.exe
vssver.scc
magenic.bmp
magenic.ico
mssccprj.scc
options.bmp
options1.bmp
seperato.bmp
vssver.scc
Setup
ico101.ico
Setup.aps
Setup.dsp
setup.ico
Setup.plg
WinCe.dsw
WinLib.dsw
kgwince.zip
app.ico
BeamEx.dsp
BeamEx.dsw
BeamEx.ini
BeamEx.plg
BeamEx.vcl
BeamEx.vcp
bitmap1.bmp
bmp00001.bmp
bmp00002.bmp
calc.bmp
calc16.bmp
circ_cross.ico
cir_cross.ico
cross_4.ico
help16.bmp
help4.bmp
ico00001.ico
ico00002.ico
ico00005.ico
ico00008.ico
ico00009.ico
ico00010.ico
icon1.ico
icon2.ico
icon4.ico
id_downl.bmp
BeamEx.inf
BeamEx.ini
Setup.exe
i_cross.ico
l_cross.ico
magenic.ico
mssccprj.scc
obl_corss.ico
obl_cross.ico
options.bmp
options1.bmp
ping16.bmp
rect_cross.ico
scene_5.ico
scene_6.ico
tri_cross.ico
vssver.scc
CeFtp.vcp
CeFtp.vcw
CeLabel.inl
CeLib.aps
CeLib.dsp
CeLib.dsw
CeLib.plg
CeLib.vcl
CeLib.vcp
CeMisc.inl
CeProperty.inl
CeTab.inl
CeWnd.inl
mssccprj.scc
vssver.scc
WinLib.dsp
WinLib.dsw
bitmap1.bmp
bitmap2.bmp
bmp00001.bmp
db5.bmp
DbView.dsp
dbView.dsw
dbView.plg
DbView.vcl
DbView.vcp
deldb.bp2
deldb5.bmp
delrec.bp2
delrecor.bmp
help16.bmp
help4.bmp
icon1.ico
icon2.ico
dbView.inf
dbView.ini
Setup.exe
magenic.bmp
magenic.ico
menu1_5.bmp
mssccprj.scc
vssver.scc
appicon.ico
bitmap1.bmp
bitmap2.bmp
bitmap3.bmp
bitmap4.bmp
bmp00001.bmp
bmp00002.bmp
db5.bmp
deldb.bp2
delrec.bp2
FtpView.dsp
ftpView.dsw
ftpView.plg
FtpView.vcl
FtpView.vcp
FtpView.vcw
help16.bmp
help4.bmp
ico00001.ico
ico00002.ico
ico171.ico
ico35.ico
icon1.ico
icon2.ico
imagelis.bmp
IMAGES.bmp
ftpView.inf
ftpView.ini
Setup.exe
vssver.scc
magenic.bmp
magenic.ico
mssccprj.scc
newmenu.bmp
options.bmp
options1.bmp
rcdata1.bin
seperato.bmp
toolbar1.bmp
vssver.scc
WinCe.dsw
WinCe.vcw
#include "StdAfx.h"
#include "BeamEx.h"
#include "BeamExPages.h"

#include <math.h>

#if defined(_WIN32_WCE_POCKETPC)
	extern SHACTIVATEINFO s_saiDlgBox;
#endif

///////////////////////////////////////////////////////////////////////////////
//
void CeLayoutPage::Sync(bool bSave)
{
	if (NULL != m_hWnd)
	{
		if (bSave)
		{
			m_strParm_1.GetWindowText(GetDlgItem(IDC_SECTION_PARM_1));
			m_strParm_2.GetWindowText(GetDlgItem(IDC_SECTION_PARM_2));
			m_strParm_3.GetWindowText(GetDlgItem(IDC_SECTION_PARM_3));
			m_strParm_4.GetWindowText(GetDlgItem(IDC_SECTION_PARM_4));
		}
		else
		{
			SetDlgItemText(IDC_SECTION_PARM_1, m_strParm_1);
			SetDlgItemText(IDC_SECTION_PARM_2, m_strParm_2);
			SetDlgItemText(IDC_SECTION_PARM_3, m_strParm_3);
			SetDlgItemText(IDC_SECTION_PARM_4, m_strParm_4);

			SetCrossSection(m_nSection);
		}
	}
}


double CeLayoutPage::CalcI()
{
	const double dblPi = 3.1415926535897932;	// PI to 16 decimal places

	// 4 required
	Sync(true);

	double dblEdit1 = m_strParm_1;
	double dblEdit2 = m_strParm_2;
	double dblEdit3 = m_strParm_3;
	double dblEdit4 = m_strParm_4;

	switch (m_nSection)
	{
		case BSC_Rod:
		{
			// edit control 1 == diameter
			double dblDiameter	= dblEdit1;
			return (1.0 / 64.0) * dblPi * pow(dblDiameter, 4);
		}

		case BCS_Beam:
		{
			double dblBase		= dblEdit1;
			double dblHeight	= dblEdit2;
			return (1.0 / 12.0) * dblBase * pow(dblHeight, 3);
		}

		case BSC_Triangle:
		{
			double dblBase		= dblEdit1;
			double dblHeight	= dblEdit2;
			return (1.0 / 36.0) * dblBase * pow(dblHeight, 3);
		}

		case BCS_IBeam:
		{
			double dblBase		= dblEdit1;
			double dblIntHeight	= dblEdit2;
			double dblExtHeight	= dblEdit3;
			double dblThick		= dblEdit4;
			return (dblBase * pow(dblExtHeight, 3) - pow(dblIntHeight, 3) * (dblBase - dblThick)) / 12.0;
		}

		case BSC_LBeam:
		{
			double dblA	= dblEdit1;
			double dblB	= dblEdit2;
			double dblT	= dblEdit3;
			double dblY = dblB - (dblA + pow(dblB, 2) - pow(dblT, 2)) / (2 * (dblA + dblB - dblT));
			return (dblT * pow(dblY,3) + dblA * pow(dblB - dblY, 3) - (dblA - dblT) * pow(dblB - dblY - dblT, 3)) / 3.0;
		}

		case BSC_User:
			return dblEdit1;

		default:
			return 0;
	}

	return double(0);
}


BOOL CeLayoutPage::OnInitDialog()
{
	BOOL bRet = CeTabPage::OnInitDialog();

	Sync(false);
	SetCrossSection(m_nSection);

	m_mgr.Manage(GetDlgItem(IDC_SECTION_LOOKUP), AL_ANCHOR_RIGHT);
	m_mgr.Manage(GetDlgItem(IDC_SECTION_ICON), AL_ANCHOR_RIGHT | AL_ADJUST_WIDTH);

	m_mgr.Manage(GetDlgItem(IDC_SECTION_PARM_1), AL_ANCHOR_RIGHT | AL_ADJUST_WIDTH);
	m_mgr.Manage(GetDlgItem(IDC_SECTION_PARM_2), AL_ANCHOR_RIGHT | AL_ADJUST_WIDTH);
	m_mgr.Manage(GetDlgItem(IDC_SECTION_PARM_3), AL_ANCHOR_RIGHT | AL_ADJUST_WIDTH);
	m_mgr.Manage(GetDlgItem(IDC_SECTION_PARM_4), AL_ANCHOR_RIGHT | AL_ADJUST_WIDTH);

	return bRet;
}

BOOL CeLayoutPage::OnSetActive()
{
	return CeTabPage::OnSetActive();
}

void CeLayoutPage::OnSize( UINT nType, int cx, int cy, bool& bHandled )
{
	CeTabPage::OnSize(nType, cx, cy, bHandled);

	m_mgr.OnSize(nType, cx, cy);
	bHandled = true;
}

BOOL CeLayoutPage::OnCommand(WPARAM wParam, LPARAM lParam, bool& bHandled)
{
	WORD wNotifyCode = HIWORD(wParam);
	WORD wID = LOWORD(wParam);
//	HWND hwndCtl = (HWND) lParam;

	bHandled = true;

	switch (wID)
	{
	case IDC_SECTION_LOOKUP:
		if (wNotifyCode == BN_CLICKED)
		{
			OnSection();
			::PostMessage(GetTopLevelWindow(), WM_COMMAND, ID_FILE_CALC, 0);
			return 0;
		}
		break;

	case IDC_SECTION_PARM_1:
	case IDC_SECTION_PARM_2:
	case IDC_SECTION_PARM_3:
	case IDC_SECTION_PARM_4:
	case IDC_MATERIAL_MODULUS:
		if (wNotifyCode == EN_CHANGE)
		{
			::PostMessage(GetTopLevelWindow(), WM_COMMAND, ID_FILE_CALC, 0);
			return 0;
		}
		break;
	}
		
	bHandled = false;
	return 0;
}


void CeLayoutPage::OnSection()
{
	CeSectionDlg dlg;
	dlg.m_nSection = m_nSection;

	if (IDOK == dlg.DoModal(IDD_SECTION, g_wndMain, g_hInst))
		SetCrossSection(dlg.m_nSection);

	::SetFocus(::GetDlgItem(*this, IDC_SECTION_LOOKUP));
}

void CeLayoutPage::SetCrossSection(int nSection)
{
	HWND hStatic = GetDlgItem(IDC_SECTION_ICON);
	HICON hIcon = NULL;

	switch (nSection)
	{
	case BSC_Rod:
		hIcon = (HICON) ::LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_CROSS_ROD));
		SetDlgItemText(IDC_SECTION_PARM_TEXT_1,  _T("Diameter (in):"));
		SetDlgItemText(IDC_SECTION_PARM_TEXT_2,  _T(""));
		SetDlgItemText(IDC_SECTION_PARM_TEXT_3,  _T(""));
		SetDlgItemText(IDC_SECTION_PARM_TEXT_4,  _T(""));

		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_1), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_2), SW_HIDE );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_3), SW_HIDE );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_4), SW_HIDE );

		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_1), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_2), SW_HIDE );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_3), SW_HIDE );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_4), SW_HIDE );
		break;

	case BCS_Beam:
	case BSC_Triangle:

		if (BCS_Beam == nSection)
			hIcon = (HICON) ::LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_CROSS_BEAM));
		else //if (BSC_Triangle == nSection)
			hIcon = (HICON) ::LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_CROSS_TRIANGLE));

		SetDlgItemText(IDC_SECTION_PARM_TEXT_1,  _T("Base (in):"));
		SetDlgItemText(IDC_SECTION_PARM_TEXT_2,  _T("Height (in):"));
		SetDlgItemText(IDC_SECTION_PARM_TEXT_3,  _T(""));
		SetDlgItemText(IDC_SECTION_PARM_TEXT_4,  _T(""));

		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_1), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_2), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_3), SW_HIDE );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_4), SW_HIDE );

		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_1), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_2), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_3), SW_HIDE );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_4), SW_HIDE );
		break;

	case BCS_IBeam:
		hIcon = (HICON) ::LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_CROSS_IBEAM));
		SetDlgItemText(IDC_SECTION_PARM_TEXT_1,  _T("Base (in):"));
		SetDlgItemText(IDC_SECTION_PARM_TEXT_2,  _T("Outside Height (in):"));
		SetDlgItemText(IDC_SECTION_PARM_TEXT_3,  _T("Inside Height (in):"));
		SetDlgItemText(IDC_SECTION_PARM_TEXT_4,  _T("Thickness (in):"));

		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_1), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_2), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_3), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_4), SW_SHOW );

		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_1), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_2), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_3), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_4), SW_SHOW );
		break;

	case BSC_User:
		hIcon = (HICON) ::LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_CROSS_USER));
		SetDlgItemText(IDC_SECTION_PARM_TEXT_1,  _T("User Moment of Inertia:"));
		SetDlgItemText(IDC_SECTION_PARM_TEXT_2,  _T(""));
		SetDlgItemText(IDC_SECTION_PARM_TEXT_3,  _T(""));
		SetDlgItemText(IDC_SECTION_PARM_TEXT_4,  _T(""));

		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_1), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_2), SW_HIDE );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_3), SW_HIDE );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_4), SW_HIDE );

		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_1), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_2), SW_HIDE );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_3), SW_HIDE );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_4), SW_HIDE );
		break;

	case BSC_LBeam:
		hIcon = (HICON) ::LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_CROSS_LBEAM));
		SetDlgItemText(IDC_SECTION_PARM_TEXT_1,  _T("Base (in):"));
		SetDlgItemText(IDC_SECTION_PARM_TEXT_2,  _T("Height (in):"));
		SetDlgItemText(IDC_SECTION_PARM_TEXT_3,  _T("Thickness (in):"));
		SetDlgItemText(IDC_SECTION_PARM_TEXT_4,  _T(""));

		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_1), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_2), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_3), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_TEXT_4), SW_HIDE );

		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_1), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_2), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_3), SW_SHOW );
		::ShowWindow( GetDlgItem(IDC_SECTION_PARM_4), SW_HIDE );
		break;

	default:
		break;
	}

	::SendMessage(hStatic, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
	m_nSection = nSection;
}




///////////////////////////////////////////////////////////////////////////////
//
CeActualsPage::CeActualsPage():
	CeTabPage(IDD_ACTUALS_PAGE, _T("Scenario"))
{
	m_nScenario = (int) BST_CantileveredPointLoad;
}


void CeActualsPage::Sync(bool bSave)
{
	if (NULL != m_hWnd)
	{
		if (bSave)
		{
			m_strParm_1.GetWindowText(GetDlgItem(IDC_PARM_1));
			m_strParm_2.GetWindowText(GetDlgItem(IDC_PARM_2));
			m_strParm_3.GetWindowText(GetDlgItem(IDC_PARM_3));
		}
		else
		{
			SetDlgItemText(IDC_PARM_1, m_strParm_1);
			SetDlgItemText(IDC_PARM_2, m_strParm_2);
			SetDlgItemText(IDC_PARM_3, m_strParm_3);

			SetScenario(m_nScenario);
		}
	}
}


bool CeActualsPage::CalcY(double dblI, double dblE, double& dblY, double& dblYmax)
{
//	if (dblE || dblI)
	if (1.0 + dblE == 1.0 || 1.0 + dblI == 1.0)
	{
		// check for a number VERY close to zero
		dblY = 0;
		dblYmax = 0;
		return false;
	}

	Sync(true);

	if (//NULL == m_hWnd ||
		m_strParm_1.IsEmpty() ||
		m_strParm_2.IsEmpty() ||
		m_strParm_3.IsEmpty())
		return false;

	double dblL = m_strParm_1;
	double dblW = m_strParm_2;
	double dblX = m_strParm_3;

	// point or constant force variable
	double dblP = dblW;
	double dblM = dblW;

	switch (m_nScenario)
	{
	case BST_CantileveredPointLoad:
		// Cantilevered Beam with Load at End

		//Y = - P*(x^3 - 3L * x^2) / 6EI
		//
		dblY    = dblP * ( pow(dblX, 3) - 3 * dblL * pow(dblX, 2) ) / (6 * dblE * dblI);

		//Ymax = - P * L^3 / 3EI
		//
		dblYmax = - dblP * pow(dblL, 3) / (3 * dblE * dblI);
		return true;

	case BST_CantileveredUniformLoad:
		//Cantilevered Beam with Uniform Load

		//Y =-(xu^4-4*Lu*xu^3+6*Lu^2*xu^2)*(w/(24*E*Iu))
		//
		dblY    = - (pow(dblX, 4) - 4 * dblL * pow(dblX, 3) + 6 * pow(dblL, 2) * pow(dblX, 2)) *
			(dblW / (24 * dblE * dblI));

		//Ymax = -(w*Lu^4)/(8*E*Iu)
		//
		dblYmax = -(dblW * pow(dblL, 4)) / (8 * dblE * dblI);
		return true;

	case BST_CantileveredMoment:
		// Cantilevered Beam with Moment at End

		// Y    = - (M * xm ^ 2) / (2 * E * Im)
		//
		dblY    = - (dblM * pow(dblX, 2)) / (2 * dblE * dblI);

		// Ymax = - (M * Lm ^ 2) / (2 * E * Im)
		//
		dblYmax = - (dblM * pow(dblL, 2)) / (2 * dblE * dblI);
		return true;

	case BST_SupportedPointLoad:
		// Supported Beam with Center Load
		// Y =(4*xh^3-3*Lh^2*xh)*Ph/(48*E*Ih)
		dblY = (4 * pow(dblX,3) - 3 * pow(dblL,2) * dblX) * dblP / (48 * dblE * dblI);
		// Ymax = -(Ph*Lh^3)/(48*E*Ih)
		dblYmax = - (dblP * pow(dblL,3)) / (48 * dblE * dblI);
		return true;

	case BST_SupportedUniform:
		//Supported Beam with Uniform Load
		//Y     = -(xs^4-2*Ls*xs^3+Ls^3*xs)*ws/(24*E*Is)
		dblY    = - (pow(dblX, 4) - 2 * dblL * pow(dblX,3) + pow(dblL, 3) * dblX) *
			dblW / (24 * dblE * dblI);
		//Ymax  = -(5*ws*Ls^4)/(384*E*Is)
		dblYmax = -(5 * dblW * pow(dblL, 4)) / (384 * dblE * dblI);
		return true;

	default:
		return false;
	}
}


BOOL CeActualsPage::OnInitDialog()
{
	BOOL bRet = CeTabPage::OnInitDialog();

	// Sync data to control values
	Sync(false);

	// add windows to manage...
	m_mgr.Manage(GetDlgItem(IDC_SCENARIO_LOOKUP), AL_ANCHOR_RIGHT);
	m_mgr.Manage(GetDlgItem(IDC_SCENARIO_ICON), AL_ANCHOR_RIGHT | AL_ADJUST_WIDTH);

	m_mgr.Manage(GetDlgItem(IDC_PARM_1), AL_ANCHOR_RIGHT | AL_ADJUST_WIDTH);
	m_mgr.Manage(GetDlgItem(IDC_PARM_2), AL_ANCHOR_RIGHT | AL_ADJUST_WIDTH);
	m_mgr.Manage(GetDlgItem(IDC_PARM_3), AL_ANCHOR_RIGHT | AL_ADJUST_WIDTH);
	m_mgr.Manage(GetDlgItem(IDC_PARM_4), AL_ANCHOR_RIGHT | AL_ADJUST_WIDTH);

	// change to be the registry/load parameter...
	SetScenario(m_nScenario);

	return bRet;
}

BOOL CeActualsPage::OnCommand(WPARAM wParam, LPARAM lParam, bool& bHandled)
{
	WORD wNotifyCode = HIWORD(wParam);
	WORD wID = LOWORD(wParam);
//	HWND hwndCtl = (HWND) lParam;

	switch (wID)
	{
	case IDC_SCENARIO_LOOKUP:
		if (BN_CLICKED == wNotifyCode)
		{
			bHandled = true;
			OnScenario();
			::PostMessage(GetTopLevelWindow(), WM_COMMAND, ID_FILE_CALC, 0);
			return 0;
		}
		break;

	case IDC_PARM_1:
	case IDC_PARM_2:
	case IDC_PARM_3: 
	case IDC_PARM_4:
		if (EN_CHANGE == wNotifyCode)
		{
			bHandled = true;
			::PostMessage(GetTopLevelWindow(), WM_COMMAND, ID_FILE_CALC, 0);
			return 0;
		}
		break;
	}

	bHandled = false;
	return 0;
}

void CeActualsPage::SetScenario(int nScenario)
{
	HWND hStatic = GetDlgItem(IDC_SCENARIO_ICON);
	UINT nIcon = 0;
	bool bImpl = true;

	HWND hWndParm1 = GetDlgItem(IDC_PARM_1);
	HWND hWndParm2 = GetDlgItem(IDC_PARM_2);
	HWND hWndParm3 = GetDlgItem(IDC_PARM_3);
	HWND hWndParm4 = GetDlgItem(IDC_PARM_4);

	switch (nScenario)
	{
	case 0:		nIcon = IDI_SCENE_1;	break;
	case 1:		nIcon = IDI_SCENE_2;	break;
	case 2:		nIcon = IDI_SCENE_3;	break;
	case 3:		nIcon = IDI_SCENE_4;	break;
	case 4:		nIcon = IDI_SCENE_5;	break;
	}

	SetDlgItemText(IDC_PARM_STATIC_1, _T("Beam Length (in):"));
	SetDlgItemText(IDC_PARM_STATIC_3, _T("Measure At (in):"));

	switch (nScenario)
	{
	case BST_CantileveredMoment:
		SetDlgItemText(IDC_PARM_STATIC_2, _T("Moment (lbs/in):"));
		break;

	case BST_CantileveredUniformLoad:
	case BST_SupportedUniform:
		SetDlgItemText(IDC_PARM_STATIC_2, _T("Load (lbs/in):"));
		break;

	case BST_CantileveredPointLoad:
	case BST_SupportedPointLoad:
		SetDlgItemText(IDC_PARM_STATIC_2, _T("Load (lbs):"));
		break;
	}

	::ShowWindow(GetDlgItem(IDC_PARM_1), SW_SHOW);
	::ShowWindow(GetDlgItem(IDC_PARM_STATIC_1), SW_SHOW);
	::ShowWindow(GetDlgItem(IDC_PARM_2), SW_SHOW);
	::ShowWindow(GetDlgItem(IDC_PARM_STATIC_2), SW_SHOW);
	::ShowWindow(GetDlgItem(IDC_PARM_3), SW_SHOW);
	::ShowWindow(GetDlgItem(IDC_PARM_STATIC_3), SW_SHOW);
	::ShowWindow(GetDlgItem(IDC_PARM_4), SW_HIDE);
	::ShowWindow(GetDlgItem(IDC_PARM_STATIC_4), SW_HIDE);

	HICON hIcon = (HICON) ::LoadIcon(g_hInst, MAKEINTRESOURCE(nIcon));
	::SendMessage(hStatic, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);

	m_nScenario = nScenario;
}

void CeActualsPage::OnScenario()
{
	CeScenarioDlg dlg;
	dlg.m_nScenario = m_nScenario;

	if (IDOK == dlg.DoModal(IDD_SCENARIO, g_wndMain, g_hInst))
		SetScenario(dlg.m_nScenario);

	::SetFocus(::GetDlgItem(*this, IDC_SCENARIO_LOOKUP));
}


void CeActualsPage::OnSize( UINT nType, int cx, int cy, bool& bHandled )
{
	CeTabPage::OnSize(nType, cx, cy, bHandled);

	m_mgr.OnSize(nType, cx, cy);
	bHandled = true;
}

///////////////////////////////////////////////////////////////////////////////
//

BOOL CeResultsPanel::OnInitDialog()
{
	BOOL bRet = CeDialog::OnInitDialog();

	m_mgr.Manage(GetDlgItem(IDC_DEFLECTION), AL_ANCHOR_RIGHT | AL_ADJUST_WIDTH);
	m_mgr.Manage(GetDlgItem(IDC_DEFLECTION_MAX), AL_ANCHOR_RIGHT | AL_ADJUST_WIDTH);
	m_mgr.Manage(GetDlgItem(IDC_RESULTS_LABEL), AL_ANCHOR_RIGHT | AL_ADJUST_WIDTH);

	m_static.Subclass(GetDlgItem(IDC_RESULTS_LABEL));

	return bRet;
}

void CeResultsPanel::OnSize( UINT nType, int cx, int cy, bool& bHandled )
{
	CeDialog::OnSize(nType, cx, cy, bHandled);

	m_mgr.OnSize(nType, cx, cy);
	bHandled = true;
}

#include "CeMisc.h"

///////////////////////////////////////////////////////////////////////////////
//
BOOL CeMaterialDlg::OnInitDialog()
{
#ifdef _WIN32_PPC_
	CeShowSip(TRUE);
#endif

	BOOL bRet = CeDialog::OnInitDialog();

    m_mgr.Manage(GetDlgItem(IDC_STATIC_MATERIAL), AL_ANCHOR_BOTTOM);
    m_mgr.Manage(GetDlgItem(IDC_EDIT_MATERIAL), AL_ANCHOR_BOTTOM|AL_ADJUST_WIDTH);
    m_mgr.Manage(GetDlgItem(IDC_STATIC_ELASTICITY), AL_ANCHOR_BOTTOM);
    m_mgr.Manage(GetDlgItem(IDC_EDIT_ELASTICITY), AL_ANCHOR_BOTTOM|AL_ADJUST_WIDTH);
	m_mgr.Manage(GetDlgItem(IDC_MATERIAL_ACTION), AL_ANCHOR_BOTRIGHT);

	HWND hList = GetDlgItem(IDC_MATERIAL_LIST);

	m_mgr.Manage(hList, AL_ADJUST_SIZE);

	// Setup the columns
	LVCOLUMN col;

	col.mask = LVCF_FMT | LVCF_TEXT; 
	col.fmt = LVCFMT_LEFT;
	col.pszText = _T("Material");
	ListView_InsertColumn(hList, 0, &col);

	col.fmt = LVCFMT_RIGHT;
	col.pszText = _T("Modulus (Million PSI)");
	ListView_InsertColumn(hList, 1, &col);

	CeDb db;
	if (! db.Open(_T("BeamEx Materials")))
		return bRet;

	// Add materials
	LVITEM item;
	item.lParam = 0;

	CeDbRecord rec;
	CEOID oidRec = db.SeekFirst();
	for (int nRow = 0; 0 != oidRec; oidRec = db.SeekNext(), nRow++)
	{
		if (!db.ReadRec(rec))
			continue;

		CeString str;

		// Add materials
		rec.GetIdVal(BEAMID_NAME, str);
		item.mask     = LVIF_TEXT | LVIF_PARAM;
		item.iItem    = nRow;
		item.lParam   = rec.m_oid;
		item.iSubItem = 0;
		item.pszText  = (LPTSTR) (LPCTSTR) str;

		int nItem = ListView_InsertItem(hList, &item);

		rec.GetIdVal(BEAMID_ELASTICITY, str);
		item.mask     = LVIF_TEXT;
		item.iItem	  = nItem;
		item.iSubItem = 1;
		item.pszText  = (LPTSTR) (LPCTSTR) str;
		ListView_SetItem(hList, &item);
	}

	// Adjust the width so the second
	CeRect rc;
	ListView_SetColumnWidth(hList, 1, LVSCW_AUTOSIZE);
	::GetClientRect(hList, rc);
	int nWidth = rc.right - rc.left;
	nWidth -= ListView_GetColumnWidth(hList, 1);
	ListView_SetColumnWidth(hList, 0, nWidth);

	// select the new default
	ListView_SetItemState(hList, m_nSelected, LVIS_SELECTED, LVIS_SELECTED);
	ListView_EnsureVisible(hList, m_nSelected, FALSE);
	
	// LVS_EX_CHECKBOXES
	ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT);

#ifdef _WIN32_WCE_POCKETPC

	// Create a Done button and size it.  
	SHINITDLGINFO shidi;
	shidi.dwMask = SHIDIM_FLAGS;
	shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIZEDLG;
	shidi.hDlg = m_hWnd;

	SHInitDialog(&shidi);

#elif defined(_WIN32_PPC_)

	CeMoveOurWindowBasedOnSip(*this);

#endif

	return bRet;
}


void CeMaterialDlg::OnSize(UINT nType, int cx, int cy, bool& bHandled)
{
	m_mgr.OnSize(nType, cx, cy);

	CeScrollDialog::OnSize(nType, cx, cy, bHandled);
}

void CeMaterialDlg::OnSettingChange( WORD wFlag, LPCTSTR pszSection, bool& bHandled )
{
#if defined(_WIN32_WCE_POCKETPC)

	s_saiDlgBox.cbSize = sizeof s_saiDlgBox;
	SHHandleWMSettingChange(m_hWnd, wFlag, (long) pszSection, &s_saiDlgBox);
	bHandled = true;

#endif
}


LRESULT CeMaterialDlg::OnNotify(int nCtrlId, LPNMHDR pNMH, bool& bHandled)
{
	if (IDC_MATERIAL_LIST == nCtrlId)
	{
		if (pNMH->code == NM_DBLCLK)
		{
			OnOK();
			bHandled = true;
			return 0;
		}
		else if (pNMH->code == LVN_ITEMCHANGED)
		{
			// change the edit control values when selection changes
			NMLISTVIEW* pNMLV = (NMLISTVIEW*) pNMH;
			// populate the lower edit controls
			// when the selection changes
			if ((pNMLV->uChanged & LVIF_STATE) && (pNMLV->uNewState & LVIS_SELECTED))
				SetEditValues(pNMLV->iItem);
			bHandled = true;
			return 0;
		}
	}

	bHandled = false;
	return 0;
}

BOOL CeMaterialDlg::OnCommand(WPARAM wParam, LPARAM lParam, bool& bHandled)
{
	WORD wNotify = HIWORD(wParam);
	WORD wId = LOWORD(wParam);

	if (wId == IDC_MATERIAL_ACTION && wNotify == BN_CLICKED)
	{
		OnMaterialValues();
		bHandled = true;
	}
	else if ((wId == IDC_EDIT_MATERIAL|| wId == IDC_EDIT_ELASTICITY) && wNotify == EN_CHANGE)
	{
		SetDlgItemText(IDC_MATERIAL_ACTION, _T("Add"));
	}

	return 0;
}


void CeMaterialDlg::OnOK()
{
	HWND hList = GetDlgItem(IDC_MATERIAL_LIST);

	m_nSelected = ListView_GetNextItem(hList, -1, LVNI_SELECTED);
	if (m_nSelected >= 0)
	{
		TCHAR szText[64];
		ListView_GetItemText(hList, m_nSelected, 0, szText, 64);
		m_strMaterial = szText;

		ListView_GetItemText(hList, m_nSelected, 1, szText, 64);
		m_dblModulus = CeString(szText);
	}
	else
	{
		m_strMaterial.Empty();
		m_dblModulus = 0;
	}

#ifdef _WIN32_PPC_
	CeShowSip(FALSE);
#endif

	CeDialog::OnOK();
}

void CeMaterialDlg::OnCancel()
{
#ifdef _WIN32_PPC_
	CeShowSip(FALSE);
#endif

	CeDialog::OnCancel();
}

void CeMaterialDlg::OnMaterialValues()
{
	CeString str;

	GetDlgItemText(IDC_MATERIAL_ACTION, str.GetBuffer(20), 20);
	str.ReleaseBuffer();

	HWND hList = GetDlgItem(IDC_MATERIAL_LIST);

	CeDb db;
	if (! db.Open(_T("BeamEx Materials")))
		return;

	if (str == _T("Remove"))
	{
		int nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED);
		if (nItem < 0)
			return;

		int nResp = ::MessageBox(*this,
			_T("Remove the serected material?"),
			_T("Remove Material"),
			MB_OKCANCEL);

		if (IDOK != nResp)
			return;
		
		LVITEM item;
		item.mask = LVIF_PARAM;
		item.iItem = nItem;
		item.iSubItem = 0;

		ListView_GetItem(hList, &item);

		db.DeleteRecord(item.lParam);
		ListView_DeleteItem(hList, nItem);
	}
	else
	{
		// add the record to the list
		CeDbRecord rec;
		CeString strMaterial;

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

		GetDlgItemText(IDC_EDIT_MATERIAL, strMaterial.GetBuffer(64), 64);
		strMaterial.ReleaseBuffer();
		rec.SetIdVal(BEAMID_NAME, (LPCTSTR) strMaterial);

		GetDlgItemText(IDC_EDIT_ELASTICITY, str.GetBuffer(64), 64);
		str.ReleaseBuffer();
		rec.SetIdVal(BEAMID_ELASTICITY, (LPCTSTR) str);

		db.AddRec(rec);

		// add to the end of the list
		LVITEM item;
		item.mask     = LVIF_TEXT | LVIF_PARAM;
		item.iItem    = ListView_GetItemCount(hList);
		item.lParam   = rec.m_oid;
		item.iSubItem = 0;
		item.pszText  = (LPTSTR) (LPCTSTR) strMaterial;

		int nItem = ListView_InsertItem(hList, &item);

		rec.GetIdVal(BEAMID_ELASTICITY, str);
		item.iItem    = nItem;
		item.mask     = LVIF_TEXT;
		item.iSubItem = 1;
		item.pszText  = (LPTSTR) (LPCTSTR) str;
		ListView_SetItem(hList, &item);
	}
}

void CeMaterialDlg::SetEditValues(int nItem)
{
	HWND hList = GetDlgItem(IDC_MATERIAL_LIST);
	int nCnt = ListView_GetItemCount(hList);

	if (nItem >= nCnt)
	{
		SetDlgItemText(IDC_EDIT_MATERIAL, _T(""));
		SetDlgItemText(IDC_EDIT_ELASTICITY, _T(""));
	}
	else
	{
		TCHAR szText[64];
		ListView_GetItemText(hList, nItem, 0, szText, 64);
		SetDlgItemText(IDC_EDIT_MATERIAL, szText);

		ListView_GetItemText(hList, nItem, 1, szText, 64);
		SetDlgItemText(IDC_EDIT_ELASTICITY, szText);
	}

	SetDlgItemText(IDC_MATERIAL_ACTION, _T("Remove"));
	//EnableWindow(GetDlgItem(IDC_MATERIAL_ACTION), FALSE);
}


///////////////////////////////////////////////////////////////////////////////
//
BOOL CeScenarioDlg::OnInitDialog()
{
	CheckRadioButton(IDC_SCENE_1, IDC_SCENE_5, IDC_SCENE_1 + m_nScenario);

	return CeDialog::OnInitDialog();
}

void CeScenarioDlg::OnOK()
{
	for (int ii = IDC_SCENE_1; ii < IDC_SCENE_5; ii++)
	{
		if (IsDlgButtonChecked(ii))
			break;
	}

	if (ii > IDC_SCENE_5)
		// something BAD!!!
		return;

	m_nScenario = (ii - IDC_SCENE_1);

	CeDialog::OnOK();
}

///////////////////////////////////////////////////////////////////////////////
//
void CeSectionDlg::OnOK()
{
	for (int ii = IDC_SECTION_1; ii < IDC_SECTION_6; ii++)
	{
		if (IsDlgButtonChecked(ii))
			break;
	}

	if (ii > IDC_SECTION_6)
		// something BAD!!!
		return;

	m_nSection = (ii - IDC_SECTION_1);

	CeDialog::OnOK();
}

BOOL CeSectionDlg::OnInitDialog()
{
	CheckRadioButton(IDC_SECTION_1, IDC_SECTION_6, IDC_SECTION_1 + m_nSection);

	return CeDialog::OnInitDialog();
}

///////////////////////////////////////////////////////////////////////////////
//
inline HICON LoadLargeIcon(UINT nResID)
{
	return (HICON) ::LoadImage(g_hInst, MAKEINTRESOURCE(nResID), IMAGE_ICON, 32, 32, 0);
}

BOOL CeScenario2Dlg::OnInitDialog()
{
	BOOL bRet = CeDialog::OnInitDialog();

	m_hImageList = ImageList_Create(32, 32, ILC_COLOR|ILC_MASK, 8, 1);

	ImageList_AddIcon(m_hImageList, LoadLargeIcon(IDI_SCENE_1));
	ImageList_AddIcon(m_hImageList, LoadLargeIcon(IDI_SCENE_2));
	ImageList_AddIcon(m_hImageList, LoadLargeIcon(IDI_SCENE_3));
	ImageList_AddIcon(m_hImageList, LoadLargeIcon(IDI_SCENE_4));
	ImageList_AddIcon(m_hImageList, LoadLargeIcon(IDI_SCENE_5));

	HWND hList = GetDlgItem(IDC_SCENE_LIST);
	ListView_SetImageList(hList, m_hImageList, LVSIL_NORMAL);

	LVITEM item;
	memset(&item, 0, sizeof item);

	ListView_SetIconSpacing(hList, 32+16, 32+16);

	for (int ii = 0; ii < 7; ii++)
	{
		item.mask = /*LVIF_TEXT | */ LVIF_IMAGE | LVIF_STATE; 
		item.iItem = ii;
		item.iImage = ii;

		if (ii == m_nScenario)
		{
			item.state = LVIS_SELECTED;
			item.stateMask = LVIS_SELECTED; 
		}
		else
		{
			item.state = 0;
			item.stateMask = 0; 
		}

		ListView_InsertItem(hList, &item);
	}

	return bRet;
}

void CeScenario2Dlg::OnOK()
{
	HWND hList = GetDlgItem(IDC_SCENE_LIST);
	m_nScenario = ListView_GetNextItem(hList, -1, LVIS_SELECTED);

	CeDialog::OnOK();
}


///////////////////////////////////////////////////////////////////////////////
//

void CeMaterialsPage::OnMaterial()
{
	CeMaterialDlg dlg;

	dlg.m_nSelected = m_nMaterial;

	if (IDOK == dlg.DoModal(IDD_MATERIAL, g_wndMain, g_hInst))
	{ 
		SetDlgItemText(IDC_MATERIAL_STATIC, dlg.m_strMaterial);
		m_dblModulus = dlg.m_dblModulus;
		m_nMaterial = dlg.m_nSelected;

		CeString str(m_dblModulus);
		SetDlgItemText(IDC_MATERIAL_MODULUS, str);
	}

	::SetFocus(::GetDlgItem(*this, IDC_MATERIAL_LOOKUP));
}


void CeMaterialsPage::OnSize( UINT nType, int cx, int cy, bool& bHandled )
{
	CeTabPage::OnSize(nType, cx, cy, bHandled);

	m_mgr.OnSize(nType, cx, cy);
	bHandled = true;
}


BOOL CeMaterialsPage::OnInitDialog()
{
	BOOL bRet = CeTabPage::OnInitDialog();

	Sync(false);

	m_mgr.Manage(GetDlgItem(IDC_MATERIAL_LOOKUP), AL_ANCHOR_RIGHT);
	m_mgr.Manage(GetDlgItem(IDC_MATERIAL_STATIC), AL_ANCHOR_RIGHT | AL_ADJUST_WIDTH);
	m_mgr.Manage(GetDlgItem(IDC_MATERIAL_MODULUS), AL_ANCHOR_RIGHT | AL_ADJUST_WIDTH);

	return bRet;
}


BOOL CeMaterialsPage::OnCommand(WPARAM wParam, LPARAM lParam, bool& bHandled)
{
	WORD wNotifyCode = HIWORD(wParam);
	WORD wID = LOWORD(wParam);

	if (wID == IDC_MATERIAL_LOOKUP && wNotifyCode == BN_CLICKED)
	{
		bHandled = true;
		OnMaterial();
		::PostMessage(GetTopLevelWindow(), WM_COMMAND, ID_FILE_CALC, 0);
	}
	else if (wID == IDC_MATERIAL_MODULUS && wNotifyCode == EN_CHANGE)
	{
		::PostMessage(GetTopLevelWindow(), WM_COMMAND, ID_FILE_CALC, 0);
	}
	else
		bHandled = false;

	return 0;
}


double CeMaterialsPage::CalcE()
{
	Sync(true);

	double dblE = m_strModulus;
	dblE *= 1000000.0;	// displayed in millions
	return dblE;
}


void CeMaterialsPage::Sync(bool bSave)
{
	if (NULL != m_hWnd)
	{
		if (bSave)
		{
			m_strMaterial.GetWindowText(GetDlgItem(IDC_MATERIAL_STATIC));
			m_strModulus.GetWindowText(GetDlgItem(IDC_MATERIAL_MODULUS));
		}
		else
		{
			SetDlgItemText(IDC_MATERIAL_STATIC, m_strMaterial);
			SetDlgItemText(IDC_MATERIAL_MODULUS, m_strModulus);
		}
	}
}

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)

Share

About the Author

Kenny G

United States United States
No Biography provided

| Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 5 Oct 2000
Article Copyright 2000 by Kenny G
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid