1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static bool bRedraw = false;
// Message Interpretation
switch (uMsg)
{
// In the case that the window is closed
case WM_DESTROY:
PostQuitMessage(0);
return 0;
// In the case that a key is pressed
// This is where the problem is, I want to write out some text
// (in this case WIN) when I hit enter while the window is in focus,
// but when I do, nothing happens.
case WM_KEYDOWN:
switch (wParam)
{
// In the case which that key is enter
case (VK_RETURN):
bRedraw = true;
SendMessage(hwnd, WM_PAINT, wParam, lParam);
bRedraw = false;
break;
}
return 0;
// In the case that the window is drawn
case WM_PAINT:
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1));
TextOut(hdc, 10, 10, L"Prospect Number:", 16);
TextOut(hdc, 10, 34, L"Delete Code:", 12);
TextOut(hdc, 10, 58, L"Current Delete Code:", 20);
if (bRedraw)
{
TextOut(hdc, 10, 82, L"WIN", 3);
}
EndPaint(hwnd, &ps);
return 0;
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
|