#include "main.h" LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); void verif_app(HWND,LPCSTR); bool InitFenetre(HINSTANCE); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { MSG msg; if(!InitFenetre(hInstance)) return 0; while (GetMessage(&msg,0,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } void verif_app(HWND hand,LPCSTR classe) { if (hand=FindWindow(classe,0)) { ShowWindow(hand,1); SetForegroundWindow(hand); exit(0); } } bool InitFenetre(HINSTANCE hInstance) { static char nom_classe[] = "onsenfou"; HWND hand; WNDCLASS classe; verif_app(hand,nom_classe); classe.style = CS_HREDRAW | CS_VREDRAW; classe.lpfnWndProc = WndProc; classe.cbClsExtra = 0; classe.cbWndExtra = 0; classe.hbrBackground = (HBRUSH)(COLOR_WINDOW+9); classe.hInstance = hInstance; classe.lpszClassName = nom_classe; classe.hCursor = LoadCursor(NULL,IDC_ARROW); classe.hIcon = LoadIcon(NULL,IDI_APPLICATION); classe.lpszMenuName = 0; if (!RegisterClass(&classe)) { MessageBox(0,"Impossible de creer la fenetre...","erreur",MB_OK); return 0; } hand = CreateWindow(nom_classe,"application",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, 100,800,600,0,0,hInstance,0); if (!hand) { MessageBox(0,"hWnd","erreur",MB_OK); return false; } ShowWindow(hand,1); UpdateWindow(hand); return true; } LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_DESTROY: PostQuitMessage (0) ; return 0 ; } return DefWindowProc (hwnd, message, wParam, lParam) ; }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question