From 11cc2c18fb5578b757fdddb44f9730502025716d Mon Sep 17 00:00:00 2001
From: George Hazan <ghazan@miranda.im>
Date: Wed, 26 Apr 2023 13:50:58 +0300
Subject: much more effective way of resizing custom log viewers

---
 plugins/HistoryPlusPlus/historypp.dproj      |   2 +-
 plugins/HistoryPlusPlus/hpp_external.pas     | 230 ++++++++++++---------------
 plugins/HistoryPlusPlus/hpp_externalgrid.pas |   7 -
 plugins/TabSRMM/src/msgdialog.cpp            |   4 +-
 4 files changed, 106 insertions(+), 137 deletions(-)

(limited to 'plugins')

diff --git a/plugins/HistoryPlusPlus/historypp.dproj b/plugins/HistoryPlusPlus/historypp.dproj
index dac7decafd..dba6d42d27 100644
--- a/plugins/HistoryPlusPlus/historypp.dproj
+++ b/plugins/HistoryPlusPlus/historypp.dproj
@@ -8,7 +8,7 @@
 			<AppType>Library</AppType>
 			<FrameworkType>VCL</FrameworkType>
 			<ProjectVersion>13.4</ProjectVersion>
-			<Platform Condition="'$(Platform)'==''">Win32</Platform>
+			<Platform Condition="'$(Platform)'==''">Win64</Platform>
 		</PropertyGroup>
 		<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
 			<Base>true</Base>
diff --git a/plugins/HistoryPlusPlus/hpp_external.pas b/plugins/HistoryPlusPlus/hpp_external.pas
index cb81d72363..9c3dbb8ed7 100644
--- a/plugins/HistoryPlusPlus/hpp_external.pas
+++ b/plugins/HistoryPlusPlus/hpp_external.pas
@@ -67,76 +67,60 @@ uses
 var
   hExtOptChanged: THandle;
 
-function _ExtWindow(wParam:WPARAM; lParam: LPARAM): uint_ptr;
+function ExtWindowNative(wParam:WPARAM; lParam: LPARAM): uint_ptr; cdecl;
 var
   par: PIEVIEWWINDOW;
   ExtGrid: TExternalGrid;
-  ControlID: Cardinal;
 begin
   Result := 0;
-  //try
-    par := PIEVIEWWINDOW(lParam);
-    Assert(par <> nil, 'Empty IEVIEWWINDOW structure');
-    case par.iType of
-      IEW_CREATE: begin
-        {$IFDEF DEBUG}
-        OutputDebugString('IEW_CREATE');
-        {$ENDIF}
-        case par.dwMode of
-          IEWM_TABSRMM: ControlID := 1006;  // IDC_LOG from tabSRMM
-          IEWM_SCRIVER: ControlID := 1001;  // IDC_LOG from Scriver
-          IEWM_MUCC:    ControlID := 0;
-          IEWM_CHAT:    ControlID := 0;
-          IEWM_HISTORY: ControlID := 0;
-        else            ControlID := 0;
-        end;
-        ExtGrid := TExternalGrid.Create(par.Parent,ControlID);
-        case par.dwMode of
-          IEWM_MUCC,IEWM_CHAT: begin
-            ExtGrid.ShowHeaders   := False;
-            ExtGrid.GroupLinked   := False;
-            ExtGrid.ShowBookmarks := False;
-          end;
-          IEWM_HISTORY:
-            ExtGrid.GroupLinked := False;
+
+  par := PIEVIEWWINDOW(lParam);
+  Assert(par <> nil, 'Empty IEVIEWWINDOW structure');
+  case par.iType of
+    IEW_CREATE: begin
+      {$IFDEF DEBUG}
+      OutputDebugString('IEW_CREATE');
+      {$ENDIF}
+      ExtGrid := TExternalGrid.Create(par.Parent);
+      case par.dwMode of
+        IEWM_MUCC,IEWM_CHAT: begin
+          ExtGrid.ShowHeaders   := False;
+          ExtGrid.GroupLinked   := False;
+          ExtGrid.ShowBookmarks := False;
         end;
