Forum > LCL
Got "BITMAP", expected "TBitmap"
lazer:
Hi,
I'm trying to change a TspeedButton's glyph during runtime.
I have two spare TspeedButton on my form with a tick and a cross glyph. I need to swap these onto my visible buttons or clear the glyph .
The following code works fine on Linux but won't compile for windows.
--- 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";}};} ---var bmp:Tbitmap;... testMarks[i] of markNone: bmp:=nil; markBad: bmp:=cross24Btn.glyph; markGood: bmp:=tick24Btn.glyph; end; panelButton.glyph:=bmp; panelButton.visible:=bmp<>nil;
--- 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";}};} ---form1.pas(1185,26) Error: Incompatible types: got "Pointer" expected "BITMAP"form1.pas(1185,26) Error: Incompatible types: got "Pointer" expected "BITMAP"form1.pas(1185,26) Error: Incompatible types: got "Pointer" expected "BITMAP"form1.pas(1189,43) Error: Incompatible type for arg no. 1: Got "BITMAP", expected "TBitmap"speedbutton.inc(203,30) Hint: Found declaration: SetGlyph(TBitmap);
The IDE shows glyph property to be Tbitmap on Linux, why does it not accept this assignment?
I guess the underlying libraries are different , how should I do this to span both platforms?
TIA.
Lazarus 2.3.0 (rev main-2_3-2165-gc63984efd6) FPC 3.3.1 x86_64-linux-gtk2
Thaddy:
There are TWO Tbitmaps under windows and in two different units:graphics and windows.
Windows.Tbitmap equals BITMAP, which is a windows API structure.
A generic TBitmap is Graphics.TBitmap, so if you qualify with the unit name ( or have the units in the right order in the uses clause) everything should be fine.
lazer:
Many thanks for the explanation.
I got around it by directly assigning using glyph.clear and getting rid of bmp, but it's great to know what's going on for next time.
;)
lazer:
Well, I thought I'd found a way around but I cannot find out what to test to see whether I called glyph.clear.
numglyphs=0 does not seem to help. What property can I test?
thanks
KodeZwerg:
--- Quote from: lazer on October 29, 2022, 03:54:36 pm ---
--- 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";}};} ---var bmp: Graphics.Tbitmap; // <- do direct assignment like thaddy told
--- End quote ---
Hope it helps.
Navigation
[0] Message Index
[#] Next page