diff options
Diffstat (limited to 'src/common.cpp')
-rw-r--r-- | src/common.cpp | 66 |
1 files changed, 53 insertions, 13 deletions
diff --git a/src/common.cpp b/src/common.cpp index 59c7695..3cd84a7 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -217,19 +217,6 @@ bool Common::SelectDir(HWND parent, const char *title, std::string& path) // ------------------------------------------------------------ // -int CALLBACK Common::BrowseCallback(HWND w, UINT u, LPARAM p1, LPARAM p2) -{ - if (u==BFFM_INITIALIZED) - { - PostMessage(w,BFFM_SETSELECTION,TRUE,p2); - } - - return 0; -} - - -// ------------------------------------------------------------ -// std::string Common::GetOSError() { std::string res; @@ -262,6 +249,59 @@ HINSTANCE Common::GetInstance() } +// ------------------------------------------------------------ +// +HWND Common::GetAppWindow() +{ + EnumData data; + + data.handle=0; + data.procid=GetCurrentProcessId(); + + W32DEBUGOUT("Looking for window for process " << data.procid); + + EnumWindows(EnumCallback,reinterpret_cast<LPARAM>(&data)); + + W32DEBUGOUT("Got window handle " << data.handle << + " for process " << data.procid); + + return data.handle; +} + + +// ------------------------------------------------------------ +// +int CALLBACK Common::BrowseCallback(HWND w, UINT u, LPARAM p1, LPARAM p2) +{ + if (u==BFFM_INITIALIZED) + { + PostMessage(w,BFFM_SETSELECTION,TRUE,p2); + } + + return 0; +} + + +// ------------------------------------------------------------ +// +BOOL CALLBACK Common::EnumCallback(HWND w, LPARAM p) +{ + DWORD id; + EnumData *data=reinterpret_cast<EnumData*>(p); + + GetWindowThreadProcessId(w,&id); + + if (id==data->procid) + { + data->handle=w; + return FALSE; + } + + return TRUE; +} + + }; // namespace W32DLib + // END OF FILE |