Kai Tietz | 1e44680 | 2007-08-20 14:25:57 +0000 | [diff] [blame] | 1 | /** |
| 2 | * This file has no copyright assigned and is placed in the Public Domain. |
Rafaël Carré | 8a67ab4 | 2012-06-28 15:40:59 +0000 | [diff] [blame] | 3 | * This file is part of the mingw-w64 runtime package. |
Kai Tietz | fa0cfe3 | 2010-01-15 20:02:21 +0000 | [diff] [blame] | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
Kai Tietz | 1e44680 | 2007-08-20 14:25:57 +0000 | [diff] [blame] | 5 | */ |
Ozkan Sezer | daabd71 | 2009-08-22 18:11:19 +0000 | [diff] [blame] | 6 | #ifndef WIN32_LEAN_AND_MEAN |
Kai Tietz | 518dd33 | 2007-08-10 09:54:15 +0000 | [diff] [blame] | 7 | #define WIN32_LEAN_AND_MEAN |
Ozkan Sezer | daabd71 | 2009-08-22 18:11:19 +0000 | [diff] [blame] | 8 | #endif |
Kai Tietz | 518dd33 | 2007-08-10 09:54:15 +0000 | [diff] [blame] | 9 | #include <windows.h> |
| 10 | |
| 11 | #define TITLE "WinMain" |
| 12 | #define WIDTH 250 |
| 13 | #define HEIGHT 250 |
| 14 | |
| 15 | void Draw(HDC hdc); |
| 16 | |
| 17 | LRESULT 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 | |
| 36 | char szClassName[] = "WinMain"; |
| 37 | |
| 38 | int 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 | |
| 73 | void 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 | } |