#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);
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__