WORD GetClassWord( HWND hwnd, int index) { PWND pwnd; PCLS pclsClient; pwnd = ValidateHwnd(hwnd); if (pwnd == NULL) return 0; pclsClient = (PCLS)REBASEALWAYS(pwnd, pcls); if (index == GCW_ATOM) { return (WORD)_GetClassData(pclsClient, pwnd, index, FALSE); } else { if ((index < 0) || (index + (int)sizeof(WORD) > pclsClient->cbclsExtra)) { RIPERR0(ERROR_INVALID_INDEX, RIP_VERBOSE, ""); return 0; } else { WORD UNALIGNED *puw; puw = (WORD UNALIGNED *)((BYTE *)(pclsClient + 1) + index); return *puw; } } }
BOOL _HasCaptionIcon(PWND pwnd) { HICON hIcon; PCLS pcls; if (TestWF(pwnd, WEFTOOLWINDOW)) // it's a tool window -- it doesn't get an icon return(FALSE); if ((TestWF(pwnd, WFBORDERMASK) != (BYTE)LOBYTE(WFDLGFRAME)) && !TestWF(pwnd, WEFDLGMODALFRAME)) // they are not trying to look like a dialog, they get an icon return TRUE; if (!TestWF(pwnd, WFWIN40COMPAT) && (((PCLS)REBASEALWAYS(pwnd, pcls))->atomClassName == (ATOM)DIALOGCLASS)) // it's an older REAL dialog -- it doesn't get an icon return(FALSE); hIcon = (HICON) _GetProp(pwnd, MAKEINTATOM(gpsi->atomIconSmProp), TRUE); if (hIcon) { // it's a 4.0 dialog with a small icon -- if that small icon is // something other than the generic small windows icon, it gets an icon return(hIcon != gpsi->hIconSmWindows); } hIcon = (HICON) _GetProp(pwnd, MAKEINTATOM(gpsi->atomIconProp), TRUE); if (hIcon && (hIcon != gpsi->hIcoWindows)) // it's a 4.0 dialog with no small icon, but instead a large icon // that's not the generic windows icon -- it gets an icon return(TRUE); pcls = REBASEALWAYS(pwnd, pcls); if (pcls->spicnSm) { if (pcls->spicnSm != HMObjectFromHandle(gpsi->hIconSmWindows)) { // it's a 4.0 dialog with a class icon that's not the generic windows // icon -- it gets an icon return(TRUE); } } // it's a 4.0 dialog with no small or large icon -- it doesn't get an icon return(FALSE); }
/***************************************************************************\ * * _NextSibblingOrAncestor * * Called by _NextControl. It returns the next control to pwndStart. If there * is a next window (pwndStart->spwndNext), then that is it. * Otherwise, the next control is up the parent chain. However, if it's already * at the top of the chain (pwndRoot == pwndStart->spwndParent), then the next * control is the first child of pwndRoot. But if it's not at the top of the chain, * then the next control is pwndStart->spwndParent or an ancestor. * \***************************************************************************/ PWND _NextSibblingOrAncestor (PWND pwndRoot, PWND pwndStart) { PWND pwndParent; #ifdef DEBUG PWND pwndNext; #endif // If there is a sibbling, go for it if (pwndStart->spwndNext != NULL) { return (REBASEALWAYS(pwndStart, spwndNext)); } // If it cannot go up the parent chain, then return the first sibbling. pwndParent = REBASEALWAYS(pwndStart, spwndParent); if (pwndParent == pwndRoot) { // Note that if pwndStart doesn't have any sibblings, // this will return pwndStart again return (REBASEALWAYS(pwndParent, spwndChild)); } // Otherwise walk up the parent chain looking for the first window with // a WS_EX_CONTROLPARENT parent. #ifdef DEBUG pwndNext = #else return #endif _GetChildControl(pwndRoot, pwndParent); #ifdef DEBUG if ((pwndNext != pwndParent) || !TestWF(pwndParent, WEFCONTROLPARENT)) { // Code looping through the controls in a dialog might go into an infinite // loop because of this (i.e., xxxRemoveDefaultButton, _GetNextDlgTabItem,..) // We've walked up the parent chain but will never walk down the child chain again // because there is a NON WS_EX_CONTROLPARENT parent window somewhere in the chain. RIPMSG0 (RIP_ERROR, "_NextSibblingOrAncestor: Non WS_EX_CONTROLPARENT window in parent chain"); } return pwndNext; #endif }
/***************************************************************************\ * PhkNextValid * * This helper routine walk the phkNext chain looking for the next valid * hook (i.e., not marked as destroyed). If the end of the local (or * thread specific) hook chain is reached, then it jumps to the global * (or desktop) chain. * * Once a hook is destroyed, we don't want anymore activity on it; however, * if the hook is locked at destroy time (= someone is calling it), then * we keep it in the list so CallNextHook will work properly * * History: * 03/24/96 GerardoB Moved to rtl and added *Valid stuff. * 01-30-91 DavidPe Created. \***************************************************************************/ PHOOK PhkNextValid(PHOOK phk) { #if DBG int iHook = phk->iHook; #ifdef _USERK_ CheckCritInShared(); #endif #endif do { /* * If this hook is marked as destroyed, it must be either * locked or we should be in the process of destroying it */ UserAssert(!(phk->flags & HF_DESTROYED) || (((PHEAD)phk)->cLockObj != 0) || (phk->flags & HF_INCHECKWHF)); /* * Get the next hook */ if (phk->phkNext != NULL) { phk = REBASEALWAYS(phk, phkNext); } else if (!(phk->flags & HF_GLOBAL)) { #ifdef _USERK_ phk = PtiCurrent()->pDeskInfo->aphkStart[phk->iHook + 1]; #else PCLIENTINFO pci = GetClientInfo(); phk = pci->pDeskInfo->aphkStart[phk->iHook + 1]; /* * If it found a pointer, rebase it. */ if (phk != NULL) { (KPBYTE)phk -= pci->ulClientDelta; } #endif UserAssert((phk == NULL) || (phk->flags & HF_GLOBAL)); } else { return NULL; } /* * If destroyed, keep looking. */ } while ((phk != NULL) && (phk->flags & HF_DESTROYED)); #ifdef _USERK_ DbgValidateHooks(phk, iHook); #endif return phk; }
PMENU _GetSubMenu( PMENU pMenu, int nPos) { PITEM pItem; PMENU pPopup = NULL; /* * Make sure nPos refers to a valid popup */ if ((UINT)nPos < (UINT)((PMENU)pMenu)->cItems) { pItem = &((PITEM)REBASEALWAYS(pMenu, rgItems))[nPos]; if (pItem->spSubMenu != NULL) pPopup = (PMENU)REBASEPTR(pMenu, pItem->spSubMenu); } return (PVOID)pPopup; }
ULONG_PTR _GetClassLongPtr( PWND pwnd, int index, BOOL bAnsi) { PCLS pcls = REBASEALWAYS(pwnd, pcls); if (index < 0) { return _GetClassData(pcls, pwnd, index, bAnsi); } else { if (index + (int)sizeof(ULONG_PTR) > pcls->cbclsExtra) { RIPERR0(ERROR_INVALID_INDEX, RIP_VERBOSE, ""); return 0; } else { ULONG_PTR UNALIGNED *pudw; pudw = (ULONG_PTR UNALIGNED *)((BYTE *)(pcls + 1) + index); return *pudw; } } }
DWORD _GetClassLong( PWND pwnd, int index, BOOL bAnsi) { PCLS pcls = REBASEALWAYS(pwnd, pcls); if (index < 0) { if (index < INDEX_OFFSET || afClassDWord[index - INDEX_OFFSET] > sizeof(DWORD)) { RIPERR1(ERROR_INVALID_INDEX, RIP_WARNING, "GetClassLong: invalid index %d", index); return 0; } return (DWORD)_GetClassData(pcls, pwnd, index, bAnsi); } else { if (index + (int)sizeof(DWORD) > pcls->cbclsExtra) { RIPERR0(ERROR_INVALID_INDEX, RIP_VERBOSE, ""); return 0; } else { DWORD UNALIGNED *pudw; pudw = (DWORD UNALIGNED *)((BYTE *)(pcls + 1) + index); return *pudw; } } }
PITEM MNLookUpItem( PMENU pMenu, UINT wCmd, BOOL fByPosition, PMENU *ppMenuItemIsOn) { PITEM pItem; PITEM pItemRet = NULL; PITEM pItemMaybe; PMENU pMenuMaybe = NULL; int i; if (ppMenuItemIsOn != NULL) *ppMenuItemIsOn = NULL; if (pMenu == NULL || !pMenu->cItems || wCmd == MFMWFP_NOITEM) { // RIPERR0(ERROR_INVALID_PARAMETER, RIP_WARNING, "MNLookUpItem: invalid item"); return NULL; } /* * dwFlags determines how we do the search */ if (fByPosition) { if (wCmd < (UINT)pMenu->cItems) { pItemRet = &((PITEM)REBASEALWAYS(pMenu, rgItems))[wCmd]; if (ppMenuItemIsOn != NULL) *ppMenuItemIsOn = pMenu; return (pItemRet); } else return NULL; } /* * Walk down the menu and try to find an item with an ID of wCmd. * The search procedes from the end of the menu (as was done in * assembler). */ /* this is the Chicago code, which walks from the front of the menu -- Fritz */ // for (pItem = &pMenu->rgItems[i - 1]; pItemRet == NULL && i--; --pItem) { for (i = 0, pItem = REBASEALWAYS(pMenu, rgItems); i < (int)pMenu->cItems; i++, pItem++) { /* * If the item is a popup, recurse down the tree */ if (pItem->spSubMenu != NULL) { // // COMPAT: // Allow apps to pass in menu handle as ID in menu APIs. We // remember that this popup had a menu handle with the same ID // value. This is a 2nd choice though. We still want to see // if there's some actual command that has this ID value first. // if (pItem->wID == wCmd) { pMenuMaybe = pMenu; pItemMaybe = pItem; } pItemRet = MNLookUpItem((PMENU)REBASEPTR(pMenu, pItem->spSubMenu), wCmd, FALSE, ppMenuItemIsOn); if (pItemRet != NULL) return pItemRet; } else if (pItem->wID == wCmd) { /* * Found the item, now save things for later */ if (ppMenuItemIsOn != NULL) *ppMenuItemIsOn = pMenu; return pItem; } } if (pMenuMaybe) { // no non popup menu match found -- use the 2nd choice popup menu // match if (ppMenuItemIsOn != NULL) *ppMenuItemIsOn = pMenuMaybe; return(pItemMaybe); } return(NULL); }