1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
class Window
{
virtual LRESULT HandleControlNotifications( UINT uMsg, WPARAM wParam, LPARAM lParam );
// ...
static LRESULT APIENTRY WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
};
// ...
LRESULT Window::HandleNotifications( UINT uMsg, WPARAM wParam, LPARAM lParam )
{
try
{
if ( uMsg == WM_CLOSE )
{
// bla
}
else if ( uMsg == WM_DESTROY )
{
// blubb
}
else if ( uMsg == WM_COMMAND )
{
// Menu, Accel oder Controlnachricht verarbeiten bzw
// weiterleiten
}
return CallDefaultWindowProc( uMsg, wParam, lParam );
}
catch ( ... )
{
return 0;
}
}
LRESULT APIENTRY Window::WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
WindowList::iterator it = std::find_if( windows.begin(), windows.end(), std::bind2nd( WindowComparer(), hWnd ) );
if ( it != windows.end() )
{
return ( *it )->HandleNotifications( uMsg, wParam, lParam );
}
else
return DefWindowProc( hWnd, uMsg, wParam, lParam );
}
|