Undependeable Gadget Handle
Posted: Thu Sep 19, 2013 1:09 pm
As I already tried to explain in this thread
http://www.purebasic.fr/english/viewtop ... =4&t=55925
there are still circumstances that you can't trust
a returned handle.
In the above thread, I showed, that a handle
returned by CanvasGadget() can be invalid, even
if there was no error or warning raised.
freak tried to overcome this failure by arbitrarily
limit the size of CanvasGadget to 16000x16000.
Fred wrote, that there is a 2 GB limit. But you
can't use the Gadget within this 2GB limit.
That was one story.
Now, I discovered, that a returned handle for
ScrollAreaGadget also can't be trusted.
If you create a ScrollAreaGadget for example
32768x200 you get a handle, the Gadget is created,
but you can't use the whole size.
Please notice, that you can use a CanvasGadget
larger than 16000 in one direction.
So, again, you can't trust a returned handle.
I wonder if there are more of these unreliable handles exists.
http://www.purebasic.fr/english/viewtop ... =4&t=55925
there are still circumstances that you can't trust
a returned handle.
In the above thread, I showed, that a handle
returned by CanvasGadget() can be invalid, even
if there was no error or warning raised.
freak tried to overcome this failure by arbitrarily
limit the size of CanvasGadget to 16000x16000.
Fred wrote, that there is a 2 GB limit. But you
can't use the Gadget within this 2GB limit.
That was one story.
Now, I discovered, that a returned handle for
ScrollAreaGadget also can't be trusted.
If you create a ScrollAreaGadget for example
32768x200 you get a handle, the Gadget is created,
but you can't use the whole size.
Please notice, that you can use a CanvasGadget
larger than 16000 in one direction.
Code: Select all
Procedure SAGx()
SetWindowTitle(1, Str(GetGadgetAttribute(1, #PB_ScrollArea_X)))
EndProcedure
OpenWindow(1, 10, 10, 600, 600, "")
hScrollAreaGadget.i=ScrollAreaGadget(1, 0, 378, 600, 222, 64000, 200)
; no error or warning is raised here
BindGadgetEvent(1, @SAGx()); just display x-pos of ScrollAreaGadget in WindowTitle
DisableDebugger
hCanvasGadget.i=CanvasGadget(2, 0,0,64000, 200)
; CanvasSize is way below 2GB-limit, but because of the 16000x16000 limit arbitrarily
; intruduced in PB 5.20 we have to disable debugger in order to get what we want
EnableDebugger
CloseGadgetList()
Debug hScrollAreaGadget; shows valid handle
Debug hCanvasGadget; shows valid handle
CreateImage(1, 200, 200); Create something to display
StartDrawing(ImageOutput(1))
LineXY(0 ,0, 199, 199, $0000FF)
LineXY(199, 0, 0, 199, $0000FF)
StopDrawing()
;Display Image in different positions
StartDrawing(CanvasOutput(2))
DrawImage(ImageID(1), 0, 0)
;
DrawImage(ImageID(1), 32000-200, 0) ; visible
DrawImage(ImageID(1), 32768-200, 0) ; visible
DrawImage(ImageID(1), 64000-200, 0) ; NOT visible
;
StopDrawing()
Repeat
Event=WaitWindowEvent()
Until Event=#PB_Event_CloseWindow
I wonder if there are more of these unreliable handles exists.