The following is a small Windows program that shows a dialog.
Use a plain "Win32 Application" project for this. Do not use the AppWizard's option to generate source code; put the following code in a cpp file (such as DlgHello.cpp) and add that file to the project . The dialog resource is not provided here but it can quickly be created by the resource editor. Simply create a new dialog template for the project; it should work as created without any modification required.
#define STRICT
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "resource.h"
BOOL CALLBACK DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
switch (message) {
case WM_INITDIALOG:
return (TRUE);
case WM_COMMAND:
switch (wParam) {
case IDOK:
case IDCANCEL:
EndDialog(hDlg, TRUE);
return (TRUE);
}
break;
}
return (FALSE);
}
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
int ReturnValue;
ReturnValue = DialogBoxParam(NULL, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DialogProc, NULL);
return 0;
}
See my Visual C++ Programmer Stuff page for more C++ stuff.