This example can't use it ?:
//testDlg.c
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
BOOL CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
return TRUE;
case WM_CLOSE:
DestroyWindow(hWnd);
return FALSE;
case WM_DESTROY:
PostQuitMessage(0);
return FALSE;
}
//return DefWindowProc(hWnd, uMsg, wParam, lParam);
return FALSE;
}
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow)
{
MSG Msg;
HWND hWnd = CreateDialog(hInstance, MAKEINTRESOURCE(1001), NULL,(DLGPROC)DlgProc);
if (!hWnd) return 1;
while (GetMessage(&Msg, NULL, 0, 0) == TRUE)
{
if (!IsDialogMessage(hWnd, &Msg))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}
return (int) Msg.wParam;
}
//testDlg.rc
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
1001 DIALOGEX DISCARDABLE -1, -1, 156, 24
STYLE DS_CENTER|WS_CAPTION|WS_SYSMENU|WS_VISIBLE
FONT 8, "MS Sans Serif", 0, 0, 1
{
CONTROL "OK", 4001, "Button", WS_TABSTOP, 48, 4, 45, 15
CONTROL "Cancel", 4002, "Button", WS_TABSTOP, 96, 4, 45, 15
CONTROL "", 4003, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 4, 4, 40, 12
}
EDIT:
It is needed with registered class that define lpfnWndProc ?
Modified version for non-modal dialog:
/****************************************************************************
* *
* File : main.c *
* *
* Purpose : Generic dialog based Win32 application. *
* *
* History : Date Reason *
* 00/00/00 Created *
* *
****************************************************************************/
/*
* Either define WIN32_LEAN_AND_MEAN, or one or more of NOCRYPT,
* NOSERVICE, NOMCX and NOIME, to decrease compile time (if you
* don't need these defines -- see windows.h).
*/
#define WIN32_LEAN_AND_MEAN
/* #define NOCRYPT */
/* #define NOSERVICE */
/* #define NOMCX */
/* #define NOIME */
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <tchar.h>
#include "main.h"
#define NELEMS(a) (sizeof(a) / sizeof((a)[0]))
/** Prototypes **************************************************************/
static INT_PTR CALLBACK MainDlgProc(HWND, UINT, WPARAM, LPARAM);
/** Global variables ********************************************************/
static HANDLE ghInstance;
/****************************************************************************
* *
* Function: WinMain *
* *
* Purpose : Initialize the application. Register a window class, *
* create and display the main window and enter the *
* message loop. *
* *
* History : Date Reason *
* 00/00/00 Created *
* *
****************************************************************************/
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
INITCOMMONCONTROLSEX icc;
WNDCLASSEX wcx;
HWND hWnd;
MSG msg;
ghInstance = hInstance;
/* Initialize common controls. Also needed for MANIFEST's */
/*
* TODO: set the ICC_???_CLASSES that you need.
*/
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_WIN95_CLASSES /*|ICC_COOL_CLASSES|ICC_DATE_CLASSES|ICC_PAGESCROLLER_CLASS|ICC_USEREX_CLASSES|... */;
InitCommonControlsEx(&icc);
/* Load Rich Edit control support */
/*
* TODO: uncomment one of the lines below, if you are using a Rich Edit control.
*/
// LoadLibrary(_T("riched32.dll")); // Rich Edit v1.0
// LoadLibrary(_T("riched20.dll")); // Rich Edit v2.0, v3.0
/*
* TODO: uncomment line below, if you are using the Network Address control (Windows Vista+).
*/
// InitNetworkAddressControl();
/* Get system dialog information */
wcx.cbSize = sizeof(wcx);
if (!GetClassInfoEx(NULL, MAKEINTRESOURCE(32770), &wcx))
return 0;
/* Add our own stuff */
wcx.hInstance = hInstance;
wcx.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDR_ICO_MAIN));
wcx.lpszClassName = _T("TestAppClass");
wcx.lpfnWndProc = (WNDPROC)MainDlgProc;
wcx.hbrBackground = (HBRUSH)COLOR_3DSHADOW;
if (!RegisterClassEx(&wcx))
return 0;
/* The user interface is a non-modal dialog box */
hWnd = CreateDialog(hInstance, MAKEINTRESOURCE(DLG_MAIN), NULL, 0);
if (!hWnd)
return 0;
while(GetMessage(&msg, NULL, 0, 0))
{
if(!IsDialogMessage(hWnd, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
/****************************************************************************
* *
* Function: MainDlgProc *
* *
* Purpose : Process messages for the Main dialog. *
* *
* History : Date Reason *
* 00/00/00 Created *
* *
****************************************************************************/
static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
/*
* TODO: Add code to initialize the dialog.
*/
return TRUE;
case WM_SIZE:
/*
* TODO: Add code to process resizing, when needed.
*/
return TRUE;
case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam))
{
/*
* TODO: Add more control ID's, when needed.
*/
case IDOK:
DestroyWindow(hwndDlg);
return TRUE;
}
break;
case WM_CLOSE:
DestroyWindow(hwndDlg);
return TRUE;
case WM_DESTROY:
PostQuitMessage(0);
return FALSE;
/*
* TODO: Add more messages, when needed.
*/
}
return DefWindowProc(hwndDlg, uMsg, wParam, lParam);
}