Fix Mouse Wheel Scrolling in Shortcut Mapper even nothing to scroll

Reduce also Shortcut Mapper memory use.

Fix #14895, close #14896
This commit is contained in:
Don Ho 2024-03-22 16:22:59 +01:00
parent 71a12c4289
commit 52fa5a3b8a
2 changed files with 792 additions and 795 deletions

View File

@ -1,4 +1,4 @@
//BABYGRID code is copyrighted (C) 20002 by David Hillard //BABYGRID code is copyrighted (C) 2002 by David Hillard
// //
//This code must retain this copyright message //This code must retain this copyright message
// //
@ -23,7 +23,8 @@ HFONT g_hfontbody = nullptr;
HFONT g_hfontheader = nullptr; HFONT g_hfontheader = nullptr;
HFONT g_hfonttitle = nullptr; HFONT g_hfonttitle = nullptr;
#define MAX_GRIDS 20 #define MAX_GRIDS 1 // Notepad++ uses only one GridHandleStruct, the old value "20" is not necessary
struct GridHandleStruct struct GridHandleStruct
{ {
HMENU gridmenu = nullptr; HMENU gridmenu = nullptr;
@ -1174,9 +1175,9 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_PAINT: case WM_PAINT:
{ {
PAINTSTRUCT ps; PAINTSTRUCT ps{};
BeginPaint(hWnd, &ps); BeginPaint(hWnd, &ps);
RECT rt; RECT rt{};
GetClientRect(hWnd, &rt); GetClientRect(hWnd, &rt);
CalcVisibleCellBoundaries(SelfIndex); CalcVisibleCellBoundaries(SelfIndex);
//display title //display title
@ -1186,11 +1187,11 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
DisplayColumn(hWnd, SelfIndex, 0, 0, BGHS[SelfIndex].hfont, BGHS[SelfIndex].hcolumnheadingfont); DisplayColumn(hWnd, SelfIndex, 0, 0, BGHS[SelfIndex].hfont, BGHS[SelfIndex].hcolumnheadingfont);
{ {
int c, j, k, offset; int offset = BGHS[SelfIndex].columnwidths[0];
offset = BGHS[SelfIndex].columnwidths[0]; int j = BGHS[SelfIndex].leftvisiblecol;
j = BGHS[SelfIndex].leftvisiblecol; int k = BGHS[SelfIndex].rightvisiblecol;
k = BGHS[SelfIndex].rightvisiblecol;
for (c = j; c <= k; c++) for (int c = j; c <= k; c++)
{ {
DisplayColumn(hWnd, SelfIndex, c, offset, BGHS[SelfIndex].hfont, BGHS[SelfIndex].hcolumnheadingfont); DisplayColumn(hWnd, SelfIndex, c, offset, BGHS[SelfIndex].hfont, BGHS[SelfIndex].hcolumnheadingfont);
offset += BGHS[SelfIndex].columnwidths[c]; offset += BGHS[SelfIndex].columnwidths[c];
@ -1469,8 +1470,6 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
//now add it //now add it
wcscat_s(buffer, TEXT("|")); wcscat_s(buffer, TEXT("|"));
wcscat_s(buffer, BGHS[SelfIndex].protect); wcscat_s(buffer, BGHS[SelfIndex].protect);
//determine data type (text,numeric, or boolean)(1,2,3)
//iDataType=DetermineDataType((TCHAR*)lParam);
int iDataType = 1; int iDataType = 1;
@ -1536,7 +1535,6 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
//if there are \n codes in the generic_string, find the longest line //if there are \n codes in the generic_string, find the longest line
int longestline = FindLongestLine(hdc, (TCHAR*)lParam, &size); int longestline = FindLongestLine(hdc, (TCHAR*)lParam, &size);
//GetTextExtentPoint32(hdc,(TCHAR*)lParam,lstrlen((TCHAR*)lParam),&size);
int required_width = longestline + 15; int required_width = longestline + 15;
required_height = size.cy; required_height = size.cy;
//count lines //count lines
@ -2149,7 +2147,6 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (NCC) { NotifyColChanged(hWnd, SelfIndex); } if (NCC) { NotifyColChanged(hWnd, SelfIndex); }
DrawCursor(hWnd, SelfIndex); DrawCursor(hWnd, SelfIndex);
//SetCurrentCellStatus(hWnd,SelfIndex); //redundant
SetHomeRow(hWnd, SelfIndex, BGHS[SelfIndex].cursorrow, BGHS[SelfIndex].cursorcol); SetHomeRow(hWnd, SelfIndex, BGHS[SelfIndex].cursorrow, BGHS[SelfIndex].cursorcol);
SetHomeCol(hWnd, SelfIndex, BGHS[SelfIndex].cursorrow, BGHS[SelfIndex].cursorcol); SetHomeCol(hWnd, SelfIndex, BGHS[SelfIndex].cursorrow, BGHS[SelfIndex].cursorcol);
RefreshGrid(hWnd); RefreshGrid(hWnd);
@ -2184,7 +2181,6 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
DrawCursor(hWnd, SelfIndex); DrawCursor(hWnd, SelfIndex);
//SetCurrentCellStatus(hWnd,SelfIndex); //redundant
SetHomeRow(hWnd, SelfIndex, BGHS[SelfIndex].cursorrow, BGHS[SelfIndex].cursorcol); SetHomeRow(hWnd, SelfIndex, BGHS[SelfIndex].cursorrow, BGHS[SelfIndex].cursorcol);
RefreshGrid(hWnd); RefreshGrid(hWnd);
BGHS[SelfIndex].EDITING = FALSE; BGHS[SelfIndex].EDITING = FALSE;
@ -2258,7 +2254,6 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
NotifyRowChanged(hWnd, SelfIndex); NotifyRowChanged(hWnd, SelfIndex);
DrawCursor(hWnd, SelfIndex); DrawCursor(hWnd, SelfIndex);
//SetCurrentCellStatus(hWnd,SelfIndex); //redundant
SetHomeRow(hWnd, SelfIndex, BGHS[SelfIndex].cursorrow, BGHS[SelfIndex].cursorcol); SetHomeRow(hWnd, SelfIndex, BGHS[SelfIndex].cursorrow, BGHS[SelfIndex].cursorcol);
SetHomeCol(hWnd, SelfIndex, BGHS[SelfIndex].cursorrow, BGHS[SelfIndex].cursorcol); SetHomeCol(hWnd, SelfIndex, BGHS[SelfIndex].cursorrow, BGHS[SelfIndex].cursorcol);
RefreshGrid(hWnd); RefreshGrid(hWnd);
@ -2548,6 +2543,8 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_MOUSEWHEEL: case WM_MOUSEWHEEL:
{ {
if (!BGHS[SelfIndex].VSCROLL)
return TRUE;
short zDelta = (short)HIWORD(wParam); short zDelta = (short)HIWORD(wParam);
::SendMessage(hWnd, WM_VSCROLL, zDelta < 0 ? SB_LINEDOWN : SB_LINEUP, 0); ::SendMessage(hWnd, WM_VSCROLL, zDelta < 0 ? SB_LINEDOWN : SB_LINEUP, 0);
return TRUE; return TRUE;
@ -2601,6 +2598,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
} }
if (LOWORD(wParam) == SB_LINEDOWN) if (LOWORD(wParam) == SB_LINEDOWN)
{ {
RECT gridrect{}; RECT gridrect{};
@ -2627,8 +2625,6 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
if (LOWORD(wParam) == SB_PAGEUP) if (LOWORD(wParam) == SB_PAGEUP)
{ {
RECT gridrect{}; RECT gridrect{};
@ -2724,7 +2720,6 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
DrawCursor(hWnd, SelfIndex); DrawCursor(hWnd, SelfIndex);
BGHS[SelfIndex].GRIDHASFOCUS = TRUE; BGHS[SelfIndex].GRIDHASFOCUS = TRUE;
DrawCursor(hWnd, SelfIndex); DrawCursor(hWnd, SelfIndex);
//SetCurrentCellStatus(hWnd,SelfIndex); //redundant
SetHomeRow(hWnd, SelfIndex, BGHS[SelfIndex].cursorrow, BGHS[SelfIndex].cursorcol); SetHomeRow(hWnd, SelfIndex, BGHS[SelfIndex].cursorrow, BGHS[SelfIndex].cursorcol);
SetHomeCol(hWnd, SelfIndex, BGHS[SelfIndex].cursorrow, BGHS[SelfIndex].cursorcol); SetHomeCol(hWnd, SelfIndex, BGHS[SelfIndex].cursorrow, BGHS[SelfIndex].cursorcol);

View File

@ -17,7 +17,7 @@
#include "BabyGridWrapper.h" #include "BabyGridWrapper.h"
const TCHAR *babyGridClassName = TEXT("BABYGRID"); const wchar_t* babyGridClassName = L"BABYGRID";
bool BabyGridWrapper::_isRegistered = false; bool BabyGridWrapper::_isRegistered = false;
@ -37,4 +37,6 @@ void BabyGridWrapper::init(HINSTANCE hInst, HWND parent, int16_t id)
reinterpret_cast<HMENU>(id), reinterpret_cast<HMENU>(id),
_hInst, _hInst,
NULL); NULL);
_isRegistered = true;
} }