Forum > Windows
[SOLVED] THUMBBUTTON does not work in Laz 64
Xenno:
My code below is to show thumb buttons on taskbar.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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:
--- Quote from: Xenno on July 15, 2025, 05:05:55 am ---My code below is to show thumb buttons on taskbar.
--- End quote ---
Please make an example that can be compiled.
By the way in
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- 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:
--- Quote from: ASerge on July 15, 2025, 08:10:40 pm ---Please make an example that can be compiled.
--- End quote ---
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 pm ---why are you calling CreateComObject again? FTaskbarList3 has already been initialized with the Supports function.
--- End quote ---
You are right. I was modifying the code in trying to find solution. Please refer to the attached code,
TIA,
ASerge:
--- Quote from: Xenno on July 16, 2025, 08:52:47 am ---Sure, attached.
32 bits in Laz 3.8 (OK)
64 bits in Laz 4.0 (not OK)
--- End quote ---
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 [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- 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]));
--- Quote ---You are right. I was modifying the code in trying to find solution. Please refer to the attached code,
--- End quote ---
Better:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- 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:
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.
Navigation
[0] Message Index
[#] Next page