summaryrefslogtreecommitdiff
path: root/src/common.cpp
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2005-04-18 00:52:51 +0000
committerIan C <ianc@noddybox.co.uk>2005-04-18 00:52:51 +0000
commit6910f6539d74a59e6d773f4a5d311cb530c2db6e (patch)
tree27fc74013aa5e2e8497dc80ce32de053c40dd917 /src/common.cpp
parent9d0c916a1c22615b25f84b8a219df1f607a110e5 (diff)
Changed debug file location and added GetAppWindow to Common
Diffstat (limited to 'src/common.cpp')
-rw-r--r--src/common.cpp66
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