#include <windows.h>
#define ID_MDI_FIRSTCHILD 50000
#define ID_New 30222
#define ID_PRZYCISK1 501
#define ID_PRZYCISK2 502
LRESULT CALLBACK WindowProcedure( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam );
LRESULT CALLBACK ChildWindowProcedure( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam );
char szClassName[] = "KlasaOkna";
char szChildName[] = "KlasaOknaDziecka";
HWND hMDIClient;
HWND hNew, hOpen, hSave, hMDIEdit;
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) {
HWND hwnd;
MSG messages;
WNDCLASSEX wincl;
wincl.hInstance = hInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = 0;
wincl.cbSize = sizeof( WNDCLASSEX );
wincl.hIcon = LoadIcon( hInstance, IDI_APPLICATION );
wincl.hIconSm = LoadIcon( hInstance, IDI_APPLICATION );
wincl.hCursor = LoadCursor( NULL, IDC_ARROW );
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground =( HBRUSH ) COLOR_WINDOW;
if( !RegisterClassEx( & wincl ) )
return FALSE;
wincl.lpfnWndProc = ChildWindowProcedure;
wincl.lpszMenuName =( LPCTSTR ) NULL;
wincl.lpszClassName = "KlasaOknaDziecka";
if( !RegisterClassEx( & wincl ) )
return FALSE;
hwnd = CreateWindowEx(
0,
szClassName,
"Aplikacja MDI",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
400,
300,
NULL,
NULL,
hInstance,
NULL
);
HWND hButton1 = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "Pierwszy", WS_CHILD | WS_VISIBLE |
WS_BORDER, 500, 50, 150, 30, hwnd,( HMENU ) ID_PRZYCISK1, hInstance, NULL ),
hButton2 = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "Drugi", WS_CHILD | WS_VISIBLE |
WS_BORDER, 450, 100, 150, 30, hwnd,( HMENU ) ID_PRZYCISK2, hInstance, NULL );
ShowWindow( hwnd, nCmdShow );
CLIENTCREATESTRUCT ccs;
ccs.hWindowMenu = NULL;
ccs.idFirstChild = ID_MDI_FIRSTCHILD;
hMDIClient = CreateWindowEx( 0, "MDICLIENT",( LPCTSTR ) NULL,
WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
5, 5, 400, 300, hwnd,( HMENU ) 0xCAC, hInstance,( LPSTR ) & ccs );
ShowWindow( hMDIClient, SW_SHOW );
while( GetMessage( & messages, NULL, 0, 0 ) ) {
if( !TranslateMDISysAccel( hMDIClient, & messages ) ) {
TranslateMessage( & messages );
DispatchMessage( & messages );
}
}
return messages.wParam;
}
LRESULT CALLBACK WindowProcedure( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) {
switch( message ) {
case WM_COMMAND:
switch( wParam )
{
case ID_PRZYCISK1:
break;
case ID_PRZYCISK2:
MessageBox( hwnd, "Zamkniecie okna", "info", MB_ICONINFORMATION );
DestroyWindow( hwnd );
break;
default:
MessageBox( hwnd, "Zrobiłeś coś innego ;-)", "Test", MB_ICONINFORMATION );
}
break;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
case WM_SIZE:
break;
default:
return DefFrameProc( hwnd, hMDIClient, message, wParam, lParam );
}
return 0;
}
LRESULT CALLBACK ChildWindowProcedure( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) {
switch( message ) {
default:
return DefMDIChildProc( hwnd, message, wParam, lParam );
}
return 0;
}
Proszę o prawienie w miarę możliwości.