-
Notifications
You must be signed in to change notification settings - Fork 2
/
view.h
102 lines (85 loc) · 2.64 KB
/
view.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include "finddlg.h"
class CEditView :
public CWindowImpl<CEditView, CEdit>,
public CEditCommands<CEditView>,
public CEditFindReplaceImpl<CEditView, CFindReplaceDialogWithMessageFilter>
{
protected:
typedef CEditView thisClass;
typedef CEditCommands<CEditView> editCommandsClass;
typedef CEditFindReplaceImpl<CEditView, CFindReplaceDialogWithMessageFilter> findReplaceClass;
public:
DECLARE_WND_SUPERCLASS(NULL, CEdit::GetWndClassName())
BOOL PreTranslateMessage(MSG* pMsg)
{
// In non Multi-thread SDI cases, CFindReplaceDialogWithMessageFilter will add itself to the
// global message filters list. In our case, we'll call it directly.
if(m_pFindReplaceDialog != NULL)
{
if(m_pFindReplaceDialog->PreTranslateMessage(pMsg))
return TRUE;
}
return FALSE;
}
BEGIN_MSG_MAP(CEditView)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MSG_WM_GETDLGCODE(OnGetDlgCode)
CHAIN_MSG_MAP_ALT(editCommandsClass, 1)
CHAIN_MSG_MAP_ALT(findReplaceClass, 1)
END_MSG_MAP()
LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
{
LRESULT lRet = DefWindowProc(uMsg, wParam, lParam);
LimitText(0);
return lRet;
}
UINT OnGetDlgCode(LPMSG lpMsg)
{
// Prevent selecting all text when focused.
// https://devblogs.microsoft.com/oldnewthing/20031114-00/?p=41823
return DefWindowProc() & ~DLGC_HASSETSEL;
}
// Overrides from CEditFindReplaceImpl
CFindReplaceDialogWithMessageFilter* CreateFindReplaceDialog(BOOL bFindOnly, // TRUE for Find, FALSE for FindReplace
LPCTSTR lpszFindWhat,
LPCTSTR lpszReplaceWith = NULL,
DWORD dwFlags = FR_DOWN,
HWND hWndParent = NULL)
{
// In non Multi-Threaded SDI cases, we'd pass in the message loop to CFindReplaceDialogWithMessageFilter.
// In our case, we'll call PreTranslateMessage directly from this class.
//CFindReplaceDialogWithMessageFilter* findReplaceDialog =
// new CFindReplaceDialogWithMessageFilter(_Module.GetMessageLoop());
CFindReplaceDialogWithMessageFilter* findReplaceDialog =
new CFindReplaceDialogWithMessageFilter(NULL);
if(findReplaceDialog == NULL)
{
::MessageBeep(MB_ICONHAND);
}
else
{
HWND hWndFindReplace = findReplaceDialog->Create(bFindOnly,
lpszFindWhat, lpszReplaceWith, dwFlags, hWndParent);
if(hWndFindReplace == NULL)
{
delete findReplaceDialog;
findReplaceDialog = NULL;
}
else
{
findReplaceDialog->SetActiveWindow();
findReplaceDialog->ShowWindow(SW_SHOW);
}
}
return findReplaceDialog;
}
DWORD GetFindReplaceDialogFlags(void) const
{
DWORD dwFlags = FR_HIDEWHOLEWORD;
if(m_bFindDown)
dwFlags |= FR_DOWN;
if(m_bMatchCase)
dwFlags |= FR_MATCHCASE;
return dwFlags;
}
};