|
1
|
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 } |