Drawing on a Plain Window
Posted: Sat Jan 04, 2025 3:58 am
Hi, thanks for having me. My background is Visual Basic prior to .NET. I have purchased PureBasic, and am currently teaching myself on a Mac Mini M4. This is a very small program, which is supposed to draw on a window itself (i.e., no ImageGadget). It is a variant on a program from page 1671 of the book, "PureBasic Reference Manual 6.00." On pressing the button, the program is supposed to draw a red box on the window. It doesn’t work, and I don’t know why. All help is appreciated!
Thanks,
Mike
Thanks,
Mike
Code: Select all
If OpenWindow(0, 0, 0, 640, 480, "WindowOutput Example...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(1, (640 - 200) / 2, (480 - 30) - 10, 200, 30, "Draw on Window")
Repeat
E = WaitWindowEvent()
Select E
Case #PB_Event_Gadget
Select EventGadget()
Case 1
If StartDrawing(WindowOutput(0))
Box(100, 100, 100, 100, RGB(255, 0, 0))
StopDrawing()
EndIf
EndSelect
EndSelect
Until E = #PB_Event3D_CloseWindow
EndIf