MinnisotaFreezing
Programmer
My declares
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
LRESULT CALLBACK btnProc (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK EditBoxProc (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK LstBoxProc (HWND, UINT, WPARAM, LPARAM);
WNDPROC oldBtn, oldEdit, oldList;
Under Create:
hwndEdit = CreateWindow (TEXT("edit", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT
| ES_MULTILINE , 3, 250, 5, 5, hwnd, (HMENU) 3, ((LPCREATESTRUCT)
lParam)->hInstance, NULL);
oldEdit = (WNDPROC) SetWindowLong (hwndEdit, GWL_WNDPROC, (LONG) EditBoxProc);
And finally the callback itself:
LRESULT CALLBACK EditBoxProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
hdc = GetDC(hwnd);
//TextOut(hdc, 3, 150 + 20, TEXT("Entered editProc", sizeof(TEXT("Entered editProc"));
switch (message)
{
case WM_KEYDOWN:
if (wParam == VK_RETURN)
{
TextOut(hdc, 3, 150 + 20, TEXT("Enter pushed in EditBoxProc", sizeof(TEXT("Enter pushed in EditBoxProc"));
}
break;
}
ReleaseDC(hwnd, hdc);
return CallWindowProc(oldEdit, hwnd, message, wParam, lParam);
}
My problem is that this does not catch the enter key being presed. I have two other child windows, and they have procedures that are almost identical to this one, and they trap the Enter key just fine. The example is:
LRESULT CALLBACK LstBoxProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
hdc = GetDC(hwnd);
CString MessageString = "Return Key pushed in LstBoxProc";
if (message == WM_KEYDOWN && wParam == VK_RETURN)
{
TextOut(hdc, 3, 150, TEXT(MessageString), strlen(MessageString));
}
ReleaseDC(hwnd, hdc);
return CallWindowProc(oldList, hwnd, message, wParam, lParam);
}
In the case of the non-working EditBoxProc, I did some testing, and I dont think my program ever even enters EditBoxProc, and I don't know why. Also, can anyone tell me how to change the color of my text in these posts? I would have liked to make my comments red. Like <textcolor>Red</textcolor>
Thank you very much in advance for your help
CJB
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
LRESULT CALLBACK btnProc (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK EditBoxProc (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK LstBoxProc (HWND, UINT, WPARAM, LPARAM);
WNDPROC oldBtn, oldEdit, oldList;
Under Create:
hwndEdit = CreateWindow (TEXT("edit", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT
| ES_MULTILINE , 3, 250, 5, 5, hwnd, (HMENU) 3, ((LPCREATESTRUCT)
lParam)->hInstance, NULL);
oldEdit = (WNDPROC) SetWindowLong (hwndEdit, GWL_WNDPROC, (LONG) EditBoxProc);
And finally the callback itself:
LRESULT CALLBACK EditBoxProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
hdc = GetDC(hwnd);
//TextOut(hdc, 3, 150 + 20, TEXT("Entered editProc", sizeof(TEXT("Entered editProc"));
switch (message)
{
case WM_KEYDOWN:
if (wParam == VK_RETURN)
{
TextOut(hdc, 3, 150 + 20, TEXT("Enter pushed in EditBoxProc", sizeof(TEXT("Enter pushed in EditBoxProc"));
}
break;
}
ReleaseDC(hwnd, hdc);
return CallWindowProc(oldEdit, hwnd, message, wParam, lParam);
}
My problem is that this does not catch the enter key being presed. I have two other child windows, and they have procedures that are almost identical to this one, and they trap the Enter key just fine. The example is:
LRESULT CALLBACK LstBoxProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
hdc = GetDC(hwnd);
CString MessageString = "Return Key pushed in LstBoxProc";
if (message == WM_KEYDOWN && wParam == VK_RETURN)
{
TextOut(hdc, 3, 150, TEXT(MessageString), strlen(MessageString));
}
ReleaseDC(hwnd, hdc);
return CallWindowProc(oldList, hwnd, message, wParam, lParam);
}
In the case of the non-working EditBoxProc, I did some testing, and I dont think my program ever even enters EditBoxProc, and I don't know why. Also, can anyone tell me how to change the color of my text in these posts? I would have liked to make my comments red. Like <textcolor>Red</textcolor>
Thank you very much in advance for your help
CJB