blob: 0adc24f426dc3ab6a624d92c5d681e82787c9989 [file] [log] [blame]
Kai Tietz1e446802007-08-20 14:25:57 +00001/**
2 * This file has no copyright assigned and is placed in the Public Domain.
Rafaël Carré8a67ab42012-06-28 15:40:59 +00003 * This file is part of the mingw-w64 runtime package.
Kai Tietzfa0cfe32010-01-15 20:02:21 +00004 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
Kai Tietz1e446802007-08-20 14:25:57 +00005 */
Ozkan Sezerdaabd712009-08-22 18:11:19 +00006#ifndef WIN32_LEAN_AND_MEAN
Kai Tietz518dd332007-08-10 09:54:15 +00007#define WIN32_LEAN_AND_MEAN
Ozkan Sezerdaabd712009-08-22 18:11:19 +00008#endif
Kai Tietz518dd332007-08-10 09:54:15 +00009#include <windows.h>
10
11#define TITLE "WinMain"
12#define WIDTH 250
13#define HEIGHT 250
14
15void Draw(HDC hdc);
16
17LRESULT CALLBACK WindowProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam)
18{
19 PAINTSTRUCT ps;
20 switch (Msg)
21 {
22 case WM_PAINT:
23 BeginPaint(hWnd,&ps);
24 Draw(ps.hdc);
25 EndPaint(hWnd,&ps);
26 break;
27 case WM_DESTROY:
28 PostQuitMessage(0);
29 break;
30 default:
31 return DefWindowProc(hWnd,Msg,wParam,lParam);
32 }
33 return 0;
34}
35
36char szClassName[] = "WinMain";
37
38int WINAPI WinMain(HINSTANCE hThisInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
39{
40 HWND hwnd;
41 MSG messages;
42 WNDCLASSEX wincl;
43
44 wincl.hInstance = hThisInstance;
45 wincl.lpszClassName = szClassName;
46 wincl.lpfnWndProc = WindowProc;
47 wincl.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
48 wincl.cbSize = sizeof(WNDCLASSEX);
49
50 wincl.hIcon = LoadIcon(NULL,IDI_APPLICATION);
51 wincl.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
52 wincl.hCursor = LoadCursor(NULL,IDC_ARROW);
53 wincl.lpszMenuName = NULL;
54 wincl.cbClsExtra = 0;
55 wincl.cbWndExtra = 0;
56 wincl.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);;
57
58 if (!RegisterClassEx(&wincl)) return 0;
59
60 hwnd = CreateWindowEx(0, szClassName, TITLE, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, WIDTH, HEIGHT,
61 HWND_DESKTOP, NULL, hThisInstance, NULL);
62
63 ShowWindow(hwnd,nCmdShow);
64
65 while (GetMessage(&messages,NULL,0,0))
66 {
67 TranslateMessage(&messages);
68 DispatchMessage(&messages);
69 }
70 return (int)messages.wParam;
71}
72
73void Draw(HDC hdc)
74{
75 HBRUSH pinsel;
76 pinsel = CreateSolidBrush(RGB(255,255,0));
77 Rectangle(hdc,10,10,110,110);
78 TextOut(hdc,15,45,"Hello, World!",13);
79
80 SelectObject(hdc,pinsel);
81 Ellipse(hdc,100,100,200,200);
82 Arc(hdc,120,120,180,180,100,200,200,200);
83 SetPixel(hdc,130,140,0);
84 SetPixel(hdc,170,140,0);
85 MoveToEx(hdc,150,100,0);
86 LineTo(hdc,145,90);
87 LineTo(hdc,155,80);
88 LineTo(hdc,150,75);
89}