- CreateDialogBox
-
-PURPOSE:
- Creates a Dialog Box.
-***********************************************************************/
-int CBaseWindow::CreateDialogBox( HWND hwnd, CBaseWindow *p_obj )
-{
- uint8_t p_buffer[sizeof(DLGTEMPLATE) + sizeof(WORD) * 4];
- DLGTEMPLATE *p_dlg_template = (DLGTEMPLATE *)p_buffer;
- memset( p_dlg_template, 0, sizeof(DLGTEMPLATE) + sizeof(WORD) * 4 );
-
- // these values are arbitrary, they won't be used normally anyhow
- p_dlg_template->x = 0; p_dlg_template->y = 0;
- p_dlg_template->cx = 300; p_dlg_template->cy = 300;
- p_dlg_template->style =
- DS_MODALFRAME|WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX;
-
- return DialogBoxIndirectParam( GetModuleHandle(0), p_dlg_template, hwnd,
- (DLGPROC)p_obj->BaseWndProc, (LPARAM)p_obj );
-}
-
-/***********************************************************************
-FUNCTION:
- BaseWndProc
-
-PURPOSE:
- Processes messages sent to the main window.
-***********************************************************************/
-LRESULT CALLBACK CBaseWindow::BaseWndProc( HWND hwnd, UINT msg, WPARAM wParam,
- LPARAM lParam )
-{
- CBaseWindow *p_obj;
-
- // check to see if a copy of the 'this' pointer needs to be saved
- if( msg == WM_CREATE )
- {
- p_obj = (CBaseWindow *)(((LPCREATESTRUCT)lParam)->lpCreateParams);
- SetWindowLong( hwnd, GWL_USERDATA,
- (LONG)((LPCREATESTRUCT)lParam)->lpCreateParams );
-
- p_obj->hWnd = hwnd;
- }
-
- if( msg == WM_INITDIALOG )
- {
- p_obj = (CBaseWindow *)lParam;
- SetWindowLong( hwnd, GWL_USERDATA, lParam );
- p_obj->hWnd = hwnd;
- }
-
- // Retrieve the pointer
- p_obj = (CBaseWindow *)GetWindowLong( hwnd, GWL_USERDATA );
-
- if( !p_obj ) return DefWindowProc( hwnd, msg, wParam, lParam );
-
- // Filter message through child classes
- return p_obj->WndProc( hwnd, msg, wParam, lParam );
-}
-
-/***********************************************************************
-FUNCTION: