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
| #include <windows.h>
// définition de la procédure
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "CodeBlocksWindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nCmdShow)
{
HWND handle;
char lpTemplate[]="test";
handle=CreateDialog(hThisInstance, lpTemplate, NULL, (DLGPROC)WindowProcedure);
ShowWindow(handle, SW_SHOW);
MSG message;
while(GetMessage(&message, NULL, 0, 0)==TRUE)
{
TranslateMessage(&message);
DispatchMessage(&message);
}
return 0;
}
// fonction appelée par DispatchMessage()
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int Select;
switch(message)
{
case WM_COMMAND:
Select=LOWORD(wParam);
switch(Select)
{
case IDOK:
EndDialog(hwnd, 0);
PostQuitMessage(0);
return TRUE;
case IDCANCEL:
EndDialog(hwnd, Select);
PostQuitMessage(0);
return TRUE;
}
default:
return FALSE;
}
} |
Partager