7 LRESULT WINAPI
MainWndProc(HWND
, UINT
, WPARAM
, LPARAM
);
9 const TCHAR
* CLASS_NAME
= _T("LineTestClass");
12 WinMain(HINSTANCE hInstance
,
13 HINSTANCE hPrevInstance
,
21 wc
.lpszClassName
= CLASS_NAME
;
22 wc
.lpfnWndProc
= MainWndProc
;
23 wc
.style
= CS_VREDRAW
| CS_HREDRAW
;
24 wc
.hInstance
= hInstance
;
25 wc
.hIcon
= LoadIcon(NULL
, (LPCSTR
)IDI_APPLICATION
);
26 wc
.hCursor
= LoadCursor(NULL
, (LPCSTR
)IDC_ARROW
);
27 wc
.hbrBackground
= (HBRUSH
)GetStockObject(GRAY_BRUSH
);
28 wc
.lpszMenuName
= NULL
;
31 if (RegisterClass(&wc
) == 0)
33 fprintf(stderr
, "RegisterClass failed (last error 0x%lX)\n",
38 hWnd
= CreateWindow(CLASS_NAME
,
39 _T("Line drawing test"),
51 fprintf(stderr
, "CreateWindow failed (last error 0x%lX)\n",
56 ShowWindow(hWnd
, nCmdShow
);
58 while(GetMessage(&msg
, NULL
, 0, 0))
60 TranslateMessage(&msg
);
61 DispatchMessage(&msg
);
67 #define red RGB(255,0,0)
68 #define grn RGB(0,255,0)
69 #define blu RGB(0,0,255)
70 #define blk RGB(0,0,0)
85 { 10, 10, 19, 10, red
},
86 { 20, 10, 20, 19, grn
},
87 { 20, 20, 11, 20, blu
},
88 { 10, 20, 10, 11, blk
},
89 { 12, 12, 15, 15, red
},
90 { 18, 12, 15, 15, grn
},
91 { 18, 18, 15, 15, blu
},
92 { 12, 18, 15, 15, blk
},
94 { 35, 10, 39, 14, red
},
95 { 40, 15, 36, 19, grn
},
96 { 35, 20, 31, 16, blu
},
97 { 30, 15, 34, 11, blk
},
104 { 50, 1, 51, 1, red
},
105 { 50, 2, 52, 2, grn
},
106 { 50, 3, 53, 3, blu
},
107 { 50, 4, 54, 4, blk
},
108 { 50, 5, 55, 5, red
},
109 { 50, 6, 56, 6, grn
},
110 { 50, 7, 57, 7, blu
},
111 { 50, 8, 58, 8, blk
},
112 { 50, 9, 59, 9, red
},
113 { 50, 10, 60, 10, grn
},
114 { 50, 11, 61, 11, blu
},
115 { 50, 12, 62, 12, blk
},
117 { 50, 14, 62, 14, red
},
118 { 51, 15, 62, 15, grn
},
119 { 52, 16, 62, 16, blu
},
120 { 53, 17, 62, 17, blk
},
121 { 54, 18, 62, 18, red
},
122 { 55, 19, 62, 19, grn
},
123 { 56, 20, 62, 20, blu
},
124 { 57, 21, 62, 21, blk
},
125 { 58, 22, 62, 22, red
},
126 { 59, 23, 62, 23, grn
},
127 { 60, 24, 62, 24, blu
},
128 { 61, 25, 62, 25, blk
},
132 for (i
= 0; i
< sizeof(points
) / sizeof(points
[0]); i
++)
135 hpen
= CreatePen ( PS_SOLID
, 0, points
[i
].clr
);
136 hpenold
= (HPEN
)SelectObject ( hDC
, hpen
);
137 MoveToEx ( hDC
, points
[i
].fromx
, points
[i
].fromy
, NULL
);
138 LineTo ( hDC
, points
[i
].tox
, points
[i
].toy
);
139 SelectObject ( hDC
, hpenold
);
140 DeleteObject ( hpen
);
144 LRESULT CALLBACK
MainWndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
154 GetClientRect(hWnd
, &clr
);
155 //ClipRgn = CreateRectRgnIndirect(&clr);
156 hDC
= BeginPaint(hWnd
, &ps
);
161 //FillRect(hDC, &Rect, CreateSolidBrush(RGB(0xFF, 0x00, 0x00)));
162 //ExcludeRgn = CreateRectRgnIndirect(&Rect);
163 //CombineRgn(ClipRgn, ClipRgn, ExcludeRgn, RGN_DIFF);
164 //DeleteObject(ExcludeRgn);
169 hbr
= CreateSolidBrush(RGB(255, 255, 255));
170 FillRect ( hDC
, &clr
, hbr
);
171 DeleteObject ( hbr
);
181 return DefWindowProc(hWnd
, msg
, wParam
, lParam
);