Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用GDI在我的窗口周围绘制边框,不会';不行?_C++_Windows_Winapi_Border_Gdi - Fatal编程技术网

C++ 使用GDI在我的窗口周围绘制边框,不会';不行?

C++ 使用GDI在我的窗口周围绘制边框,不会';不行?,c++,windows,winapi,border,gdi,C++,Windows,Winapi,Border,Gdi,我试图在我的窗口周围画一个边框,但我的代码似乎不起作用。它没有画任何东西。谁能告诉我有什么问题吗 LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { HDC hDC = 0; PAINTSTRUCT ps; ZeroMemory(&ps, sizeof(PAINTSTRUCT)); HPEN hp353535 = 0; RECT rWnd;

我试图在我的窗口周围画一个边框,但我的代码似乎不起作用。它没有画任何东西。谁能告诉我有什么问题吗

LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    HDC hDC = 0;
    PAINTSTRUCT ps;
    ZeroMemory(&ps, sizeof(PAINTSTRUCT));
    HPEN hp353535 = 0;
    RECT rWnd;
    GetWindowRect(hWnd, &rWnd);

    switch(msg)
    {
        case WM_PAINT:
            // I could/should put GetWindowRect() here..
            hDC = BeginPaint(hWnd, &ps);
            hp353535 = CreatePen(PS_SOLID, 7, RGB(247, 247, 247));
            SelectObject(hDC, hp353535);
            MoveToEx(hDC, rWnd.left, rWnd.top, 0);
            LineTo(hDC, rWnd.right, rWnd.top);
            LineTo(hDC, rWnd.right, rWnd.bottom);
            LineTo(hDC, rWnd.left, rWnd.bottom);
            LineTo(hDC, rWnd.left, rWnd.top);
            DeleteObject(hp353535);
            EndPaint(hWnd, &ps);
            break;

        // More cases
    }
}

GetWindowRect()返回屏幕坐标,而绘图使用客户端坐标(即相对于窗口左上角)。我认为使用GetClientRect()会有所帮助。

GetWindowRect()返回屏幕坐标,而绘图使用客户端坐标(即相对于窗口左上角)。我认为使用GetClientRect()会有所帮助。

真该死,太简单了!非常感谢。现在可以用了只要时间允许,我会接受你的回答。啊,该死,太简单了!非常感谢。现在可以用了一旦时间允许,我会接受你的回答。