[SOLVED] THUMBBUTTON does not work in Laz 64 lazarus / 34-Windows ---------------------------------------------------------------------- Xenno · 2025-07-15 03:05 My code below is to show thumb buttons on taskbar. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses ... ShlObj ..// in classFTaskbarList: ITaskbarList;FTaskbarList3: ITaskbarList3;   .. ..// in FormCreate or FormShowif (CheckWin32Version(6, 1)) then begin  FTaskbarList := CreateComObject(CLSID_TaskbarList) as ITaskbarList;  FTaskbarList.HrInit;  if (Supports(FTaskbarList, ITaskbarList3, FTaskbarList3)) then begin    FTaskbarList3 := CreateComObject(CLSID_TaskbarList) as ITaskbarList3;  end;end;        .. procedure TFormMain.PrcThumbButtons;var  Buttons: array [1..2] of THUMBBUTTON;  i: Integer;begin  Buttons[1].iId := 41;  if (FilePrior1.Enabled) then begin    Buttons[1].dwFlags := THBF_ENABLED;    Buttons[1].iBitmap := 0;     StrCopy(Buttons[1].szTip, 'Prior');  end else begin    Buttons[1].dwFlags := THBF_DISABLED;    Buttons[1].iBitmap := 1;    StrCopy(Buttons[1].szTip, '');  end;   Buttons[2].iId := 42;  if (FileNext1.Enabled) then begin    Buttons[2].dwFlags := THBF_ENABLED;    Buttons[2].iBitmap := 2;    StrCopy(Buttons[2].szTip, 'Next');  end else begin    Buttons[2].dwFlags := THBF_DISABLED;    Buttons[2].iBitmap := 3;    StrCopy(Buttons[2].szTip, '');  end;   {$IFDEF FPC}  if (FThumbButtonsFlag = '') then begin    FTaskbarList3.ThumbBarSetImageList(Application.Handle, ImageList2.Reference[0].Handle);    FTaskbarList3.ThumbBarAddButtons(Application.Handle, Length(Buttons), @Buttons);  end else    FTaskbarList3.ThumbBarUpdateButtons(Application.Handle, Length(Buttons), @Buttons);  {$ELSE}  if (FThumbButtonsFlag = '') then begin    FTaskbarList3.ThumbBarSetImageList(Handle, ImageList2.Handle);    FTaskbarList3.ThumbBarAddButtons(Handle, Length(Buttons), @Buttons);  end else    FTaskbarList3.ThumbBarUpdateButtons(Handle, Length(Buttons), @Buttons);    {$ENDIF}   FThumbButtonsFlag := NewFlag;end;     It works on Delphi 32-bits, Delphi 64-bits, and Lazarus 32-bits but it fails on Lazarus 64-bits. I tried many things but still same result. It looks like Laz 64 feed different size of THUMBBUTTON. Does anyone have experience and solution? TIA, ---------------------------------------------------------------------- ASerge · 2025-07-15 18:10 Quote from: Xenno on July 15, 2025, 05:05:55 amMy code below is to show thumb buttons on taskbar. Please make an example that can be compiled. By the way in Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   if (Supports(FTaskbarList, ITaskbarList3, FTaskbarList3)) then begin    FTaskbarList3 := CreateComObject(CLSID_TaskbarList) as ITaskbarList3;why are you calling CreateComObject again? FTaskbarList3 has already been initialized with the Supports function. ---------------------------------------------------------------------- Xenno · 2025-07-16 06:52 Quote from: ASerge on July 15, 2025, 08:10:40 pmPlease make an example that can be compiled. Sure, attached. 32 bits in Laz 3.8 (OK) 64 bits in Laz 4.0 (not OK) Quote from: ASerge on July 15, 2025, 08:10:40 pmwhy are you calling CreateComObject again? FTaskbarList3 has already been initialized with the Supports function. You are right. I was modifying the code in trying to find solution. Please refer to the attached code, TIA, ---------------------------------------------------------------------- ASerge · 2025-07-16 17:51 Quote from: Xenno on July 16, 2025, 08:52:47 amSure, attached. 32 bits in Laz 3.8 (OK) 64 bits in Laz 4.0 (not OK) Yes, it won't work in 64-bit. Workaround: copy the definition of "THUMBBUTTON" and delete "packed" from it. These are the new last lines of the example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   if FThumbButtonsFlag = '' then  begin    FTaskbarList3.ThumbBarSetImageList(Application.Handle, ImageList1.Reference[0].Handle);    FTaskbarList3.ThumbBarAddButtons(Application.Handle, Length(Buttons), Pointer(@Buttons[1]));  end  else    FTaskbarList3.ThumbBarUpdateButtons(Application.Handle, Length(Buttons), Pointer(@Buttons[1])); QuoteYou are right. I was modifying the code in trying to find solution. Please refer to the attached code, Better: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   FTaskbarList := CreateComObject(CLSID_TaskbarList) as ITaskbarList;  FTaskbarList.HrInit;  if not Supports(FTaskbarList, ITaskbarList3, FTaskbarList3) then    FTaskbarList3 := nil;  FThumbButtonsFlag := ''; Please add the issue to the FPC bug list. ---------------------------------------------------------------------- Xenno · 2025-07-16 18:50 Confirmed. This workaround solves the issue. The iId values are also correct in WMSYSCOMMAND WM_COMMAND. Note: @Buttons also works instead of Pointer(@Buttons[1]) Thank you very much, ASerge. ---------------------------------------------------------------------- ASerge · 2025-07-16 19:03 Quote from: Xenno on July 16, 2025, 08:50:12 pmNote: @Buttons also works instead of Pointer(@Buttons[1]) I always test with {$T+} (in Project/Project Options.../Compiler Options/Parsing) In this case, the compiler throws an error: Error: Incompatible type for arg no. 3: Got "^Array[1..2] Of THUMBBUTTON", expected "LPTHUMBBUTTON" ---------------------------------------------------------------------- ASerge · 2025-07-16 19:22 Added issue 41333 to the buglist. ---------------------------------------------------------------------- Xenno · 2025-07-17 05:32 Thank you again, ASerge. If anyone needs to implement THUMBBUTTON further, allow me to share code. 1. Add a private procedure to handle THUMBBUTTON when clicked and implement it, for example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   ...  private    procedure PrcThumbButtonClick(PrmId: Integer);   ... procedure TFormMain.PrcThumbButtonClick(PrmId: Integer);begin  ShowMessage('ID: ' + IntToStr(PrmId)); // replace this with yoursend;   2. Add form's Windows message handler in public part of form class and implement it, for example:      Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   ...  public    function FncAppWndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam;       lParam: LParam): LRESULT;     ... function TFormMain.FncAppWndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam;  lParam: LParam): LRESULT;begin  case uMsg of    WM_COMMAND: begin    if (HIWORD(WParam) = THBN_CLICKED) then        PrcThumbButtonClick(LOWORD(WParam));    end;  end;  Result := CallWindowProc(PrevAppWndProc, Ahwnd, uMsg, WParam, LParam);end; 3. Add application's Windows message handler in unit's implementation section: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  PrevAppWndProc: WNDPROC; function AppWndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam;  lParam: LParam): LRESULT; stdcall;begin  Result := FormMain.FncAppWndCallback(Ahwnd, uMsg, WParam, LParam);end; 4. Insert code in Form show: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i PrevAppWndProc := Windows.WNDPROC(SetWindowLongPtr(Application.Handle, GWL_WNDPROC, PtrUInt(@AppWndCallback)));  Done. The application is ready to respond when a thumb button is clicked. Cheers, ---------------------------------------------------------------------- ASerge · 2025-07-17 15:33 Quote from: Xenno on July 17, 2025, 07:32:18 amIf anyone needs to implement THUMBBUTTON further, allow me to share code. Safer: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses Windows, Messages, CommCtrl, ComObj;//...function AppSubClassProc(Wnd: HWND; Msg: UINT; WParam: WPARAM; LParam: LPARAM;  uISubClass: UINT_PTR; dwRefData: DWORD_PTR): LRESULT; stdcall;var  Self: TFormMain absolute dwRefData;begin  if (Msg = WM_COMMAND) and (HIWORD(WParam) = THBN_CLICKED) then    Self.PrcThumbButtonClick(LOWORD(WParam));  Result := DefSubclassProc(Wnd, Msg, WParam, LParam);end; procedure TFormMain.FormShow(Sender: TObject);begin  SetWindowSubclass(Application.Handle, @AppSubClassProc, 1, DWORD_PTR(Self));end;