我想知道是否可以为创建的子窗口指定 WndProc CreateWindowEx
。
我已经创建了一个窗口类、主窗口、窗口过程和一个消息循环。该代码有效,为了清楚我的问题,我决定将其保留。
到目前为止,这是我的 Window Proc:
LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
// Creation of the Win32 Window
case WM_CREATE:
// Add an Edit Field
CreateWindowEx(
WS_EX_CLIENTEDGE,
"EDIT",
"",
WS_CHILD | WS_VISIBLE,
5, 5, 200, 24,
hwnd,
(HMENU)100,
g_Instance, // Comming from WinMain
NULL
);
return DefWindowProc(hwnd, uMsg, lParam, wParam);
case WM_KEYDOWN:
// Track key presses on the edit field
std::cout << "The key with the code " << wParam << " was pressed." << std::endl;
return 0;
case WM_PAINT:
// Some painting code...
return DefWindowProc(hwnd, uMsg, lParam, wParam);
default:
return DefWindowProc(hwnd, uMsg, lParam, wParam);
}
}
我希望在我创建的子编辑字段上按下按键以抛出 WM_KEYDOWN 消息,但他们没有!键只是添加到我窗口中的编辑字段中,但不会导致 WM_KEYDOWN 消息。
似乎创建的编辑窗口不使用我的 WndProc。我该如何改变呢?