Browse Source

fix log lineno format, add GetParentsString to list parent windows for debugging.

git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@433 595ec19a-5cb4-439b-94a8-42fb3063c22c
ingenuus 18 years ago
parent
commit
7b5a20b32a
2 changed files with 22 additions and 1 deletions
  1. 21 1
      Misc.cpp
  2. 1 0
      Misc.h

+ 21 - 1
Misc.cpp

@@ -74,7 +74,7 @@ void log(const TCHAR* msg, bool bFromSendRecieve, CString csFile, long lLine)
 
 	CString csFileLine;
 	csFile = GetFileName(csFile);
-	csFileLine.Format(_T("%s %d] "), csFile, lLine);
+	csFileLine.Format(_T("%s [%d] "), csFile, lLine);
 	csText += csFileLine;
 	
 	csText += msg;
@@ -195,6 +195,26 @@ CString GetWndText( HWND hWnd )
 	return text;
 }
 
+CString GetParentsString( HWND hWndStart, TCHAR* sSep )
+{
+HWND hWnd = hWndStart;
+CString sOne = "";
+CString sResult = "";
+TCHAR pBuf[255];
+
+    pBuf[0] = 0;
+    do {
+        ::GetClassName(hWnd, pBuf, 255);
+        sOne = StrF( _T("\n->[0x%08x: (%s) \"%s\"]"),
+            hWnd, pBuf, (LPCTSTR) GetWndText(hWnd) );
+        sResult += sSep;
+        sResult += sOne;
+        hWnd = ::GetParent(hWnd);
+    } while( hWnd != NULL );
+
+    return sResult;
+}
+
 bool IsAppWnd( HWND hWnd )
 {
 	DWORD dwMyPID = ::GetCurrentProcessId();

+ 1 - 0
Misc.h

@@ -64,6 +64,7 @@ BYTE GetEscapeChar( BYTE ch );
 CString RemoveEscapes( const TCHAR* str );
 
 CString GetWndText( HWND hWnd );
+CString GetParentsString( HWND hWndStart, TCHAR* sSep = _T("\n->") );
 // returns true if the given window is owned by this process
 bool IsAppWnd( HWND hWnd );
 // returns the current Focus window even if it is not owned by our thread.