The answer depends on what technique you are using. Is it pure WinAPI or MFC
or ATL.... etc
Basically here you can find the simplest way to initialize and display
dialog box is to execute the following piece of code:
#include <windows.h>
#define MY_CLASS_NAME "MyClass"
#define MY_WINDOW_TITLE "MyTitle"
/* Prototype */
LRESULT CALLBACK
WndProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
MSG msg;
WNDCLASS wc;
HWND hwnd;
/* Register the window class for the main window. */
if( hPrevInstance == NULL )
{
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon( (HINSTANCE)NULL, IDI_APPLICATION );
wc.hCursor = LoadCursor( (HINSTANCE)NULL, IDC_ARROW );
wc.hbrBackground = GetStockObject( WHITE_BRUSH );
wc.lpszMenuName = 0;
wc.lpszClassName = MY_CLASS_NAME;
if ( RegisterClass( &wc ) == 0 )
return 0;
}
/* Create our window. */
hwnd = CreateWindow( MY_CLASS_NAME, MY_WINDOW_TITLE, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
(HWND)NULL, (HMENU)NULL, hInstance, (LPVOID)NULL );
/*
* If the window cannot be created, terminate
* the application.
*/
if( hwnd == NULL )
return 0;
/* Show the window and paint its contents. */
ShowWindow( hwnd, nCmdShow );
UpdateWindow( hwnd );
/* Start the message loop. */
while( GetMessage( &msg, (HWND)NULL, 0, 0 ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
/* Return the exit code to the system. */
return msg.wParam;
}
#include <windows.h>
LRESULT CALLBACK WndProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
lParam )
{
HINSTANCE hinst = (HINSTANCE)::GetWindowLong(hwnd, GWL_HINSTANCE);
witch( uMsg )
{
case WM_CREATE:
//Here is where dialog box will appear using your template
:
ialogBox(hinst, MAKEINTRESOURCE(DLG_WINDOW), hwnd,
(DLGPROC)DlgWndProc)==IDOK
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default:
return( DefWindowProc( hwnd, uMsg, wParam, lParam ) );
}
return 0;
}
~~~~~~~~~~~~~~~
Rememeber to replace DLG_WINDOW with the ID of your own dialog window
Read the following article in order to decide whether you need to use modal
or modeless dialog box. It will also help you to write your own Dialog
procedure:
http://msdn.microsoft.com/library/d...ce/Windowing/DialogBoxes/UsingDialogBoxes.asp
if you use MFC you can find usefull reading the following article:
http://msdn.microsoft.com/library/d...owexampledisplayingdialogboxviamenuoption.asp