Exemple #1
0
static void test_appbarget(void)
{
    APPBARDATA abd;
    HWND hwnd, foregnd, unset_hwnd;
    UINT_PTR ret;

    memset(&abd, 0xcc, sizeof(abd));
    memset(&unset_hwnd, 0xcc, sizeof(unset_hwnd));
    abd.cbSize = sizeof(abd);
    abd.uEdge = ABE_BOTTOM;

    hwnd = (HWND)SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
    ok(hwnd == NULL || IsWindow(hwnd), "ret %p which is not a window\n", hwnd);
    ok(abd.hWnd == unset_hwnd, "hWnd overwritten %p\n",abd.hWnd);

    if (!pMonitorFromWindow)
    {
        win_skip("MonitorFromWindow is not available\n");
    }
    else
    {
        /* Presumably one can pass a hwnd with ABM_GETAUTOHIDEBAR to specify a monitor.
           Pass the foreground window and check */
        foregnd = GetForegroundWindow();
        if(foregnd)
        {
            abd.hWnd = foregnd;
            hwnd = (HWND)SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd);
            ok(hwnd == NULL || IsWindow(hwnd), "ret %p which is not a window\n", hwnd);
            ok(abd.hWnd == foregnd, "hWnd overwritten\n");
            if(hwnd)
            {
                HMONITOR appbar_mon, foregnd_mon;
                appbar_mon = pMonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
                foregnd_mon = pMonitorFromWindow(foregnd, MONITOR_DEFAULTTONEAREST);
                ok(appbar_mon == foregnd_mon, "Windows on different monitors\n");
            }
        }
    }

    memset(&abd, 0xcc, sizeof(abd));
    abd.cbSize = sizeof(abd);
    ret = SHAppBarMessage(ABM_GETTASKBARPOS, &abd);
    if(ret)
    {
        ok(abd.hWnd == (HWND)0xcccccccc, "hWnd overwritten\n");
        ok(abd.uEdge <= ABE_BOTTOM ||
            broken(abd.uEdge == 0xcccccccc), /* Some Win95 and NT4 */
            "uEdge not returned\n");
        ok(abd.rc.left != 0xcccccccc, "rc not updated\n");
    }

    return;
}
HMONITOR get_monitor(HWND hw)
{
	if (NULL == pMonitorFromWindow)
	{
		HMODULE hDll = GetModuleHandle("USER32");
		*(FARPROC*)&pMonitorFromWindow = GetProcAddress(hDll, "MonitorFromWindow" );
		*(FARPROC*)&pGetMonitorInfoA   = GetProcAddress(hDll, "GetMonitorInfoA"   );
		if (NULL == pMonitorFromWindow)
			*(int*)&pMonitorFromWindow = 1;
	}

	if (*(DWORD*)&pMonitorFromWindow <= 1)
		return NULL;

	return pMonitorFromWindow(hw, MONITOR_DEFAULTTOPRIMARY);
}
Exemple #3
0
void get_workarea (HWND hwnd, RECT * w, RECT * s)
{
    static HMONITOR (WINAPI *pMonitorFromWindow)(HWND hwnd, DWORD dwFlags);
    static BOOL     (WINAPI *pGetMonitorInfoA)(HMONITOR hMonitor, LPMONITORINFO lpmi);

    if (NULL == pMonitorFromWindow)
    {
        HMODULE hUserDll = GetModuleHandle("USER32.DLL");
        *(FARPROC*)&pMonitorFromWindow = GetProcAddress(hUserDll, "MonitorFromWindow" );
        *(FARPROC*)&pGetMonitorInfoA = GetProcAddress(hUserDll, "GetMonitorInfoA"   );
        if (NULL == pMonitorFromWindow) *(DWORD*)&pMonitorFromWindow = 1;
    }

    if (*(DWORD*)&pMonitorFromWindow > 1)
    {
        MONITORINFO mi; mi.cbSize = sizeof(mi);
        HMONITOR hMon = pMonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
        if (hMon && pGetMonitorInfoA(hMon, &mi))
        {
            if (w) *w = mi.rcWork;
            if (s) *s = mi.rcMonitor;
            return;
        }
    }

    if (w)
    {
        SystemParametersInfo(SPI_GETWORKAREA, 0, w, 0);
    }

    if (s)
    {
        s->left = s->top = 0;
        s->right = GetSystemMetrics(SM_CXSCREEN);
        s->bottom = GetSystemMetrics(SM_CYSCREEN);
    }
}