最小化现代版Windows上的窗口是否仍将其移动到坐标(-32000,-32000)?

时间:2015-07-31 21:39:29

标签: screen window-managers windows-nt

根据Raymond Chen的this blog entry,Windows NT"最小化"通过将它们移动到坐标(-32000,-32000),并且在声明的句子的上下文中,它暗示在Windows NT的早期版本中就是这种情况( 3.x,4 ......)。

在Windows NT的现代版本(例如7,8和10)中,情况仍然如此吗?

是否有一个程序可以编写以在现代Windows操作系统上演示此功能的存在与否?

1 个答案:

答案 0 :(得分:0)

回答我自己的问题......我写了一个小C程序来完成我的要求。基本上,它创建一个带代码的窗口,这样如果窗口的位置在x或y维度中变为负值,它会将静态文本字段的文本设置为新坐标。

在Windows 10 RTM上输出此程序:

Output of this program

#include <Windows.h>
#include <tchar.h>
#include <strsafe.h>

TCHAR g_szClassName[] = _T("CoordReportWnd");

LRESULT CALLBACK WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK EnumChildProc(HWND hWnd, LPARAM lParam);

ATOM RegisterWCEX(HINSTANCE hInstance)
{
    WNDCLASSEX wcex;
    ZeroMemory(&wcex, sizeof(WNDCLASSEX));

    wcex.cbSize = sizeof(WNDCLASSEX);
    wcex.lpfnWndProc = WindowProc;
    wcex.hInstance = hInstance;
    wcex.lpszMenuName = NULL;
    wcex.lpszClassName = g_szClassName;
    wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
    wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground = (HBRUSH)COLOR_WINDOW;
    wcex.cbClsExtra = 0;
    wcex.cbWndExtra = 0;
    wcex.style = 0;

    return RegisterClassEx(&wcex);
}

BOOL CALLBACK EnumChildProc(HWND hWnd, LPARAM lParam)
{
    HFONT hfDefault = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
    SendMessage(hWnd, WM_SETFONT, (WPARAM)hfDefault, 0);
    return TRUE;
}

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
    HWND hWnd, hStatic;
    MSG Msg;

    if (!RegisterWCEX(hInstance))
    {
        MessageBox(0, _T("Window registration failed!"), _T("Error"), MB_ICONSTOP);
        return -1;
    }

    hWnd = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, g_szClassName, _T("Minimize Me"), WS_VISIBLE | WS_SYSMENU | WS_MINIMIZEBOX, 100, 100, 200, 150, NULL, NULL, GetModuleHandle(NULL), NULL);
    hStatic = CreateWindow(_T("Static"), _T(""), WS_VISIBLE | WS_CHILD, 10, 10, 180, 20, hWnd, NULL, GetModuleHandle(NULL), NULL);
    ShowWindow(hWnd, SW_SHOW);
    EnumChildWindows(hWnd, EnumChildProc, 0L);
    UpdateWindow(hWnd);

    while (GetMessage(&Msg, NULL, 0, 0) > 0)
    {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }
    return Msg.wParam;
}

LRESULT CALLBACK WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
    switch (Msg)
    {
    case WM_CLOSE:
        DestroyWindow(hWnd);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    case WM_WINDOWPOSCHANGED:
    {
        PWINDOWPOS pWP = (PWINDOWPOS)lParam;
        if (pWP->x < 0 || pWP->y < 0)
        {
            TCHAR stTxt[64];
            HWND hStatic = FindWindowEx(hWnd, NULL, _T("Static"), NULL);
            StringCchPrintf(stTxt, 64, _T("(%d, %d)"), pWP->x, pWP->y);
            SetWindowText(hStatic, stTxt);
        }
    }
    default:
        return DefWindowProc(hWnd, Msg, wParam, lParam);
    }
    return 0;
}

运行时,如果最小化然后重新最大化,则显示(-32000,-32000),表示窗口在最小化时移动到的位置。