Download Source Code

CWinDlg Class Reference

Base class for Windows dialog. More...

#include <WinDlg.h>

List of all members.

Public Member Functions

virtual BOOL OnWMMessage (UINT uMessage, WPARAM wParam, LPARAM lParam)
 Called for all WM_XXX messages.
virtual void OnOk ()
 Called when user clicks the Ok button.
virtual void OnCancel ()
 Called when user clicks the Cancel button.
virtual BOOL OnInitDlg (HWND hwndFocus)
 Called in response to WM_INITDIALOG.
virtual BOOL OnCommand (WPARAM wParam, LPARAM lParam)
 Called in response to WM_COMMAND.
virtual void EndDlg (int ret)
 Call this function to end the dialog box.
virtual BOOL OnIdle ()
 Called when there are no windows messages.
virtual void DestroyWindow ()
 Called to destroy the window.
virtual BOOL OnKeyDown (int nVirtKey, DWORD dwKeyData)
 Called in response to a WM_KEYDOWN message.
virtual BOOL OnEndSession (BOOL bEndSession, DWORD fLogOff)
 Called in response to a WM_ENDSESSION message.
BOOL CreateDlg (HINSTANCE hInst, HWND hParent=NULL)
 Creates a windows dialog box.
int DoModal (HINSTANCE hInst, HWND hParent=NULL, int nCmdShow=SW_SHOWNORMAL)
 Runs a modal dialog box.
void AutoCenter (BOOL b)
 Specifies that the dialog box should auto center when created.
void CenterOnParent (BOOL b)
 Specifies if the dialog box should center on the parent window when created.
void CenterWindow ()
 Appropriately centers the dialog box.
 CWinDlg ()
 Constructor.
virtual ~CWinDlg ()
 Destructor.
HINSTANCE GetInstance ()
 Returns the application module instance.
HWND GetSafeHwnd ()
 Returns the dialog box window handle.
HWND GetParent ()
 Returns the window handle of the parent window.
BOOL IsWindow ()
 Returns non-zero if there is a valid window handle.
HWND GetDlgItem (int id)
 Returns the window handle to the specified control.
BOOL ShowWindow (int nCmdShow=SW_SHOWNORMAL)
 Sets the dialog box show mode.
BOOL UpdateWindow ()
 Sends a WM_PAINT message to the dialog box.
BOOL Invalidate ()
 Invalidates the client area of the window forcing a redraw.
BOOL RedrawWindow (const RECT *pRect=NULL, HRGN hRgn=NULL, UINT uFlags=RDW_ERASE|RDW_INVALIDATE|RDW_ERASENOW|RDW_UPDATENOW|RDW_ALLCHILDREN)
 Updates the specified area of the dialog box window.
BOOL SetPos (HWND hWnd)
 Sets the windows position in the Z-Order.
BOOL SetPos (int x, int y)
 Sets the windows position.
BOOL SetForegroundWindow ()
 Sets this window as the foreground window.
HWND SetFocus ()
 Gives this window the input focus.
BOOL LoadAcceleratorTable (LPCTSTR pAccelRes)
 Loads the specified accelerator table.
BOOL IsAccel ()
 Returns non-zero if there is a valid accelerator table.
HACCEL GetAccel ()
 Returns a handle to the current accelerator table.
void SetInstance (HINSTANCE hInst)
 Sets the application module instance.
void SetDlgTemplate (LPCTSTR pRes)
 Sets the resource ID of the dialog box template to use.
LPCTSTR GetDlgTemplate ()
 Returns the current dialog box resource ID.
BOOL IsRunning ()
 Returns non-zero if a valid dialog box is currently being displayed.

Static Public Member Functions

static BOOL ChooseColor (COLORREF *pCol, HWND hOwner=NULL, DWORD dwFlags=CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT)
 Launches the Windows color picker.
static BOOL DoMessagePump (HWND hWnd=NULL, HACCEL hAccel=NULL)
 Pumps the Windows message queue.
static void CenterWindow (HWND hWnd, HWND hParent=NULL, LPRECT pRect=NULL)
 Centers the specified window.
