summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-09-05 13:55:54 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-09-05 13:55:54 +0300
commita074799eaf3218c979fa07d8a76525aa0ec7b9fd (patch)
treebc17b2c28ba7c81a861bf2a078840ea420e25f03 /plugins
parentf0919f5b6827a7965a89b287feee0693b3c7560b (diff)
NewStory: switch to the standard Miranda subclassing
Diffstat (limited to 'plugins')
-rw-r--r--plugins/NewStory/src/history_control.cpp81
1 files changed, 40 insertions, 41 deletions
diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp
index a1d3399c0f..8cca15f272 100644
--- a/plugins/NewStory/src/history_control.cpp
+++ b/plugins/NewStory/src/history_control.cpp
@@ -4,9 +4,6 @@
HANDLE htuLog = 0;
-static WNDPROC OldEditWndProc;
-static LRESULT CALLBACK HistoryEditWndProc(HWND, UINT, WPARAM, LPARAM);
-
void InitHotkeys()
{
HOTKEYDESC hkd = {};
@@ -156,6 +153,43 @@ bool NewstoryListData::AtTop(void) const
return false;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// Edit box window procedure
+
+static LRESULT CALLBACK HistoryEditWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ auto *pData = (NewstoryListData *)GetWindowLongPtr(GetParent(hwnd), 0);
+
+ switch (msg) {
+ case WM_KEYDOWN:
+ switch (wParam) {
+ case VK_RETURN:
+ pData->EndEditItem(true);
+ return 0;
+ case VK_ESCAPE:
+ pData->EndEditItem(false);
+ return 0;
+ }
+ break;
+
+ case WM_GETDLGCODE:
+ if (lParam) {
+ MSG *msg2 = (MSG *)lParam;
+ if (msg2->message == WM_KEYDOWN && msg2->wParam == VK_TAB)
+ return 0;
+ if (msg2->message == WM_CHAR && msg2->wParam == '\t')
+ return 0;
+ }
+ return DLGC_WANTMESSAGE;
+
+ case WM_KILLFOCUS:
+ pData->EndEditItem(false);
+ return 0;
+ }
+
+ return mir_callNextSubclass(hwnd, HistoryEditWndProc, msg, wParam, lParam);
+}
+
void NewstoryListData::BeginEditItem(int index, bool bReadOnly)
{
if (hwndEditBox)
@@ -192,7 +226,7 @@ void NewstoryListData::BeginEditItem(int index, bool bReadOnly)
hwndEditBox = CreateWindow(L"EDIT", item->getWBuf(), dwStyle, 0, top, rc.right - rc.left, itemHeight, m_hwnd, NULL, g_plugin.getInst(), NULL);
SetWindowLongPtrW(hwndEditBox, GWLP_USERDATA, (LPARAM)item);
- OldEditWndProc = (WNDPROC)SetWindowLongPtr(hwndEditBox, GWLP_WNDPROC, (LONG_PTR)HistoryEditWndProc);
+ mir_subclassWindow(hwndEditBox, HistoryEditWndProc);
SendMessage(hwndEditBox, WM_SETFONT, (WPARAM)g_fontTable[fontid].hfnt, 0);
SendMessage(hwndEditBox, EM_SETMARGINS, EC_RIGHTMARGIN, 100);
SendMessage(hwndEditBox, EM_SETSEL, 0, (LPARAM)(-1));
@@ -200,6 +234,8 @@ void NewstoryListData::BeginEditItem(int index, bool bReadOnly)
SetFocus(hwndEditBox);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
void NewstoryListData::Clear()
{
items.clear();
@@ -705,43 +741,6 @@ void NewstoryListData::ScrollBottom()
}
/////////////////////////////////////////////////////////////////////////////////////////
-// Edit box window procedure
-
-static LRESULT CALLBACK HistoryEditWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- auto *pData = (NewstoryListData *)GetWindowLongPtr(GetParent(hwnd), 0);
-
- switch (msg) {
- case WM_KEYDOWN:
- switch (wParam) {
- case VK_RETURN:
- pData->EndEditItem(true);
- return 0;
- case VK_ESCAPE:
- pData->EndEditItem(false);
- return 0;
- }
- break;
-
- case WM_GETDLGCODE:
- if (lParam) {
- MSG *msg2 = (MSG *)lParam;
- if (msg2->message == WM_KEYDOWN && msg2->wParam == VK_TAB)
- return 0;
- if (msg2->message == WM_CHAR && msg2->wParam == '\t')
- return 0;
- }
- return DLGC_WANTMESSAGE;
-
- case WM_KILLFOCUS:
- pData->EndEditItem(false);
- return 0;
- }
-
- return CallWindowProc(OldEditWndProc, hwnd, msg, wParam, lParam);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
// NewStory history control window procedure
LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)