-        ExtGrid.SetPosition(par.x,par.y,par.cx,par.cy);
-        ExternalGrids.Add(ExtGrid);
-        par.Hwnd := ExtGrid.GridHandle;
-      end;
-      IEW_DESTROY: begin
-        {$IFDEF DEBUG}
-        OutputDebugString('IEW_DESTROY');
-        {$ENDIF}
-        ExternalGrids.Delete(par.Hwnd);
-      end;
-      IEW_SETPOS: begin
-        {$IFDEF DEBUG}
-        OutputDebugString('IEW_SETPOS');
-        {$ENDIF}
-        ExtGrid := ExternalGrids.Find(par.Hwnd);
-        if ExtGrid <> nil then
-          ExtGrid.SetPosition(par.x,par.y,par.cx,par.cy);
-      end;
-      IEW_SCROLLBOTTOM: begin
-        {$IFDEF DEBUG}
-        OutputDebugString('IEW_SCROLLBOTTOM');
-        {$ENDIF}
-        ExtGrid := ExternalGrids.Find(par.Hwnd);
-        if ExtGrid <> nil then
-          ExtGrid.ScrollToBottom;
+        IEWM_HISTORY:
+          ExtGrid.GroupLinked := False;
       end;
+      ExtGrid.SetPosition(par.x,par.y,par.cx,par.cy);
+      ExternalGrids.Add(ExtGrid);
+      par.Hwnd := ExtGrid.GridHandle;
     end;
-  //except
-  //end;
-end;
-
-function ExtWindowNative(wParam:WPARAM; lParam: LPARAM): uint_ptr; cdecl;
-begin
-  Result := _ExtWindow(wParam,lParam);
+    IEW_DESTROY: begin
+      {$IFDEF DEBUG}
+      OutputDebugString('IEW_DESTROY');
+      {$ENDIF}
+      ExternalGrids.Delete(par.Hwnd);
+    end;
+    IEW_SETPOS: begin
+      {$IFDEF DEBUG}
+      OutputDebugString('IEW_SETPOS');
+      {$ENDIF}
+      ExtGrid := ExternalGrids.Find(par.Hwnd);
+      if ExtGrid <> nil then
+        ExtGrid.SetPosition(par.x,par.y,par.cx,par.cy);
+    end;
+    IEW_SCROLLBOTTOM: begin
+      {$IFDEF DEBUG}
+      OutputDebugString('IEW_SCROLLBOTTOM');
+      {$ENDIF}
+      ExtGrid := ExternalGrids.Find(par.Hwnd);
+      if ExtGrid <> nil then
+        ExtGrid.ScrollToBottom;
+    end;
+  end;
 end;
 
-function _ExtEvent(wParam:WPARAM; lParam: LPARAM): uint_ptr; cdecl;
+function ExtEventNative(wParam:WPARAM; lParam: LPARAM): uint_ptr; cdecl;
 var
   event: PIEVIEWEVENT;
   customEvent: PIEVIEWEVENTDATA;
@@ -147,79 +131,71 @@ var
   CustomItem: TExtCustomItem;
 begin
   Result := 0;