static BOOL CALLBACK DlgProc (HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
 The main dialog box callback procedure.
static BOOL SetPos (HWND hWnd, int x, int y)


Detailed Description

Base class for Windows dialog.

This class encapsulates a windows dialog and provides basic functionality.


Member Function Documentation

void CWinDlg::AutoCenter BOOL  b  )  [inline]
 

Specifies that the dialog box should auto center when created.

Parameters:
[in] b - Non-zero to enable auto centering

void CWinDlg::CenterOnParent BOOL  b  )  [inline]
 

Specifies if the dialog box should center on the parent window when created.

Parameters:
[in] b - Enable / disable parent centering.

void CWinDlg::CenterWindow HWND  hWnd,
HWND  hParent = NULL,
LPRECT  pRect = NULL
[static]
 

Centers the specified window.

Parameters:
[in] hWnd - Window handle
[in] hParent - Parent window for centering
[in] pRect - Rectangle in which to center hWnd. This parameter is ignored if hParent is not NULL.

BOOL CWinDlg::ChooseColor COLORREF *  pCol,
HWND  hOwner = NULL,
DWORD  dwFlags = CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT
[static]
 

Launches the Windows color picker.

Parameters:
[in,out] pCol - Pointer to color variable
[in] hOwner - Owner of the color dialog box
[in] dwFlags - Color picker dialog box flags
Returns:
Non-zero if a new color is chosen
See also:

BOOL CWinDlg::CreateDlg HINSTANCE  hInst,
HWND  hParent = NULL
 

Creates a windows dialog box.

Parameters:
[in] hInst - The application instance handle
[in] hParent - Parent window or NULL.
Returns:
Non-zero if dialog box is created.
See also:

BOOL CALLBACK CWinDlg::DlgProc HWND  hWnd,
UINT  uMessage,
WPARAM  wParam,
LPARAM  lParam
[static]
 

The main dialog box callback procedure.

Parameters:
[in] hWnd - Handle to dialog box
[in] uMessage - Windows message
[in] wParam - WPARAM
[in] lParam - LPARAM
Returns:
Zero if message was processed
See also:

BOOL CWinDlg::DoMessagePump HWND  hWnd = NULL,
HACCEL  hAccel = NULL
[static]
 

Pumps the Windows message queue.

Parameters:
[in] hWnd - Window handle to pump message for. NULL for all windows.
[in] hAccel - Accelerator table for message translation.
Returns:
Non-zero if WM_QUIT message was not processed.
See also:

int CWinDlg::DoModal HINSTANCE  hInst,
HWND  hParent = NULL,
int  nCmdShow = SW_SHOWNORMAL
 

Runs a modal dialog box.

Parameters:
[in] hInst - Application module instance
[in] hParent - Parent window or NULL
[in] nCmdShow - Show mode
Returns:
Return code from dialog box
See also:

void CWinDlg::EndDlg int  ret  )  [virtual]
 

Call this function to end the dialog box.

Parameters:
[in] ret - Return coded

HWND CWinDlg::GetDlgItem int  id  )  [inline]
 

Returns the window handle to the specified control.

Parameters:
[in] id - Control id

BOOL CWinDlg::Invalidate  )  [inline]
 

Invalidates the client area of the window forcing a redraw.

Returns:
Non-zero if success

BOOL CWinDlg::LoadAcceleratorTable LPCTSTR  pAccelRes  )  [inline]
 

Loads the specified accelerator table.

Parameters:
[in] pAccelRes - Resource ID of the accelerator.
Returns:
Non-zero if success
See also:

BOOL CWinDlg::OnCommand WPARAM  wParam,
LPARAM  lParam
[virtual]
 

Called in response to WM_COMMAND.

Parameters:
[in] wParam - WPARAM WORD wNotifyCode = HIWORD( wParam ); WORD wId = LOWORD( wParam );
[in] lParam - Window handle to the control
Returns:
Zero if processed
See also:

BOOL CWinDlg::OnEndSession BOOL  bEndSession,
DWORD  fLogOff
[virtual]
 

Called in response to a WM_ENDSESSION message.

Parameters:
[in] bEndSession - Non-zero if session is being ended.
[in] fLogOff - Indicates whether user is logging off, or the system is shutting down.
Returns:
Zero if processed
See also:

