这是我的类构造函数:
ActionButton::ActionButton(CallbackFunction function, void* param, HWND parent, int x, int y, int heigth, int width) :
m_function(function), m_parameters(param), m_window(NULL)
{
HWND m_window = CreateWindowEx(0, L"Action button", NULL, WS_CHILD | WS_VISIBLE,
x, y, width, heigth, parent, NULL, NULL, NULL);
DWORD dw = GetLastError();
SetWindowLongPtr(m_window, GWLP_USERDATA, (LONG_PTR)this);
ShowWindow(m_window, SW_NORMAL);
}
我使用了调试器,发现它可以执行CreateWindowEx()
,但是在按 F11 后程序跳出了构造函数(而且我只使用一个线程)。我的代码有问题吗?
在CreateWindowEx
执行带有参数的窗口过程之后,例如WM_CREATE
,因此步骤之后CreateWindowEx
不在构造函数中,在执行一些窗口过程回调后,它会返回到构造函数。