예제 #1
0
HWND uie::window::g_on_tab(HWND wnd_focus)
{
	HWND rv = 0;
	
	HWND wnd_temp = GetAncestor(wnd_focus, GA_ROOT);/*_GetParent(wnd_focus);
	
	while (wnd_temp && GetWindowLong(wnd_temp, GWL_EXSTYLE) & WS_EX_CONTROLPARENT)
	{
		if (GetWindowLong(wnd_temp, GWL_STYLE) & WS_POPUP) break;
		else wnd_temp = _GetParent(wnd_temp);
	}*/
	
	if (wnd_temp)
	{
		HWND wnd_next = GetNextDlgTabItem(wnd_temp, wnd_focus, (GetKeyState(VK_SHIFT) & KF_UP) ? TRUE :  FALSE);
		if (wnd_next && wnd_next != wnd_focus) 
		{
			unsigned flags = uSendMessage(wnd_next, WM_GETDLGCODE, 0, 0);
			if (flags & DLGC_HASSETSEL) uSendMessage(wnd_next, EM_SETSEL, 0, -1);
			SetFocus(wnd_next);
			
			rv = wnd_next;
		}
	}
	return rv;
};
예제 #2
0
static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult)
{
	uiColorButton *b = uiColorButton(c);
	HWND parent;
	struct colorDialogRGBA rgba;

	if (code != BN_CLICKED)
		return FALSE;

	parent = GetAncestor(b->hwnd, GA_ROOT);		// TODO didn't we have a function for this
	rgba.r = b->r;
	rgba.g = b->g;
	rgba.b = b->b;
	rgba.a = b->a;
	if (showColorDialog(parent, &rgba)) {
		b->r = rgba.r;
		b->g = rgba.g;
		b->b = rgba.b;
		b->a = rgba.a;
		invalidateRect(b->hwnd, NULL, TRUE);
		(*(b->onChanged))(b, b->onChangedData);
	}

	*lResult = 0;
	return TRUE;
}
예제 #3
0
파일: html.c 프로젝트: ArmstrongJ/mctrl
static HRESULT STDMETHODCALLTYPE
inplace_frame_GetWindow(IOleInPlaceFrame* self, HWND* win)
{
    HTML_TRACE("inplace_frame_GetWindow");
    *win = GetAncestor(MC_HTML_FROM_INPLACE_FRAME(self)->win, GA_ROOT);
    return(S_OK);
}
예제 #4
0
bool IsShellWindow(HWND window)
{
    if(!IsWindow(window) || !IsWindowVisible(window))
    {
        return false;
    }
    if(GetAncestor(window, GA_PARENT) != GetDesktopWindow())
    {
        return false;
    }

    RECT clientRect;
    GetClientRect(window, &clientRect);
    if(clientRect.right - clientRect.left <= 1 || clientRect.bottom - clientRect.top <= 1)
    {
        return false;
    }
    
    char name[256] = {'\0'};
    GetWindowText(window, name, 256);
    String sName = name;
    if(sName.Length() == 0 || sName == "Start")
    {
        return false;
    }

    return true;
}
예제 #5
0
파일: menubar.c 프로젝트: Strongc/mctrl
static menubar_t*
menubar_nccreate(HWND win, CREATESTRUCT *cs)
{
    menubar_t* mb;
    TCHAR parent_class[16];

    MENUBAR_TRACE("menubar_nccreate(%p, %p)", win, cs);

    mb = (menubar_t*) malloc(sizeof(menubar_t));
    if(MC_ERR(mb == NULL)) {
        MC_TRACE("menubar_nccreate: malloc() failed.");
        return NULL;
    }

    memset(mb, 0, sizeof(menubar_t));
    mb->win = win;

    /* Lets be a little friendly to the app. developers: If the parent is
     * ReBar control, lets send WM_NOTIFY/WM_COMMAND to the ReBar's parent
     * as ReBar really is not interested in it, and embedding the menubar
     * in the ReBar is actually main advantage of this control in comparison
     * with the standard window menu. */
    GetClassName(cs->hwndParent, parent_class, MC_SIZEOF_ARRAY(parent_class));
    if(_tcscmp(parent_class, _T("ReBarWindow32")) == 0)
        mb->notify_win = GetAncestor(cs->hwndParent, GA_PARENT);
    else
        mb->notify_win = cs->hwndParent;

    mb->hot_item = -1;
    mb->pressed_item = -1;

    return mb;
}
예제 #6
0
BOOL IsAltTabWindow(HWND hwnd)
{
    long wndStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
    if(GetWindowTextLength(hwnd) == 0)
        return false;

    // Ignore desktop window.
    if (hwnd == GetShellWindow())
        return(false);

    if(wndStyle & WS_EX_TOOLWINDOW)
        return(false);

    // Start at the root owner
    HWND hwndWalk = GetAncestor(hwnd, GA_ROOTOWNER);

    // See if we are the last active visible popup
    HWND hwndTry;
    while ((hwndTry = GetLastActivePopup(hwndWalk)) != hwndTry)
    {
        if (IsWindowVisible(hwndTry))
            break;
        hwndWalk = hwndTry;
    }
    return hwndWalk == hwnd;
}
예제 #7
0
// https://blogs.msdn.microsoft.com/oldnewthing/20071008-00/?p=24863/
static bool is_alttab_window(HWND const Window)
{
	if (!IsWindowVisible(Window))
		return false;

	auto Try = GetAncestor(Window, GA_ROOTOWNER);
	HWND Walk = nullptr;
	while (Try != Walk)
	{
		Walk = Try;
		Try = GetLastActivePopup(Walk);
		if (IsWindowVisible(Try))
			break;
	}
	if (Walk != Window)
		return false;

	// Tool windows should not be displayed either, these do not appear in the task bar
	if (GetWindowLongPtr(Window, GWL_EXSTYLE) & WS_EX_TOOLWINDOW)
		return false;

	if (IsWindows8OrGreater())
	{
		int Cloaked = 0;
		if (SUCCEEDED(imports.DwmGetWindowAttribute(Window, DWMWA_CLOAKED, &Cloaked, sizeof(Cloaked))) && Cloaked)
			return false;
	}

	return true;
}
예제 #8
0
파일: event.c 프로젝트: howard5888/wineT
/**********************************************************************
 *              EVENT_FocusIn
 */
