comparison 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
comparison
equal deleted inserted replaced
0:e9bb126753e7 1:20d02a178406
1 #pragma once
2
3 #include "windowLifetime.h"
4
5 namespace PP {
6 // CContainedWindow replacement
7 // Rationale:
8 // With CContainedWindow, all messages that the window gets are routed through the message map of your class.
9 // The window might bounce some of the messages to other windows (say, mouse4/5 handlers, WM_CONTEXTMENU), or do modal loops.
10 // If some events triggered by those destroy your CContainedWindow host, crash happens, because your object is still on stack.
11 // hookWindowMessages() sends only the messages you ask for to your class, also managing hook lifetime behind the scenes.
12 void hookWindowMessages(HWND wnd, CMessageMap* target, DWORD targetID, std::initializer_list<DWORD>&& msgs);
13
14 typedef std::function<bool(HWND, UINT, WPARAM, LPARAM, LRESULT&) > messageHook_t;
15 void hookWindowMessages(HWND wnd, messageHook_t h);
16 }