|
Post by (X) on Jan 16, 2024 14:36:24 GMT 1
I was coding along, minding my own business, when suddenly, I noticed something different when passing a Variant to be used by the LoadPicture() function...
It seemed to work fine in another program, but, in my 'reworked' code it would fail until I tried something different.
I used Cstr(A) instead of just 'A'. ('A' sometimes contained a filename, specifically ":Tex1", but none of the other filenames worked either.)
When using 'A', the width and height just contained '0'.
Proc P_Create_Texture(Nr%, A As Variant, Optional COL As Variant)
If IsObject(A) w = A.ScaleWidth h = A.ScaleHeight n++ 'n=Merker Trace CBool(IsObject(A)) Trace A Trace w Trace h Else Dim dbg = 1 Local Picture pic dbg = 2 : Set pic = LoadPicture(CStr(A)) Trace pic Trace pic.Handle Trace pic.Type w = pic.Width * Screen.TwipsPerHimet / Screen.TwipsPerPixelX h = pic.Height * Screen.TwipsPerHimet / Screen.TwipsPerPixelY Trace CBool(IsObject(A)) Trace A Trace pic.Width Trace w Trace h EndIf Take home message:"If at first you don't succeed, use Cstr()."
|
|