diff options
author | RadAd <adamgates84+github@gmail.com> | 2019-07-16 12:05:52 +1000 |
---|---|---|
committer | RadAd <adamgates84+github@gmail.com> | 2019-07-16 12:05:52 +1000 |
commit | b40b190dfdb50acd2cbb2108e92c3d4b0d7f3bfe (patch) | |
tree | 863869d3a959b5fed0e430da9dc75a184f9e491f /WinUtils.h | |
parent | a1dd103887ff7e6b6881716da495b4e57ed754c0 (diff) | |
download | RadTerminal-b40b190dfdb50acd2cbb2108e92c3d4b0d7f3bfe.tar.gz RadTerminal-b40b190dfdb50acd2cbb2108e92c3d4b0d7f3bfe.zip |
Support multiple profiles
Diffstat (limited to 'WinUtils.h')
-rw-r--r-- | WinUtils.h | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -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; +} |