@ DMac CommonTater
It is possible to use dialog inside window too.
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
char *szAppName = "WinFrame";
char *szFrameClass = "cWinFrame";
HWND hFrame;
HWND hWndDlg;
HANDLE hInst;
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wcx;
MSG msg;
wcx.cbSize = sizeof(WNDCLASSEX);
wcx.style = CS_HREDRAW | CS_VREDRAW;
wcx.lpfnWndProc = (WNDPROC) WndProc;
wcx.cbClsExtra = 0;
wcx.cbWndExtra = 0;
wcx.hInstance = hInstance;
wcx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
wcx.hbrBackground= (HBRUSH)COLOR_3DSHADOW;
wcx.lpszMenuName = MAKEINTRESOURCE(2001);
wcx.lpszClassName= szFrameClass;
wcx.hIconSm = 0;
if (!RegisterClassEx(&wcx))
return 0;
hInst = hInstance;
hFrame = CreateWindowEx(0, szFrameClass, szAppName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
300, 200,
NULL, NULL, hInst, NULL);
if(!hFrame)
return 0;
hWndDlg = CreateDialog(hInst, MAKEINTRESOURCE(1001), hFrame, (DLGPROC)WndProc);
ShowWindow(hFrame, nCmdShow);
UpdateWindow(hFrame);
while(GetMessage(&msg, NULL, 0, 0))
{
if((hWndDlg && !IsDialogMessage(hWndDlg, &msg)))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case 4001:
SetWindowText(hFrame, "OK");
return 0;
case 4002:
SetWindowText(hFrame, "Cancel");
return 0;
}
break;
case WM_SIZING:
((RECT*)lParam)->right = ((RECT*)lParam)->left+300;
((RECT*)lParam)->bottom = ((RECT*)lParam)->top+200;
return 0;
case WM_INITDIALOG:
OutputDebugString("WM_INITDIALOG");
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
// RESOURCE SCRIPT generated by "Pelles C for Windows, version 7.00".
#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
2001 MENUEX
{
POPUP "File", 0, 0, 0
{
MENUITEM "&Exit", 6001, 0, 0
}
}
1001 DIALOGEX DISCARDABLE 0, 0, 310, 18
STYLE DS_SHELLFONT|WS_CHILD|WS_VISIBLE
FONT 8, "MS Shell Dlg", 0, 0, 1
{
CONTROL "OK", 4001, "Button", WS_TABSTOP, 0, 0, 45, 15
CONTROL "Cancel", 4002, "Button", WS_TABSTOP, 48, 0, 45, 15
CONTROL "", 4003, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 96, 0, 40, 12
}