BOOL CWinDlg::OnIdle  )  [virtual]
 

Called when there are no windows messages.

If this function returns zero. It will not be called again until a Windows message is received in the queue. Return non-zero and this function will be called again regardless after checking the message queue.

Returns:
Return non-zero to receive more calls after checking the Windows message queue.
See also:

BOOL CWinDlg::OnInitDlg HWND  hwndFocus  )  [virtual]
 

Called in response to WM_INITDIALOG.

Parameters:
[in] hwndFocus - Window with the focus

BOOL CWinDlg::OnKeyDown int  nVirtKey,
DWORD  dwKeyData
[virtual]
 

Called in response to a WM_KEYDOWN message.

Parameters:
[in] nVirtKey - Virtual key code
[in] dwKeyData - Contains the repeat count, scan code, extended-key flag, context code, previous key state flag, and transition state flag.
Value Description 0–15 Specifies the repeat count for the current message. The value is the number of times the keystroke is auto-repeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative.

16–23 Specifies the scan code. The value depends on the original equipment manufacturer (OEM).

24 Specifies whether the key is an extended key, such as the right-hand alt and ctrl keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0.

25–28 Reserved; do not use.

29 Specifies the context code. The value is always 0 for a WM_KEYDOWN message.

30 Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is 0 if the key is up.

31 Specifies the transition state. The value is always 0 for a WM_KEYDOWN message.

Returns:
Zero if message is processed
See also:

BOOL CWinDlg::OnWMMessage UINT  uMessage,
WPARAM  wParam,
LPARAM  lParam
[virtual]
 

Called for all WM_XXX messages.

Parameters:
[in] uMessage - Message id
[in] wParam - WPARAM
[in] lParam - LPARAM
Returns:
See also:

BOOL CWinDlg::RedrawWindow const RECT *  pRect = NULL,
HRGN  hRgn = NULL,
UINT  uFlags = RDW_ERASE | RDW_INVALIDATE | RDW_ERASENOW | RDW_UPDATENOW | RDW_ALLCHILDREN
[inline]
 

Updates the specified area of the dialog box window.

Parameters:
[in] pRect - Area to redraw, NULL for all.
[in] hRgn - Region to redraw, NULL for all.
[in] uFlags - Redraw flags
Returns:
Non-zero if success
See also:

void CWinDlg::SetDlgTemplate LPCTSTR  pRes  )  [inline]
 

Sets the resource ID of the dialog box template to use.

Parameters:
[in] pRes - Dialog box resource template ID.

HWND CWinDlg::SetFocus  )  [inline]
 

Gives this window the input focus.

Returns:
Handle to previous window with the input focus

BOOL CWinDlg::SetForegroundWindow  )  [inline]
 

Sets this window as the foreground window.

Returns:
Non-zero if success

void CWinDlg::SetInstance HINSTANCE  hInst  )  [inline]
 

Sets the application module instance.

Parameters:
[in] hInst - The application module instance

static BOOL CWinDlg::SetPos HWND  hWnd,
int  x,
int  y
[inline, static]
 

Parameters:
[in] hWnd - Window handle
[in] x - Horizontal offset of upper left corner
[in] y - Vertical offset of upper left corner
Returns:
Non-zero if success
See also:

BOOL CWinDlg::SetPos int  x,
int  y
[inline]
 

Sets the windows position.

Parameters:
[in] x - Horizontal offset of upper left corner
[in] y - Vertical offset of upper left corner
Returns:
Non-zero if success
See also:

BOOL CWinDlg::SetPos HWND  hWnd  )  [inline]
 

Sets the windows position in the Z-Order.

Parameters:
[in] hWnd - Window handle to insert after
Returns:
Non-zero if success

BOOL CWinDlg::ShowWindow int  nCmdShow = SW_SHOWNORMAL  )  [inline]
 

Sets the dialog box show mode.

Returns:
Non-zero if success

BOOL CWinDlg::UpdateWindow  )  [inline]
 

Sends a WM_PAINT message to the dialog box.

Returns:
Non-zero if success


The documentation for this class was generated from the following files:
  • inc/WinDlg.h
  • WinDlg.cpp
Copyright Robert Umbehant
This documentation is covered by the LGPL