static void EVENT_FocusIn( HWND hwnd, XEvent *xev )
{
    XFocusChangeEvent *event = &xev->xfocus;
    XIC xic;

    if (!hwnd) return;

    TRACE( "win %p xwin %lx detail=%s\n", hwnd, event->window, focus_details[event->detail] );

    if (event->detail == NotifyPointer) return;

    if ((xic = X11DRV_get_ic( hwnd )))
    {
        wine_tsx11_lock();
        XSetICFocus( xic );
        wine_tsx11_unlock();
    }
    if (use_take_focus) return;  /* ignore FocusIn if we are using take focus */

    if (!can_activate_window(hwnd))
    {
        HWND hwnd = GetFocus();
        if (hwnd) hwnd = GetAncestor( hwnd, GA_ROOT );
        if (!hwnd) hwnd = GetActiveWindow();
        if (!hwnd) hwnd = x11drv_thread_data()->last_focus;
        if (hwnd && can_activate_window(hwnd)) set_focus( hwnd, CurrentTime );
    }
    else SetForegroundWindow( hwnd );
}
예제 #9
0
파일: window.c 프로젝트: emonkak/cereja
static int
ui_window_lower(lua_State* L)  /* emulate Alt-Esc. */
{
	HWND hwnd = NULL;
	HWND root;
	HWND next_hwnd;
	BOOL syncp = FALSE;
	Crj_ParseArgs(L, "| u Q", &hwnd, &syncp);
	hwnd = GetTargetWindow(hwnd);

	root = GetAncestor(hwnd, GA_ROOT);
	if (root != NULL)
		hwnd = root;

	if (!IsTopmostP(hwnd)) {
		if (hwnd == GetForegroundWindow()) {
			next_hwnd = GetNextAppWindow(hwnd, FALSE);
			if (next_hwnd != NULL)
				SetForegroundWindow(next_hwnd);
		}
		SetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0,
		             (((!syncp) ? SWP_ASYNCWINDOWPOS : 0)
		              | SWP_NOACTIVATE
		              | SWP_NOMOVE
		              | SWP_NOOWNERZORDER
		              | SWP_NOSIZE));
	} else {
		if (hwnd == GetForegroundWindow()) {
			next_hwnd = GetNextAppWindow(hwnd, TRUE);
			if (next_hwnd != NULL)
				SetForegroundWindow(next_hwnd);
		}
	}
	return 0;
}
예제 #10
0
/***********************************************************************
 *              send_mouse_input
 *
 * Update the various window states on a mouse event.
 */
