4 LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
6 const TCHAR* CLASS_NAME = _T("LineTestClass");
9 WinMain(HINSTANCE hInstance,
10 HINSTANCE hPrevInstance,
18 wc.lpszClassName = CLASS_NAME;
19 wc.lpfnWndProc = MainWndProc;
20 wc.style = CS_VREDRAW | CS_HREDRAW;
21 wc.hInstance = hInstance;
22 wc.hIcon = LoadIcon(NULL, (LPCSTR)IDI_APPLICATION);
23 wc.hCursor = LoadCursor(NULL, (LPCSTR)IDC_ARROW);
24 wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
25 wc.lpszMenuName = NULL;
28 if (RegisterClass(&wc) == 0)
30 fprintf(stderr, "RegisterClass failed (last error 0x%X)\n",
35 hWnd = CreateWindow(CLASS_NAME,
36 _T("Line drawing test"),
48 fprintf(stderr, "CreateWindow failed (last error 0x%X)\n",
53 ShowWindow(hWnd, nCmdShow);
55 while(GetMessage(&msg, NULL, 0, 0))
57 TranslateMessage(&msg);
58 DispatchMessage(&msg);
64 #define red RGB(255,0,0)
65 #define grn RGB(0,255,0)
66 #define blu RGB(0,0,255)
67 #define blk RGB(0,0,0)
82 { 10, 10, 19, 10, red },
83 { 20, 10, 20, 19, grn },
84 { 20, 20, 11, 20, blu },
85 { 10, 20, 10, 11, blk },
86 { 12, 12, 15, 15, red },
87 { 18, 12, 15, 15, grn },
88 { 18, 18, 15, 15, blu },
89 { 12, 18, 15, 15, blk },
91 { 35, 10, 39, 14, red },
92 { 40, 15, 36, 19, grn },
93 { 35, 20, 31, 16, blu },
94 { 30, 15, 34, 11, blk },
101 { 50, 1, 51, 1, red },
102 { 50, 2, 52, 2, grn },
103 { 50, 3, 53, 3, blu },
104 { 50, 4, 54, 4, blk },
105 { 50, 5, 55, 5, red },
106 { 50, 6, 56, 6, grn },
107 { 50, 7, 57, 7, blu },
108 { 50, 8, 58, 8, blk },
109 { 50, 9, 59, 9, red },
110 { 50, 10, 60, 10, grn },
111 { 50, 11, 61, 11, blu },
112 { 50, 12, 62, 12, blk },
114 { 50, 14, 62, 14, red },
115 { 51, 15, 62, 15, grn },
116 { 52, 16, 62, 16, blu },
117 { 53, 17, 62, 17, blk },
118 { 54, 18, 62, 18, red },
119 { 55, 19, 62, 19, grn },
120 { 56, 20, 62, 20, blu },
121 { 57, 21, 62, 21, blk },
122 { 58, 22, 62, 22, red },
123 { 59, 23, 62, 23, grn },
124 { 60, 24, 62, 24, blu },
125 { 61, 25, 62, 25, blk },
129 for (i = 0; i < sizeof(points) / sizeof(points[0]); i++)
132 hpen = CreatePen ( PS_SOLID, 0, points[i].clr );
133 hpenold = (HPEN)SelectObject ( hDC, hpen );
134 MoveToEx ( hDC, points[i].fromx, points[i].fromy, NULL );
135 LineTo ( hDC, points[i].tox, points[i].toy );
136 SelectObject ( hDC, hpenold );
137 DeleteObject ( hpen );
141 LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
151 GetClientRect(hWnd, &clr);
152 //ClipRgn = CreateRectRgnIndirect(&clr);
153 hDC = BeginPaint(hWnd, &ps);
158 //FillRect(hDC, &Rect, CreateSolidBrush(RGB(0xFF, 0x00, 0x00)));
159 //ExcludeRgn = CreateRectRgnIndirect(&Rect);
160 //CombineRgn(ClipRgn, ClipRgn, ExcludeRgn, RGN_DIFF);
161 //DeleteObject(ExcludeRgn);
166 hbr = CreateSolidBrush(RGB(255, 255, 255));
167 FillRect ( hDC, &clr, hbr );
168 DeleteObject ( hbr );
178 return DefWindowProc(hWnd, msg, wParam, lParam);