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
| #include <windows.h>
#include <stdio.h>
#include <wingdi.h>
#include <wincon.h>
//#define IDR_MANIFiEST 1
// #define RT_MANIFEST 24
LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
HWND WINAPI GetConsoleWindow(void);
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASS wc;
wc.style = 0;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hinstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
//wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "MaWinClass";
if(!RegisterClass(&wc)) return FALSE;
hwnd = CreateWindow("MaWinClass", "Dessiner", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 500, 500,
NULL, NULL, hinstance, NULL);
if (!hwnd) return FALSE;
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
/******************************************************************************/
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_PAINT :
{
HBRUSH hbRed, hbGreen, hbrOld;
HPEN hp2px, hpOld;
HFONT NewFont, OldFont;
LOGFONT lf;
char st[] = "Programme sous windows Bouguezine" ;
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
HDC hDC;
SetBkMode(hdc, TRANSPARENT);
TextOut(hdc, 10, 20, st, lstrlen(st));
Rectangle(hdc, 20, 60, 120, 100);
hp2px = CreatePen(PS_SOLID, 1, 0x00FFFF00);
hpOld = SelectObject(hdc,hp2px);
hbRed = CreateSolidBrush(0x000000FF);
hbrOld = SelectObject(hdc,hbRed);
Rectangle(hdc, 160, 60, 260, 100);
hbGreen = CreateHatchBrush(HS_DIAGCROSS, 0x00FFFFFF);
SelectObject(hdc,hbGreen);
DeleteObject(hbRed);
Ellipse(hdc, 0, 0, 400, 120);
MoveToEx(hdc, 0, 300, NULL);
LineTo(hdc, 800, 300);
SelectObject(hdc,hbrOld);
DeleteObject(hbGreen);
SelectObject(hdc,hpOld);
DeleteObject(hp2px);
ZeroMemory(&lf, sizeof(LOGFONT));
lstrcpy(lf.lfFaceName,"Arial");
lf.lfHeight = 7;
lf.lfItalic = FALSE;
lf.lfWeight = FW_LIGHT;
lf.lfPitchAndFamily= FD_WRITE;
NewFont = CreateFontIndirect(&lf);
OldFont = SelectObject(hdc,NewFont);
SetTextColor(hdc, 0x00FFFFFF);
TextOut(hdc, 10, 180, st, lstrlen(st));
SelectObject(hdc,OldFont);
DeleteObject(NewFont);
EndPaint(hwnd, &ps);
return 0;
}
case WM_DESTROY :
PostQuitMessage(0);
return 0;
default :
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
} |
Partager