static void send_mouse_input(HWND hwnd, UINT flags, int x, int y,
                             DWORD mouse_data, unsigned long time)
{
    INPUT input;
    HWND top_level_hwnd;

    top_level_hwnd = GetAncestor(hwnd, GA_ROOT);

    if ((flags & MOUSEEVENTF_MOVE) && (flags & MOUSEEVENTF_ABSOLUTE))
    {
        RECT rect;

        /* update the wine server Z-order */
        SetRect(&rect, x, y, x + 1, y + 1);
        MapWindowPoints(0, top_level_hwnd, (POINT *)&rect, 2);

        SERVER_START_REQ(update_window_zorder)
        {
            req->window      = wine_server_user_handle(top_level_hwnd);
            req->rect.left   = rect.left;
            req->rect.top    = rect.top;
            req->rect.right  = rect.right;
            req->rect.bottom = rect.bottom;
            wine_server_call(req);
        }
        SERVER_END_REQ;
    }
예제 #11
0
파일: config.c 프로젝트: alex310110/altdrag
LRESULT CALLBACK CursorProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
  if (msg == WM_LBUTTONDOWN || msg == WM_MBUTTONDOWN || msg == WM_RBUTTONDOWN) {
    ShowWindow(hwnd, SW_HIDE);
    HWND page = PropSheet_GetCurrentPageHwnd(g_cfgwnd);

    if (msg == WM_LBUTTONDOWN) {
      POINT pt;
      GetCursorPos(&pt);
      HWND window = WindowFromPoint(pt);
      window = GetAncestor(window, GA_ROOT);

      wchar_t title[256], classname[256];
      GetWindowText(window, title, ARRAY_SIZE(title));
      GetClassName(window, classname, ARRAY_SIZE(classname));

      wchar_t txt[1000];
      swprintf(txt, L"%s|%s", title, classname);
      SetDlgItemText(page, IDC_NEWRULE, txt);
    }

    // Show icon again
    ShowWindowAsync(GetDlgItem(page,IDC_FINDWINDOW), SW_SHOW);

    DestroyWindow(hwnd);
  }
  return DefWindowProc(hwnd, msg, wParam, lParam);
}
예제 #12
0
INT_PTR CloseCurrentSession(WPARAM wparam,LPARAM lparam)
{
	HWND hWnd;
	int i=0;
	MessageWindowInputData  mwid;
	MessageWindowData  mwd;

	while(session_list[0]!=0)
	{
		mwid.cbSize = sizeof(MessageWindowInputData);
		mwid.hContact=session_list[i];
		mwid.uFlags=MSG_WINDOW_UFLAG_MSG_BOTH;

		mwd.cbSize = sizeof(MessageWindowData);
		mwd.hContact = mwid.hContact;
		mwd.uFlags=MSG_WINDOW_UFLAG_MSG_BOTH;
		CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&mwid,(LPARAM)&mwd);

		if (g_mode)
		{
			hWnd=GetAncestor(mwd.hwndWindow,GA_ROOT);
			SendMessage(hWnd,WM_CLOSE,0,1);
		}
		else SendMessage(mwd.hwndWindow, WM_CLOSE, 0, 0);
	}
	ZeroMemory(session_list,SIZEOF(session_list));
	return 0;
}
예제 #13
0
/*******************************************************************
 *         WINPOS_ActivateOtherWindow
 *
 *  Activates window other than pWnd.
 */
