From b40b190dfdb50acd2cbb2108e92c3d4b0d7f3bfe Mon Sep 17 00:00:00 2001 From: RadAd Date: Tue, 16 Jul 2019 12:05:52 +1000 Subject: Support multiple profiles --- WinUtils.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'WinUtils.h') 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; +} -- cgit v1.2.3