-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQueryPane.cpp
68 lines (54 loc) · 2.19 KB
/
QueryPane.cpp
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
#include "pch.h"
#include "QueryPane.h"
#include "DatabaseExplorer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
BEGIN_MESSAGE_MAP(CQueryPane, CRichEditPane)
//{{AFX_MSG_MAP(CQueryPane)
ON_WM_CREATE()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
int CQueryPane::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (-1 == CRichEditPane::OnCreate(lpCreateStruct))
return -1;
CRect rectDummy;
rectDummy.SetRectEmpty();
constexpr DWORD dwStyle = WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN;
m_pRichEditCtrl = std::make_unique<CRichEditCtrl>();
if (! m_pRichEditCtrl->Create(dwStyle, rectDummy, this, IDC_RICHEDIT_QUERY))
{
TRACE(_T("Failed to create rich edit control\n"));
return -1; // fail to create
}
AdjustLayout();
::PostMessage(m_pRichEditCtrl->GetSafeHwnd(), EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS | ENM_SCROLLEVENTS | ENM_KEYEVENTS);
const DWORD dwNominator = static_cast<DWORD>(AfxGetApp()->GetProfileInt(_T("Settings"), _T("QueryPaneZoomNominator"), 0));
const DWORD dwDenominator = static_cast<DWORD>(AfxGetApp()->GetProfileInt(_T("Settings"), _T("QueryPaneZoomDenominator"), 0));
if (dwNominator > 0 || dwDenominator > 0)
::PostMessage(m_pRichEditCtrl->GetSafeHwnd(), EM_SETZOOM, static_cast<WPARAM>(dwNominator), static_cast<LPARAM>(dwDenominator));
if (theApp.m_bWordWrap)
m_pRichEditCtrl->SetTargetDevice(nullptr, 0);
return 0;
}
void CQueryPane::OnDestroy()
{
CRichEditPane::OnDestroy();
// TODO: Add your message handler code here
DWORD dwNominator = NULL;
DWORD dwDenominator = NULL;
::SendMessage(m_pRichEditCtrl->GetSafeHwnd(), EM_GETZOOM, reinterpret_cast<WPARAM>(&dwNominator), reinterpret_cast<LPARAM>(&dwDenominator));
AfxGetApp()->WriteProfileInt(_T("Settings"), _T("QueryPaneZoomNominator"), static_cast<int>(dwNominator));
AfxGetApp()->WriteProfileInt(_T("Settings"), _T("QueryPaneZoomDenominator"), static_cast<int>(dwDenominator));
}
CString CQueryPane::GetSelText() const
{
return m_pRichEditCtrl->GetSelText();
}
void CQueryPane::SetText(std::vector<CString>&& text)
{
for (const auto& it : text)
m_pRichEditCtrl->ReplaceSel(it + _T("\n"), TRUE);
}