aboutsummaryrefslogtreecommitdiff
path: root/WinUtils.h
diff options
context:
space:
mode:
Diffstat (limited to 'WinUtils.h')
-rw-r--r--WinUtils.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/WinUtils.h b/WinUtils.h
index ffd3929..da1a652 100644
--- a/WinUtils.h
+++ b/WinUtils.h
@@ -138,6 +138,19 @@ inline DWORD RegGetDWORD(HKEY hKey, LPCTSTR sSubKey, LPCTSTR sValue, DWORD dwDef
return dwDef;
}
+inline bool RegEnumKeyEx(_In_ HKEY hKey, _In_ DWORD dwIndex, std::tstring& strName)
+{
+ TCHAR name[256];
+ DWORD len = ARRAYSIZE(name);
+ if (RegEnumKeyEx(hKey, dwIndex, name, &len, nullptr, nullptr, nullptr, nullptr) == ERROR_SUCCESS)
+ {
+ strName = name;
+ return true;
+ }
+ else
+ return false;
+}
+
inline HWND GetMDIClient(HWND hWnd)
{
return FindWindowEx(hWnd, NULL, TEXT("MDICLIENT"), nullptr);
@@ -160,3 +173,32 @@ inline HWND MyGetActiveWnd(HWND hWnd)
hActive = GetMDIActive(GetParent(hWnd));
return hActive;
}
+
+inline bool FindMenuPos(HMENU hBaseMenu, UINT myID, HMENU* pMenu, int* mpos)
+{
+ if (hBaseMenu == NULL)
+ {
+ *pMenu = NULL;
+ *mpos = -1;
+ return true;
+ }
+
+ for (int myPos = 0; myPos < GetMenuItemCount(hBaseMenu); ++myPos)
+ {
+ if (GetMenuItemID(hBaseMenu, myPos) == myID)
+ {
+ *pMenu = hBaseMenu;
+ *mpos = myPos;
+ return true;
+ }
+
+ HMENU hNewMenu = GetSubMenu(hBaseMenu, myPos);
+ if (hNewMenu != NULL)
+ {
+ if (FindMenuPos(hNewMenu, myID, pMenu, mpos))
+ return true;
+ }
+ }
+
+ return false;
+}