-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfinddlg.h
75 lines (58 loc) · 1.61 KB
/
finddlg.h
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef __FindReplaceDialogWithMessageFilter_h__
#define __FindReplaceDialogWithMessageFilter_h__
#pragma once
#ifndef __cplusplus
#error ATL requires C++ compilation (use a .cpp suffix)
#endif
#ifndef __ATLAPP_H__
#error FindReplaceDialogWithMessageFilter.h requires atlapp.h to be included first
#endif
#ifndef __ATLWIN_H__
#error FindReplaceDialogWithMessageFilter.h requires atlwin.h to be included first
#endif
class CFindReplaceDialogWithMessageFilter :
public CFindReplaceDialogImpl<CFindReplaceDialogWithMessageFilter>,
public CMessageFilter
{
protected:
CMessageLoop* m_messageLoop;
public:
CFindReplaceDialogWithMessageFilter() : m_messageLoop(nullptr)
{
}
CFindReplaceDialogWithMessageFilter(CMessageLoop* messageLoop) :
m_messageLoop(messageLoop)
{
}
public:
BOOL PreTranslateMessage(MSG* pMsg)
{
HWND hWndFocus = ::GetFocus();
if((m_hWnd == hWndFocus) || this->IsChild(hWndFocus))
return this->IsDialogMessage(pMsg);
return FALSE;
}
virtual void OnFinalMessage(HWND /*hWnd*/)
{
delete this;
}
BEGIN_MSG_MAP(CFindReplaceDialogWithMessageFilter)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
END_MSG_MAP()
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
if(m_messageLoop)
m_messageLoop->AddMessageFilter(this);
bHandled = FALSE;
return 0;
}
LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
if(m_messageLoop)
m_messageLoop->RemoveMessageFilter(this);
bHandled = FALSE;
return 0;
}
};
#endif //__FindReplaceDialogWithMessageFilter_h__