console window.
| 160 | |
| 161 | // console window. |
| 162 | LRESULT WINAPI MyConProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { |
| 163 | HDC hdc; |
| 164 | |
| 165 | switch (msg) { |
| 166 | case WM_CREATE: { |
| 167 | LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam; |
| 168 | con_Create(hWnd, lpcs); |
| 169 | break; |
| 170 | } |
| 171 | |
| 172 | case WM_PAINT: |
| 173 | con_Paint(hWnd); |
| 174 | break; |
| 175 | |
| 176 | case WM_SYSCOMMAND: |
| 177 | if (wParam == SC_CLOSE) { |
| 178 | return 0; |
| 179 | } |
| 180 | break; |
| 181 | |
| 182 | case WM_SETFOCUS: { |
| 183 | // The window has the input focus. Load the |
| 184 | // application-defined caret resource. |
| 185 | HFONT oldfont; |
| 186 | |
| 187 | hdc = GetDC(hWnd); |
| 188 | |
| 189 | oldfont = (HFONT)SelectObject(hdc, (HFONT)GetStockObject(ANSI_FIXED_FONT)); |
| 190 | SelectObject(hdc, oldfont); |
| 191 | CreateCaret(hWnd, NULL, Con_ch_w, Con_ch_h); |
| 192 | SetCaretPos(Con_col * Con_ch_w, Con_row * Con_ch_h); |
| 193 | ShowCaret(hWnd); |
| 194 | |
| 195 | ReleaseDC(hWnd, hdc); |
| 196 | break; |
| 197 | } |
| 198 | |
| 199 | case WM_KILLFOCUS: |
| 200 | // The window is losing the input focus, |
| 201 | // so destroy the caret. |
| 202 | DestroyCaret(); |
| 203 | break; |
| 204 | |
| 205 | case WM_KEYDOWN: |
| 206 | return con_KeyDown(hWnd, wParam); |
| 207 | |
| 208 | case WM_CHAR: |
| 209 | return con_Char(hWnd, wParam); |
| 210 | } |
| 211 | |
| 212 | return DefWindowProc(hWnd, msg, wParam, lParam); |
| 213 | } |
| 214 | |
| 215 | // console window helper functions |
| 216 | void con_Create(HWND hWnd, LPCREATESTRUCT lpcs) { |
nothing calls this directly
no test coverage detected