本文整理匯總了C++中GetAncestor函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetAncestor函數的具體用法?C++ GetAncestor怎麽用?C++ GetAncestor使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetAncestor函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: GetAncestor
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: onWM_COMMAND
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: inplace_frame_GetWindow
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: IsShellWindow
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: menubar_nccreate
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: IsAltTabWindow
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: is_alttab_window
// 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: EVENT_FocusIn
/**********************************************************************
* 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: ui_window_lower
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: CursorProc
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);
}
示例11: CloseCurrentSession
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;
}
示例12: WinPosActivateOtherWindow
/*******************************************************************
* 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);
}
示例13: MonthCalReload
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);
}
示例14: ui_window_raise
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;
}
示例15: GetMainWindowHandle
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;
}