Bug in example 2DDrawing ?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tony_usa.

Hi folks,

Just bought purebasic. I am running the 2DDrawing example. If I drag a part of the window outside the screen and then drag it back, there is an repainting problem.

Is it a bug we should report? Is there a way to fix it myself?

Thanks,
Tony

PS: Windows XP Home
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Berikco.

Not a bug.
This is just a very basic example, if you would like to do 2D drawing, better do it on a bitmap.
This way no part of the window is erased.


Regards,

Berikco

http://users.pandora.be/berikco/purebasic.htm
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.


2dDrawings on a Window need to be redrawn, each time they have been erased by moving and such stuff.
Wait for the #PB_EventRepaint Event and then do your drawings again.
This is no bug, it is usual windows behaviour.

If you don't want to redraw it all time, use a Bitmap like Berikco suggested.

A more detailed example on that solution can be found here: (2nd post of the thread)
viewtopic.php?t=5408">http://forums.pur ... pages.com/
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by LJ.
Originally posted by tony_usa

Hi folks,

Just bought purebasic. I am running the 2DDrawing example. If I drag a part of the window outside the screen and then drag it back, there is an repainting problem.

Is it a bug we should report? Is there a way to fix it myself?

Thanks,
Tony

PS: Windows XP Home
Here is some sample code. The idea is to draw it in an image because Windows automatically updates Images so you don't need to do Callback then Repaint. You don't need all of this code, some extra little things. The UpdateWindow routine is simply there as the basis of a much larger program I am working on that I wanted to test destroying items so the .exe doesn't leak 4K every 3 - 5 clicks on the buttons, also extra tooltip balloon messages, but you will get the idea. Try resizing, or ALT-TAB, or minimizing then bringing back up, everything is redrawn perfectly because it is in an Image (Create Image, then draw to the image)

Global ToolTipControl

Procedure AddButtonToolTip(Handle,Text$)
#TTS_BALLOON = $40
ToolTipControl=CreateWindowEx_(0,"tooltips_class32","",$D0000000|#TTS_BALLOON,0,0,0,0,WindowID(),0,GetModuleHandle_(0),0)
sendMessage_(ToolTipControl,1044,0 ,0) ;ForeColor Tooltip
sendMessage_(ToolTipControl,1043,$58F5D6,0) ;BackColor Tooltip
sendMessage_(ToolTipControl,1048,0,180) ;Maximum Width of tooltip
Button.TOOLINFO\cbSize=84 ; SizeOf( TOOLINFO )
Button\uFlags=$11
Button\hWnd=Handle
Button\uId=Handle
Button\lpszText=@Text$
SendMessage_(ToolTipControl,$0404,0,Button)
ProcedureReturn ToolTipControl ; Return the handle !
EndProcedure

OpenWindow(1, 0, 0, 796, 550, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget, "Background image example")
CreateGadgetList(WindowID())
CreateImage(1, WindowWidth(), WindowHeight())
StartDrawing(ImageOutput())
Box(0, 0, WindowWidth(), WindowHeight(), $ff)
FrontColor(0, 0, 0)
DrawingMode(1)
DrawingFont(LoadFont(0, "Times New Roman", 16))
Locate(64, 32)
DrawText("Background image")
StopDrawing()
ImageGadget(1, 0, 0, WindowWidth(), WindowHeight(), UseImage(1))
ButtonGadget = ButtonGadget(0, 80, 64, 160, 128, "My Button")
ButtonGadgettwo = ButtonGadget(2, 80, 204, 160, 128, "My Button Two")
ToolTipHandle1 = AddButtonToolTip(ButtonGadget,"Test message for Button 1")
ToolTipHandle2 = AddButtonToolTip(ButtonGadgettwo,"Test message for Button 2")
LoadFont(0, "Times New Roman", 16)

Repeat
EventID = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()

Case 0
Gosub UpdateWindow

Case 2
Gosub UpdateWindow

EndSelect
EndIf


Until EventID = #PB_EventCloseWindow
End

UpdateWindow:
DestroyWindow_(ToolTipHandle1)
DestroyWindow_(ToolTipHandle2)
FreeGadget (0):FreeGadget(2)
UseImage(1)
StartDrawing(ImageOutput())
Box(0, 0, WindowWidth(), WindowHeight(), $ff)
FrontColor(0, 0, 0)
DrawingMode(1)
DrawingFont(UseFont(0))
Locate(64, 32)
DrawText("Test image")
StopDrawing()
ButtonGadget = ButtonGadget(0, 80, 64, 160, 128, "My Button")
ButtonGadgettwo = ButtonGadget(2, 80, 204, 160, 128, "My Button Two")
ToolTipHandle1 = AddButtonToolTip(ButtonGadget,"Test message for Button 1")
ToolTipHandle2 = AddButtonToolTip(ButtonGadgettwo,"Test message for Button 2")
SetGadgetState(1, UseImage(1))
ActivateGadget(0)
Return
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tony_usa.

Everyone: thanks
Post Reply