void
WINAPI
WinPosActivateOtherWindow(HWND hwnd)
{
    HWND hwndTo, fg;

    if ((GetWindowLongPtrW( hwnd, GWL_STYLE ) & WS_POPUP) && (hwndTo = GetWindow( hwnd, GW_OWNER )))
    {
        hwndTo = GetAncestor( hwndTo, GA_ROOT );
        if (can_activate_window( hwndTo )) goto done;
    }

    hwndTo = hwnd;
    for (;;)
    {
        if (!(hwndTo = GetWindow( hwndTo, GW_HWNDNEXT ))) break;
        if (can_activate_window( hwndTo )) break;
    }

 done:
    fg = GetForegroundWindow();
    TRACE("win = %p fg = %p\n", hwndTo, fg);
    if (!fg || (hwnd == fg))
    {
        if (SetForegroundWindow( hwndTo )) return;
    }
    if (!SetActiveWindow( hwndTo )) SetActiveWindow(0);
}
예제 #14
0
파일: monthcal.c 프로젝트: GYGit/reactos
static VOID
MonthCalReload(IN PMONTHCALWND infoPtr)
{
    WCHAR szBuf[64];
    UINT i;

    infoPtr->UIState = (DWORD)SendMessageW(GetAncestor(infoPtr->hSelf,
                                                       GA_PARENT),
                                            WM_QUERYUISTATE,
                                            0,
                                            0);

    /* Cache the configuration */
    infoPtr->FirstDayOfWeek = MonthCalFirstDayOfWeek();

    infoPtr->hbHeader = GetSysColorBrush(infoPtr->Enabled ? MONTHCAL_HEADERBG : MONTHCAL_DISABLED_HEADERBG);
    infoPtr->hbSelection = GetSysColorBrush(infoPtr->Enabled ? MONTHCAL_SELBG : MONTHCAL_DISABLED_SELBG);

    for (i = 0; i < 7; i++)
    {
        if (GetLocaleInfoW(LOCALE_USER_DEFAULT,
                           LOCALE_SABBREVDAYNAME1 +
                               ((i + infoPtr->FirstDayOfWeek) % 7),
                           szBuf,
                           sizeof(szBuf) / sizeof(szBuf[0])) != 0)
        {
            infoPtr->Week[i] = szBuf[0];
        }
    }

    /* Update the control */
    MonthCalUpdate(infoPtr);
}
예제 #15
0
파일: window.c 프로젝트: emonkak/cereja
static int
ui_window_raise(lua_State* L)
{
	HWND hwnd = NULL;
	HWND rootowner;
	HWND lap;
	Crj_ParseArgs(L, "| u", &hwnd);
	hwnd = GetTargetWindow(hwnd);

	rootowner = GetAncestor(hwnd, GA_ROOTOWNER);
	if (rootowner != NULL)
		hwnd = rootowner;
	lap = GetLastActivePopup(hwnd);
	if (lap != NULL)
		hwnd = lap;

	if (hwnd != GetForegroundWindow()) {
		SetForegroundWindow(hwnd);
	} else {
		SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
		             (SWP_ASYNCWINDOWPOS
		              | SWP_NOACTIVATE
		              | SWP_NOMOVE
		              | SWP_NOOWNERZORDER
		              | SWP_NOSIZE));
	}
	return 0;
}
예제 #16
0
void
GFGClass::Populate()
{
	const JSize bcount = GetBaseClassCount();
	if (bcount == 0)
		{
		return;
		}

	JString classname, filename;

	// Parse these in reverse order so newer declarations override
	// older ones.

	const JSize count = GetAncestorCount();
	for (JIndex i=count; i>=1; i--)
		{
		GetAncestor(i, &classname, &filename);
		itsLink->ParseClass(this, filename, classname);
		}

	// Parse these last so their function declarations override
	// those of their ancestors.

	for (JIndex i = 1; i <= bcount; i++)
		{
		GetBaseClass(i, &classname, &filename);
		itsLink->ParseClass(this, filename, classname);
		}
}
예제 #17
0
HWND GetMainWindowHandle(DWORD processId) {
  if (!HeXModule()/* && !DesktopWidget()*/) {
    return FindWindow(GetMainWindowClassName(processId), NULL);
  }

  /*if (DesktopWidget()) {
    HWND desktop = FindWindow(L"Progman", NULL);
    desktop = GetWindow(desktop, GW_CHILD);
    HWND main_window = FindWindowEx(desktop, NULL,
        GetMainWindowClassName(processId), NULL);
    return main_window;
  }*/

  seekedHandle = NULL;  
  HWND topWindow = GetTopWindow(NULL);
  while (topWindow){
    DWORD pid = 0;
    DWORD threadId = GetWindowThreadProcessId(topWindow, &pid);
    if (threadId != 0 && pid == processId) {
      EnumChildWindows(topWindow, EnumChildBrowserProc, (LPARAM)pid);
      if (seekedHandle) {
        return GetAncestor(seekedHandle, GA_ROOT);
      }
    }
    topWindow = GetNextWindow(topWindow, GW_HWNDNEXT);
  }
  return NULL;
}
예제 #18
0
void test1()
{
	HWND hWnd = HWND(0x00010412);
	HWND hAncestorWnd = GetAncestor(hWnd, GA_ROOTOWNER);
	CString strDebug;
	strDebug.Format("hWnd = %08X, hAncestorWnd = %08X\n", hWnd, hAncestorWnd);
	g_pMainWin->Log(strDebug);
}
예제 #19
0
파일: dialog.c 프로젝트: AlexSteel/wine
/***********************************************************************
 *           DIALOG_EnableOwner
 *
 * Helper function for modal dialogs to enable again the
 * owner of the dialog box.
 */
