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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
| #include <windows.h>
LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK WndProcFille (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
HINSTANCE hInstance;
HWND hWndFille;
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{
HWND hWnd;
MSG messages;
WNDCLASSEX wincl;
UNREFERENCED_PARAMETER (hPrevInstance);
UNREFERENCED_PARAMETER (lpszArgument);
hInstance = hThisInstance;
// Définition de la classe de fenêtre
wincl.cbSize = sizeof (WNDCLASSEX);
wincl.style = 0;
wincl.lpfnWndProc = WndProc;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hInstance = hInstance;
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.hbrBackground = NULL;
wincl.lpszMenuName = NULL;
wincl.lpszClassName = "Classe principale";
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
if (!RegisterClassEx (&wincl)) {
return EXIT_FAILURE;}
hWnd = CreateWindowEx (
0,
"Classe principale",
"Fenetre parente",
WS_OVERLAPPEDWINDOW & (~WS_THICKFRAME),
CW_USEDEFAULT, CW_USEDEFAULT,
775, 575,
NULL, NULL, hInstance, NULL);
if (!hWnd) {
return EXIT_FAILURE;}
ShowWindow(hWnd, nFunsterStil);
UpdateWindow(hWnd);
while (GetMessage (&messages, NULL, 0, 0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
}
LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
RECT RectGraph;
WNDCLASSEX WndCl;
switch (message)
{
case WM_CREATE:
WndCl.cbSize = sizeof (WNDCLASSEX);
WndCl.style = 0;
WndCl.lpfnWndProc = WndProcFille;
WndCl.cbClsExtra = 0;
WndCl.cbWndExtra = 0;
WndCl.hInstance = hInstance;
WndCl.hIcon = NULL;
WndCl.hCursor = LoadCursor (NULL, IDC_ARROW);
WndCl.hbrBackground = NULL;
WndCl.lpszMenuName = NULL;
WndCl.lpszClassName = "Fille";
WndCl.hIconSm = NULL;
if (!RegisterClassEx (&WndCl)) {
return EXIT_FAILURE;}
if (
(hWndFille = CreateWindowEx (
0,
"Fille",
"Fille",
WS_CHILD,
0, 0, 0, 0,
hWnd, NULL, hInstance,
NULL))
== NULL
){
return EXIT_FAILURE;
}
ShowWindow(hWndFille, SW_SHOW);
return 0;
case WM_DESTROY:
PostQuitMessage (0);
return TRUE;
case WM_SIZE:
if (wParam != SIZE_MINIMIZED) {
// Fait correspondre la taille de le fenêtre fille avec la taille de la fenêtre parente.
if (GetClientRect (hWndFille, &RectGraph) == 0) {
return 0;}
if ((RectGraph.left != 0) ||
(RectGraph.right != LOWORD (lParam)) ||
(RectGraph.top != 0) ||
(RectGraph.bottom != HIWORD (lParam))
){
if (MoveWindow (hWndFille, 0, 0, LOWORD (lParam), HIWORD (lParam), FALSE) == 0){
return 0;}
}
if (RedrawWindow (hWndFille, NULL, NULL, RDW_INVALIDATE) == 0) {
return 0;}
}
default:
return DefWindowProc (hWnd, message, wParam, lParam);
}
}
LRESULT CALLBACK WndProcFille (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_LBUTTONDOWN:
return TRUE; // breakpoint 1
case WM_MOUSEWHEEL:
return TRUE; // breakpoint 2
default:
return DefWindowProc (hWnd, message, wParam, lParam);
}
} |
Partager