Click here to Skip to main content
15,881,882 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 278.1K   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.
#ifndef __CEDialog_h__
#define __CEDialog_h__

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include "CeWnd.h"
#include "CeSet.h"
#include "CeMisc.h"

class CeDialog: public CeBaseWnd, public CeMsgWnd
{
private:
	static CeSet<HWND, HWND> m_setModeless;
	static BOOL CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

public:
	bool m_bModal;
	LPCTSTR m_lpTemplateName;

	CeDialog(LPCTSTR lpTemplateName = NULL);
	CeDialog(UINT nDlgID);
	virtual ~CeDialog();

	static bool IsDialogMsg(MSG* pMsg);

	// Default handling of the message procedure
	virtual LRESULT Default();

	// override some we can haqndle additional messages normal windows don't get (e.g., WM_INITDIALOG)
	virtual LRESULT ProcessMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);

	// create a modeless OR child dialg (by definition modeless)
	BOOL Create(LPCTSTR lpTemplateName, HWND hWndParent=NULL, HINSTANCE hInst=NULL);
	BOOL Create(UINT nIDD = 0, HWND hWndParent=NULL, HINSTANCE hInst=NULL);

	// create a modal dialg
	int DoModal(LPCTSTR lpTemplateName, HWND hWndParent=NULL, HINSTANCE hInst=NULL);
	int DoModal(UINT nIDD = 0, HWND hWndParent=NULL, HINSTANCE hInst=NULL);

	virtual void OnCancel();
	virtual void OnOK();

	BOOL EndDialog(int nResult);

	// message handlers specific to dialog boxes
	virtual BOOL OnInitDialog();
};



///////////////////////////////////////////////////////////////////////////////
//
// CeScrollDialog - dialog class that scrolls and strechs as required
//
///////////////////////////////////////////////////////////////////////////////

class CeScrollDialog: public CeDialog
{
public:
	// Modal construction, no dialog bar

	CeScrollDialog(UINT nDlgID = 0): CeDialog(nDlgID)
	{
		m_nWidth = 0;
		m_nHeight = 0;
		m_bInit = FALSE;
		m_cxOrig = 0;
		m_cyOrig = 0;
		m_bVertSBVisible = FALSE;
		m_bHorzSBVisible = FALSE;
	}

	virtual ~CeScrollDialog() {}

	// as passed to constructor:
	int   m_nWidth;         // desired window width
	int   m_nHeight;        // desired window height
	BOOL  m_bInit;          // TRUE if OnInitDialog() has been called
	int   m_cxOrig;     // width of dialog template resource
	int   m_cyOrig;    // height of dialog template resource
	BOOL  m_bVertSBVisible; 
	BOOL  m_bHorzSBVisible; 
public:
	// message handlers specific to dialog boxes
	virtual BOOL OnInitDialog();
	virtual void OnSize(UINT nType, int cx, int cy, bool& bHandled);
	virtual LRESULT OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
	int SetScrollInfo(int fnBar, int nMin, int nMax, int nPage);

	void OnVScroll(UINT nSBCode, UINT nPos, HWND hScroll);
	void OnHScroll(UINT nSBCode, UINT nPos, HWND hScroll);
};



#if defined(STRICT) || defined(_WIN32_WCE)
#define DLGPROCCAST DLGPROC
#else
#define DLGPROCCAST FARPROC
#endif

inline BOOL CeDialog::EndDialog(int nResult)
	{ CHW_ASSERT(::IsWindow(m_hWnd)); return ::EndDialog(m_hWnd, nResult); } 

inline BOOL CeDialog::Create(UINT nIDD, HWND hWndParent, HINSTANCE hInst)
	{ CHW_ASSERT(NULL == m_hWnd); return Create(MAKEINTRESOURCE(nIDD), hWndParent, hInst); }

inline int CeDialog::DoModal(UINT nIDD, HWND hWndParent, HINSTANCE hInst)
	{ CHW_ASSERT(NULL == m_hWnd); return DoModal(MAKEINTRESOURCE(nIDD), hWndParent, hInst);	}

#endif // __CEDialog_h__

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