| 12
 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
 
 |  
#include "resource.h"
#include <windows.h>
 
 
 
 
HINSTANCE hInst;
 
HWND fenetrePrincipale;
 
LRESULT CALLBACK rappelMsg(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
 
void Message(WCHAR * texte);
 
 
 
void Message(WCHAR * texte)
{
	MessageBox(fenetrePrincipale, texte, TEXT("Message"), MB_OK);
	return;
}
 
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
	hInst = hInstance;
 
	MSG msg;
	WNDCLASS wc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
	wc.hInstance = hInstance;
	wc.lpfnWndProc = (WNDPROC)rappelMsg;
	wc.lpszClassName = TEXT("classe_principale");
	wc.lpszMenuName = NULL;
	wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
 
	RegisterClass(&wc);
 
	HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU_PAINT) );
	fenetrePrincipale = CreateWindow(TEXT("classe_principale"), TEXT("ma fenetre"), WS_OVERLAPPEDWINDOW, 100, 100, 600, 300, HWND_DESKTOP, hMenu, hInstance, NULL);
	ShowWindow(fenetrePrincipale, nShowCmd);
	UpdateWindow(fenetrePrincipale);
 
	while(GetMessage(&msg, NULL, 0, 0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
 
 
 
	return 0;
 
}
 
LRESULT CALLBACK rappelMsg(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	static HDC hDC, hDCMem;
	HBITMAP monImage;
    switch(message)
    {
 
	case WM_PAINT:
	{
		monImage = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP1));
		BITMAP bitmap;
		GetObject(monImage,sizeof(BITMAP), &bitmap); 
		hDC = GetDC(hWnd);
		hDCMem = CreateCompatibleDC(hDC);
		SelectObject(hDCMem, monImage);
		BitBlt(hDC, 0, 0, bitmap.bmWidth, bitmap.bmHeight, hDCMem, 0, 0, SRCCOPY);
		DeleteDC(hDCMem);
 
		ReleaseDC(hWnd, hDC);
		DeleteObject(monImage);
 
 
	}
	break;
 
	case WM_COMMAND:
		switch(LOWORD(wParam))
		{
		case ID_FICHIER_OUVRIR:
			Message(TEXT("ouvrir"));
			break;
		case ID_FICHIER_QUITTER:
			Message(TEXT("quitter"));
			DestroyWindow(hWnd);
			break;
		}
		break;
	case WM_CLOSE:
		DestroyWindow(hWnd);
		break;
 
    case WM_DESTROY:
		Message(TEXT("destroy"));
        PostQuitMessage(0);
        break;
 
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
	return 0;
} |