1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
#include <windows.h>
#include "resource.h"
LRESULT CALLBACK FrameProc(HWND hFrame,UINT Message,WPARAM wParam,LPARAM lParam);
LRESULT CALLBACK ChildProc(HWND hChild,UINT Message,WPARAM wParam,LPARAM lParam);
HINSTANCE hInst;
HWND hMDIFrame; // Handle de la fenêtre principale
HWND hMDIClient; // Handle de la zone client
HWND hMDIChild; // Handle de la fenêtre fille
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nSowhCmd)
{
hInst = hInstance;
WNDCLASSEX wc;
wc.cbSize=sizeof(wc);
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.style=0;
wc.hInstance=hInst;
wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wc.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
wc.lpfnWndProc=(WNDPROC)FrameProc;
wc.lpszMenuName=NULL;
wc.lpszClassName="MDI Frame";
wc.hbrBackground=(HBRUSH) (COLOR_WINDOW+1);
if( !RegisterClassEx(&wc) )
return 0;
/** Création de la fenêtre mère (principale) **/
hMDIFrame = CreateWindowEx(
WS_EX_CLIENTEDGE,
"MDI Frame",
"Fenêtre mère - MDI Frame",
WS_VISIBLE | WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
1280,
1024,
NULL,
NULL,
hInst,
0);
/** Création de la fenêtre fille **/
DialogBox(hInst,(LPCTSTR)DIALOG_1,hMDIClient,(DLGPROC)ChildProc);
MSG msg;
while( GetMessage(&msg,NULL,0,0) != NULL )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK FrameProc(HWND hFrame,UINT Message,WPARAM wParam,LPARAM lParam)
{
switch(Message)
{
case WM_CREATE:
/** création de la zone client **/
CLIENTCREATESTRUCT css;
css.hWindowMenu=GetSubMenu(GetMenu(hMDIFrame),0);
css.idFirstChild=0;
hMDIClient = CreateWindow(
"MDICLIENT",
(LPCSTR)NULL,
WS_CHILD | WS_HSCROLL | WS_VSCROLL | WS_CLIPCHILDREN,
15,
15,
150,
100,
hFrame,
NULL,
hInst,
(LPSTR)&css);
ShowWindow(hMDIClient,SW_SHOW);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefFrameProc(hFrame,hMDIClient,Message,wParam,lParam);
}
}
LRESULT CALLBACK ChildProc(HWND hChild,UINT Message,WPARAM wParam,LPARAM lParam)
{
switch(Message)
{
case IDOK:
EndDialog(hChild,0);
return TRUE;
case IDCANCEL:
EndDialog(hChild,0);
return TRUE;
default:
return FALSE;
}
} |
Partager