diff foosdk/sdk/libPPUI/hookWindowMessages.h @ 1:20d02a178406 default tip

*: check in everything else yay
author Paper <paper@tflc.us>
date Mon, 05 Jan 2026 02:15:46 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/foosdk/sdk/libPPUI/hookWindowMessages.h	Mon Jan 05 02:15:46 2026 -0500
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "windowLifetime.h"
+
+namespace PP {
+	// CContainedWindow replacement
+	// Rationale: 
+	// With CContainedWindow, all messages that the window gets are routed through the message map of your class.
+	// The window might bounce some of the messages to other windows (say, mouse4/5 handlers, WM_CONTEXTMENU), or do modal loops.
+	// If some events triggered by those destroy your CContainedWindow host, crash happens, because your object is still on stack.
+	// hookWindowMessages() sends only the messages you ask for to your class, also managing hook lifetime behind the scenes.
+	void hookWindowMessages(HWND wnd, CMessageMap* target, DWORD targetID, std::initializer_list<DWORD>&& msgs);
+
+	typedef std::function<bool(HWND, UINT, WPARAM, LPARAM, LRESULT&) > messageHook_t;
+	void hookWindowMessages(HWND wnd, messageHook_t h);
+}
\ No newline at end of file