Browse Source

Making setWindowTitle() on Windows thread safe.

Dario Manesku 11 years ago
parent
commit
65f5faceec
1 changed files with 8 additions and 6 deletions
  1. 8 6
      examples/common/entry/entry_windows.cpp

+ 8 - 6
examples/common/entry/entry_windows.cpp

@@ -17,6 +17,7 @@
 #define WM_USER_SET_WINDOW_SIZE     (WM_USER+0)
 #define WM_USER_SET_WINDOW_SIZE     (WM_USER+0)
 #define WM_USER_TOGGLE_WINDOW_FRAME (WM_USER+1)
 #define WM_USER_TOGGLE_WINDOW_FRAME (WM_USER+1)
 #define WM_USER_MOUSE_LOCK          (WM_USER+2)
 #define WM_USER_MOUSE_LOCK          (WM_USER+2)
+#define WM_USER_SET_WINDOW_TITLE    (WM_USER+3)
 
 
 namespace entry
 namespace entry
 {
 {
@@ -259,6 +260,12 @@ namespace entry
 					}
 					}
 					break;
 					break;
 
 
+				case WM_USER_SET_WINDOW_TITLE:
+					{
+						SetWindowText(_hwnd, (const char*)_lparam);
+					}
+					break;
+
 				case WM_USER_TOGGLE_WINDOW_FRAME:
 				case WM_USER_TOGGLE_WINDOW_FRAME:
 					{
 					{
 						if (m_frame)
 						if (m_frame)
@@ -586,11 +593,6 @@ namespace entry
 			}
 			}
 		}
 		}
 
 
-		void setWindowTitle(const char* _title)
-		{
-			SetWindowText(m_hwnd, _title);
-		}
-
 		static LRESULT CALLBACK wndProc(HWND _hwnd, UINT _id, WPARAM _wparam, LPARAM _lparam);
 		static LRESULT CALLBACK wndProc(HWND _hwnd, UINT _id, WPARAM _wparam, LPARAM _lparam);
 
 
 		EventQueue m_eventQueue;
 		EventQueue m_eventQueue;
@@ -641,7 +643,7 @@ namespace entry
 
 
 	void setWindowTitle(const char* _title)
 	void setWindowTitle(const char* _title)
 	{
 	{
-		s_ctx.setWindowTitle(_title);
+		PostMessage(s_ctx.m_hwnd, WM_USER_SET_WINDOW_TITLE, 0, (LPARAM)_title);
 	}
 	}
 
 
 	void toggleWindowFrame()
 	void toggleWindowFrame()