From 6910f6539d74a59e6d773f4a5d311cb530c2db6e Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 18 Apr 2005 00:52:51 +0000 Subject: Changed debug file location and added GetAppWindow to Common --- src/common.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 13 deletions(-) (limited to 'src/common.cpp') diff --git a/src/common.cpp b/src/common.cpp index 59c7695..3cd84a7 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -215,19 +215,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() @@ -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(&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(p); + + GetWindowThreadProcessId(w,&id); + + if (id==data->procid) + { + data->handle=w; + return FALSE; + } + + return TRUE; +} + + }; // namespace W32DLib + // END OF FILE -- cgit v1.2.3