使用DestroyWindow的Firebrreath插件崩溃

时间:2014-06-04 14:30:11

标签: c++ boost window firebreath

我需要一种在firebreath中销毁我的窗口的方法,但是当我使用DestroyWindow()时,插件崩溃,而CloseWindow()对我来说不是一个可行的选择。我使用gInstance创建窗口,否则窗口不会更新。所以我猜这个错误/崩溃有两种选择,要么使用另一种方法来破坏窗口,要么使用另一种方法来构建窗口。

这是我的电话

CalibrationScreen(gInstance, NULL, (LPSTR)"test", SW_SHOW);

这是函数

int WINAPI TobiiWrapper::CalibrationScreen(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR           gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

wc.cbSize        = sizeof(WNDCLASSEX);
wc.style         = 0;
wc.lpfnWndProc   = WndProc;
wc.cbClsExtra    = 0;
wc.cbWndExtra    = 0;
wc.hInstance     = hInstance;
wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName  = NULL;
wc.lpszClassName = lpCmdLine;
wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

if(!RegisterClassEx(&wc))
{
    return 0;
}

full_screen_window = CreateWindowEx(
    WS_EX_TOPMOST,
    lpCmdLine,
    (LPCSTR)"Tobii Calibration Screen",
    WS_POPUP,
    CW_USEDEFAULT, CW_USEDEFAULT,
    _screenWidth, _screenHeight,
    NULL, NULL, hInstance, NULL);

if(full_screen_window == NULL)
{
    return 0;
}

ShowWindow(full_screen_window, nCmdShow);
UpdateWindow(full_screen_window);
GdiSetBatchLimit(1);

PAINTSTRUCT  ps;
hdc = BeginPaint(full_screen_window, &ps);
startNextOrFinish(); //run through target loop
EndPaint(full_screen_window, &ps);
CloseWindow(full_screen_window);
DestroyWindow(full_screen_window);

return 0;
}

如果你需要WndProc

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
    case WM_PAINT:
        return 0;
    case WM_CLOSE:
        DestroyWindow(hwnd);
    break;
    case WM_QUIT:
    case WM_DESTROY:
        PostQuitMessage(0);
    break;
    case WM_KEYDOWN:
    case WM_CHAR:  
        DestroyWindow(hwnd);
        break;
    default:
        return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}

0 个答案:

没有答案