static void DIALOG_EnableOwner( HWND hOwner )
{
    /* Owner must be a top-level window */
    if (hOwner)
        hOwner = GetAncestor( hOwner, GA_ROOT );
    if (!hOwner) return;
    EnableWindow( hOwner, TRUE );
}
예제 #20
0
파일: mouse.c 프로젝트: dvdhoo/wine
/***********************************************************************
 *		send_mouse_input
 *
 * Update the various window states on a mouse event.
 */
static void send_mouse_input( HWND hwnd, UINT flags, Window window, int x, int y,
                              unsigned int state, DWORD mouse_data, Time time )
{
    struct x11drv_win_data *data = X11DRV_get_win_data( hwnd );
    POINT pt;
    INPUT input;

    if (!data) return;

    if (window == data->whole_window)
    {
        x += data->whole_rect.left - data->client_rect.left;
        y += data->whole_rect.top - data->client_rect.top;
    }
    if (window == root_window)
    {
        x += virtual_screen_rect.left;
        y += virtual_screen_rect.top;
    }
    pt.x = x;
    pt.y = y;
    if (GetWindowLongW( data->hwnd, GWL_EXSTYLE ) & WS_EX_LAYOUTRTL)
        pt.x = data->client_rect.right - data->client_rect.left - 1 - pt.x;
    MapWindowPoints( hwnd, 0, &pt, 1 );

    if (InterlockedExchangePointer( (void **)&cursor_window, hwnd ) != hwnd ||
        GetTickCount() - last_time_modified > 100)
    {
        cursor_window = hwnd;
        sync_window_cursor( data );
    }
    last_time_modified = GetTickCount();

    if (hwnd != GetDesktopWindow()) hwnd = GetAncestor( hwnd, GA_ROOT );

    /* update the wine server Z-order */

    if (window != x11drv_thread_data()->grab_window &&
        /* ignore event if a button is pressed, since the mouse is then grabbed too */
        !(state & (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask|Button6Mask|Button7Mask)))
    {
        RECT rect;
        SetRect( &rect, pt.x, pt.y, pt.x + 1, pt.y + 1 );
        MapWindowPoints( 0, hwnd, (POINT *)&rect, 2 );

        SERVER_START_REQ( update_window_zorder )
        {
            req->window      = wine_server_user_handle( hwnd );
            req->rect.left   = rect.left;
            req->rect.top    = rect.top;
            req->rect.right  = rect.right;
            req->rect.bottom = rect.bottom;
            wine_server_call( req );
        }
        SERVER_END_REQ;
    }
/*****************************************************************
 *		SetFocus  (USER32.@)
 */
HWND WINAPI SetFocus( HWND hwnd )
{
    HWND hwndTop = hwnd;
    HWND previous = GetFocus();

    TRACE( "%p prev %p\n", hwnd, previous );

    if (hwnd)
    {
        /* Check if we can set the focus to this window */
        hwnd = WIN_GetFullHandle( hwnd );
        if (!IsWindow( hwnd ))
        {
            SetLastError( ERROR_INVALID_WINDOW_HANDLE );
            return 0;
        }
        if (hwnd == previous) return previous;  /* nothing to do */
        for (;;)
        {
            HWND parent;
            LONG style = GetWindowLongW( hwndTop, GWL_STYLE );
            if (style & (WS_MINIMIZE | WS_DISABLED)) return 0;
            if (!(style & WS_CHILD)) break;
            parent = GetAncestor( hwndTop, GA_PARENT );
            if (!parent || parent == GetDesktopWindow())
            {
                if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return 0;
                break;
            }
            if (parent == get_hwnd_message_parent()) return 0;
            hwndTop = parent;
        }

        /* call hooks */
        if (HOOK_CallHooks( WH_CBT, HCBT_SETFOCUS, (WPARAM)hwnd, (LPARAM)previous, TRUE )) return 0;

        /* activate hwndTop if needed. */
        if (hwndTop != GetActiveWindow())
        {
            if (!set_active_window( hwndTop, NULL, FALSE, FALSE )) return 0;
            if (!IsWindow( hwnd )) return 0;  /* Abort if window destroyed */

            /* Do not change focus if the window is no longer active */
            if (hwndTop != GetActiveWindow()) return 0;
        }
    }
    else /* NULL hwnd passed in */
    {
        if (!previous) return 0;  /* nothing to do */
        if (HOOK_CallHooks( WH_CBT, HCBT_SETFOCUS, 0, (LPARAM)previous, TRUE )) return 0;
    }

    /* change focus and send messages */
    return set_focus_window( hwnd );
}
예제 #22
0
파일: menu.cpp 프로젝트: Moteesh/reactos
void test_CShellMenu_with_DeskBar(IShellFolder *shellFolder, HMENU hmenu)
{
    HRESULT hResult;
    IShellMenu* shellMenu;
    IDockingWindow* dockingMenu;
    IObjectWithSite *menuWithSite;
    IMenuPopup* menuPopup;
    IBandSite* bandSite;

    /* Create the tree objects and query the nescesary interfaces */
    BOOL bCreated = CreateCShellMenu(&shellMenu, &dockingMenu, &menuWithSite);
    hResult = CoCreateInstance(CLSID_MenuDeskBar, NULL, CLSCTX_INPROC_SERVER, IID_IMenuPopup, reinterpret_cast<void **>(&menuPopup));
    test_S_OK(hResult, "Failed to instantiate CLSID_MenuDeskBar");
    hResult = CoCreateInstance(CLSID_MenuBandSite, NULL, CLSCTX_INPROC_SERVER, IID_IBandSite, reinterpret_cast<void **>(&bandSite));
    test_S_OK(hResult, "Failed to instantiate CLSID_MenuBandSite");
    if (!bCreated || !menuPopup || !bandSite)
    {
        skip("failed to create MenuBandSite object\n");
        return;
    }
    
    /* Create the popup menu */
    hResult = shellMenu->Initialize(NULL, 0, ANCESTORDEFAULT, SMINIT_TOPLEVEL|SMINIT_VERTICAL); 
    test_S_OK(hResult, "Initialize failed");
    hResult = shellMenu->SetMenu( hmenu, NULL, SMSET_TOP);
    test_S_OK(hResult, "SetMenu failed");
    hResult = menuPopup->SetClient(bandSite);
    test_S_OK(hResult, "SetClient failed");
    hResult = bandSite->AddBand(shellMenu);
    test_S_OK(hResult, "AddBand failed");

    /* Show the popum menu */
    POINTL p = {10,10};
    hResult = menuPopup->Popup(&p, NULL, 0);
    test_HRES(hResult, S_FALSE, "Popup failed");

    HWND hWndToolbar, hWndToplevel;

    /* Ensure that the created windows are correct */
    hResult = dockingMenu->GetWindow(&hWndToolbar);
    test_S_OK(hResult, "GetWindow failed");    
    ok(hWndToolbar != NULL, "GetWindow should return a window\n");

    hResult = menuPopup->GetWindow(&hWndToplevel);
    test_S_OK(hResult, "GetWindow failed");
    ok(hWndToolbar != NULL, "GetWindow should return a window\n");

    HWND hwndRealParent = GetParent(hWndToolbar);
    ok(GetParent(hwndRealParent) == hWndToplevel, "Wrong parent\n");
    ok(CheckWindowClass(hWndToolbar, L"ToolbarWindow32"), "Wrong class\n");
    ok(CheckWindowClass(hwndRealParent, L"MenuSite"), "Wrong class\n");
    ok(CheckWindowClass(hWndToplevel, L"BaseBar"), "Wrong class\n");

    ok(GetAncestor (hWndToplevel, GA_PARENT) == GetDesktopWindow(), "Expected the BaseBar window to be top level\n");
}
예제 #23
0
BOOL WindowUtil_isToplevel(HWND hwnd) {
	BOOL toplevel;
	HWND parent;
	parent = GetAncestor(hwnd, GA_PARENT);

	/* According to MS: "A window that has no parent, or whose
	   parent is the desktop window, is called a top-level
	   window." See http://msdn2.microsoft.com/en-us/library/ms632597(VS.85).aspx. */
	toplevel = (!parent || parent == GetDesktopWindow());
	return toplevel;
}
예제 #24
0
// Show the dialog box. Returns true to suppress the original task dialog box
bool CClassicCopyFolder::Run( HWND hWnd )
{
	m_Original=hWnd;
	const int ID_ALLCHECK=16663;
	HWND check=GetDlgItem(hWnd,ID_ALLCHECK);
	bool bMulti=(check && (GetWindowLong(check,GWL_STYLE)&WS_VISIBLE));
	// pick the correct dialog template (for single and multiple files, for LTR and RTL)
	int dlg=bMulti?(IsLanguageRTL()?IDD_FOLDERMULTIR:IDD_FOLDERMULTI):(IsLanguageRTL()?IDD_FOLDERR:IDD_FOLDER);

	HWND parent=GetWindow(GetAncestor(hWnd,GA_ROOT),GW_OWNER);

	int res=(int)DialogBoxParam(g_Instance,MAKEINTRESOURCE(dlg),parent,DialogProc,(LPARAM)this);

	if (res==IDOK) // Yes button for single folder
	{
		// Yes was pressed, proceed with the operation
		PostMessage(hWnd,WM_COMMAND,IDYES,(LPARAM)GetDlgItem(hWnd,IDYES));
	}
	else if (res==IDNO)
	{
		// No
		if (bMulti)
		{
			if (GetKeyState(VK_SHIFT)<0)
			{
				CheckDlgButton(hWnd,ID_ALLCHECK,BST_CHECKED);
				SendMessage(hWnd,WM_COMMAND,ID_ALLCHECK,(LPARAM)check);
			}
			PostMessage(hWnd,WM_COMMAND,IDNO,(LPARAM)GetDlgItem(hWnd,IDNO)); // Skip
		}
		else
			PostMessage(hWnd,WM_COMMAND,IDCANCEL,(LPARAM)GetDlgItem(hWnd,IDCANCEL)); // No
	}
	else if (res==IDYES)
	{
		// Yes to All
		CheckDlgButton(hWnd,ID_ALLCHECK,BST_CHECKED);
		SendMessage(hWnd,WM_COMMAND,ID_ALLCHECK,(LPARAM)check);
		PostMessage(hWnd,WM_COMMAND,IDYES,(LPARAM)GetDlgItem(hWnd,IDYES));
	}
	if (res==IDCANCEL)
	{
		// Cancel
		if (GetKeyState(VK_SHIFT)<0 || GetKeyState(VK_CONTROL)<0)
			return false; // // Shift+Cancel or Ctrl+Cancel was clicked - show the original dialog box
		PostMessage(hWnd,WM_COMMAND,IDCANCEL,(LPARAM)GetDlgItem(hWnd,IDCANCEL)); // No
	}
	if (res==IDC_LINKMORE)
	{
		// More... was clicked - show the original dialog box
		return false;
	}
	return true;
}
예제 #25
0
/*-----------------------------------------------------------------------------
  Find the top-level and document windows for the browser
-----------------------------------------------------------------------------*/
bool CPagetestBase::FindBrowserWindows(DWORD process_id, HWND& frame_window, 
                          HWND& document_window) {
  bool found = false;
  // find a known document window that belongs to this process
  document_window = FindDocumentWindow(process_id, ::GetDesktopWindow());
  if (document_window) {
    found = true;
    frame_window = GetAncestor(document_window, GA_ROOTOWNER);
  }
  return found;
}
예제 #26
0
파일: FixFocus.cpp 프로젝트: cool-RR/Miro
static void install_toplevel_focus_fix(HWND hwnd)
{
    HWND root_window = GetAncestor(hwnd, GA_ROOT);
    if(GetProp(root_window, "ToplevelFocusHackOldProc") != NULL) {
        /* We already installed the fix, maybe there are 2 browser's
         * embedded? */
        return;
    }
    WNDPROC old_proc = (WNDPROC) SetWindowLongPtr(root_window,
                GWL_WNDPROC, (LONG_PTR)ToplevelFocusHackWndProc);
    SetProp(root_window,"ToplevelFocusHackOldProc", old_proc);
}
예제 #27
0
static BOOL CDECL nulldrv_CreateWindow( HWND hwnd )
{
    static int warned;
    HWND parent = GetAncestor( hwnd, GA_PARENT );

    /* HWND_MESSAGE windows don't need a graphics driver */
    if (!parent || parent == get_user_thread_info()->msg_window) return TRUE;
    if (warned++) return FALSE;

    ERR_(winediag)( "Application tried to create a window, but no driver could be loaded.\n" );
    if (driver_load_error[0]) ERR_(winediag)( "%s\n", driver_load_error );
    return FALSE;
}
예제 #28
0
HWND findLastParent(HWND window, bool (*criterium)(HWND)) {
	HWND ancestor = window;
	HWND match = NULL;
	while (ancestor && ancestor != INVALID_HANDLE_VALUE) {
		DEBUGLOG("Current ancestor is 0x%X", ancestor);
		if (criterium(ancestor)) {
			DEBUGLOG("We like your style; storing candidate 0x%X", ancestor);
			match = ancestor;
		}
		ancestor = GetAncestor(ancestor, GA_PARENT);
	}
	return match;
}
예제 #29
0
// Better version of above one. 
// Stolen and butchered from AltDrag's code
HWND GetRealParent(HWND hWnd)
{
      HWND root = GetAncestor(hWnd, GA_ROOT);

        while (hWnd != root) {
          HWND parent = GetParent(hWnd);
          LONG_PTR exstyle = GetWindowLongPtr(hWnd, GWL_EXSTYLE);
          if ((exstyle & WS_EX_MDICHILD)) {
            break;
          }
          hWnd = parent;
        }
      return hWnd;
}
예제 #30
0
파일: dialog.c 프로젝트: AlexSteel/wine
/***********************************************************************
 *           DIALOG_DisableOwner
 *
 * Helper function for modal dialogs to disable the
 * owner of the dialog box. Returns TRUE if owner was enabled.
 */
static BOOL DIALOG_DisableOwner( HWND hOwner )
{
    /* Owner must be a top-level window */
    if (hOwner)
        hOwner = GetAncestor( hOwner, GA_ROOT );
    if (!hOwner) return FALSE;
    if (IsWindowEnabled( hOwner ))
    {
        EnableWindow( hOwner, FALSE );
        return TRUE;
    }
    else
        return FALSE;
}