-  //try
-    {$IFDEF DEBUG}
-    OutputDebugString('MS_IEVIEW_EVENT');
-    {$ENDIF}
-    event := PIEVIEWEVENT(lParam);
-    Assert(event <> nil, 'Empty IEVIEWEVENT structure');
-    ExtGrid := ExternalGrids.Find(event.Hwnd);
-    if ExtGrid = nil then exit;
-    case event.iType of
-      IEE_LOG_DB_EVENTS: begin
-        UsedCodepage := event.Codepage;
-        eventCount := event.Count;
-        hDBNext := event.Event.hDBEventFirst;
-        ExtGrid.BeginUpdate;
-        while (eventCount <> 0) and (hDBNext <> 0) do
-        begin
-          ExtGrid.AddEvent(event.hContact, hDBNext, UsedCodepage,
+
+  {$IFDEF DEBUG}
+  OutputDebugString('MS_IEVIEW_EVENT');
+  {$ENDIF}
+  event := PIEVIEWEVENT(lParam);
+  Assert(event <> nil, 'Empty IEVIEWEVENT structure');
+  ExtGrid := ExternalGrids.Find(event.Hwnd);
+  if ExtGrid = nil then exit;
+  case event.iType of
+    IEE_LOG_DB_EVENTS: begin
+      UsedCodepage := event.Codepage;
+      eventCount := event.Count;
+      hDBNext := event.Event.hDBEventFirst;
+      ExtGrid.BeginUpdate;
+      while (eventCount <> 0) and (hDBNext <> 0) do
+      begin
+        ExtGrid.AddEvent(event.hContact, hDBNext, UsedCodepage,
+                         boolean(event.dwFlags and IEEF_RTL),
+                         not boolean(event.dwFlags and IEEF_NO_SCROLLING));
+        if eventCount > 0 then Dec(eventCount);
+        if eventCount <> 0 then
+          hDBNext := db_event_next(event.hContact,hDBNext);
+      end;
+      ExtGrid.EndUpdate;
+    end;
+    IEE_LOG_MEM_EVENTS: begin
+      UsedCodepage := event.Codepage;
+      eventCount := event.Count;
+      customEvent := event.Event.eventData;
+      ExtGrid.BeginUpdate;
+      while (eventCount <> 0) and (customEvent <> nil) do
+      begin
+        if boolean(customEvent.dwFlags and IEEDF_UNICODE_TEXT) then
+          SetString(CustomItem.Text,customEvent.Text.w,lstrlenW(customEvent.Text.w))
+        else
+          CustomItem.Text := AnsiToWideString(AnsiString(customEvent.Text.a),UsedCodepage);
+        if boolean(customEvent.dwFlags and IEEDF_UNICODE_NICK) then
+          SetString(CustomItem.Nick,customEvent.Nick.w,lstrlenW(customEvent.Nick.w))
+        else
+          CustomItem.Nick := AnsiToWideString(AnsiString(customEvent.Nick.a),UsedCodepage);
+        CustomItem.Sent := boolean(customEvent.bIsMe);
+        CustomItem.Time := customEvent.time;
+        CustomItem.hEvent := customEvent.hEvent;
+        ExtGrid.AddCustomEvent(event.hContact, CustomItem, UsedCodepage,
                            boolean(event.dwFlags and IEEF_RTL),
                            not boolean(event.dwFlags and IEEF_NO_SCROLLING));
-          if eventCount > 0 then Dec(eventCount);
-          if eventCount <> 0 then
-            hDBNext := db_event_next(event.hContact,hDBNext);
-        end;
-        ExtGrid.EndUpdate;
-      end;
-      IEE_LOG_MEM_EVENTS: begin
-        UsedCodepage := event.Codepage;
-        eventCount := event.Count;
-        customEvent := event.Event.eventData;
-        ExtGrid.BeginUpdate;
-        while (eventCount <> 0) and (customEvent <> nil) do
-        begin
-          if boolean(customEvent.dwFlags and IEEDF_UNICODE_TEXT) then
-            SetString(CustomItem.Text,customEvent.Text.w,lstrlenW(customEvent.Text.w))
-          else
-            CustomItem.Text := AnsiToWideString(AnsiString(customEvent.Text.a),UsedCodepage);
-          if boolean(customEvent.dwFlags and IEEDF_UNICODE_NICK) then
-            SetString(CustomItem.Nick,customEvent.Nick.w,lstrlenW(customEvent.Nick.w))
-          else
-            CustomItem.Nick := AnsiToWideString(AnsiString(customEvent.Nick.a),UsedCodepage);
-          CustomItem.Sent := boolean(customEvent.bIsMe);
-          CustomItem.Time := customEvent.time;
-          CustomItem.hEvent := customEvent.hEvent;
-          ExtGrid.AddCustomEvent(event.hContact, CustomItem, UsedCodepage,
-                             boolean(event.dwFlags and IEEF_RTL),
-                             not boolean(event.dwFlags and IEEF_NO_SCROLLING));
-          if eventCount > 0 then Dec(eventCount);
-          customEvent := customEvent.next;
-        end;
-        ExtGrid.EndUpdate;
-      end;
-      IEE_CLEAR_LOG: begin
-        ExtGrid.BeginUpdate;
-        ExtGrid.Clear;
-        ExtGrid.EndUpdate;
-      end;
-      IEE_GET_SELECTION: begin
-        Result := uint_ptr(ExtGrid.GetSelection());
-      end;
-      IEE_SAVE_DOCUMENT: begin
-        ExtGrid.SaveSelected;
+        if eventCount > 0 then Dec(eventCount);
+        customEvent := customEvent.next;
       end;
+      ExtGrid.EndUpdate;
     end;
-  //except
-  //end;
-end;
-
-function ExtEventNative(wParam:WPARAM; lParam: LPARAM): uint_ptr; cdecl;
-begin
-  Result := _ExtEvent(wParam,lParam);
+    IEE_CLEAR_LOG: begin
+      ExtGrid.BeginUpdate;
+      ExtGrid.Clear;
+      ExtGrid.EndUpdate;
+    end;
+    IEE_GET_SELECTION: begin
+      Result := uint_ptr(ExtGrid.GetSelection());
+    end;
+    IEE_SAVE_DOCUMENT: begin
+      ExtGrid.SaveSelected;
+    end;
+  end;
 end;
 
-
 function ExtNavigate(wParam:WPARAM; lParam: LPARAM): uint_ptr; cdecl;
 begin
   Result := 0;
diff --git a/plugins/HistoryPlusPlus/hpp_externalgrid.pas b/plugins/HistoryPlusPlus/hpp_externalgrid.pas
index 364e3b0331..ce87e08aef 100644
--- a/plugins/HistoryPlusPlus/hpp_externalgrid.pas
+++ b/plugins/HistoryPlusPlus/hpp_externalgrid.pas
@@ -458,7 +458,6 @@ begin
   TranslateMenu(pmLink.Items);
 
   CreateEventsFilterMenu;
-  // SetEventFilter(GetDBInt(hppDBName,'RecentLogFilter',GetShowAllEventsIndex));
   SetEventFilter(GetShowAllEventsIndex);
 end;
 
@@ -693,11 +692,6 @@ begin
     end;
 end;
 
-// procedure TExternalGrid.HMIcons2Changed(var M: TMessage);
-// begin
-// Grid.Repaint;
-// end;
-
 procedure TExternalGrid.GridSelectRequest(Sender: TObject);
 begin
   if (Grid.Selected <> -1) and Grid.IsVisible(Grid.Selected) then
@@ -1214,7 +1208,6 @@ end;
 procedure TExternalGrid.GridMCData(Sender: TObject; Index: Integer; var Item: TMCItem; Stage: TSaveStage);
 var
   DBEventInfo: TOldDBEventInfo;
-  dbei : TDBEventInfo;
   hDBEvent: THandle;
   DataOffset: PAnsiChar;
   TextUTF: Utf8String;
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index 11065a5733..b131ac952c 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -1079,8 +1079,7 @@ int CMsgDialog::Resizer(UTILRESIZECONTROL *urc)
 
 	int  iSplitterX = m_pContainer->cfg.iSplitterX;
 
-	RECT rc, rcButton;
-	GetClientRect(m_pLog->GetHwnd(), &rc);
+	RECT rcButton;
 	GetClientRect(GetDlgItem(m_hwnd, IDC_PROTOCOL), &rcButton);
 
 	if (m_bIsAutosizingInput)
@@ -1183,6 +1182,7 @@ int CMsgDialog::Resizer(UTILRESIZECONTROL *urc)
 		return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM;
 
 	case IDC_CONTACTPIC:
+		RECT rc;
 		GetClientRect(m_message.GetHwnd(), &rc);
 		urc->rcItem.top -= m_iSplitterY - m_originalSplitterY;
 		urc->rcItem.left = urc->rcItem.right - (m_pic.cx + 2);
-- 
cgit v1.2.3