It seems to get that with F5 which is the using of debugger by default (in my case).
I have used enableExplicit and all variable takes 8 bytes (.i or .d).
WhaitEvent() is used to get more reactivity.
I have to test it on Windows 11.
why I cannot write a procedure in the loop event
Re: why I cannot write a procedure in the loop event
Code: Select all
Repeat
Select WaitWindowEvent()
Case #PB_Event_Timer
; the first option
Case #PB_Event_Gadget
Select EventGadget()
Case 0
; code
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
; the second option
i + 1
If i > 100 ; 100 - how often will the code be executed. If a window loses focus, it reduces the frequency of event polling.
i = 0
; Procedure call
; it should be executed quickly to avoid slowing down the window
EndIf
ForEver
Why do the calculation? Draw the image once and then copy it to the surface
Users who don't have 2,000 messages should be banned from writing theremk-soft wrote: Mon Aug 11, 2025 8:31 pm Please do not immediately write everything in the bug reports.
Re: why I cannot write a procedure in the loop event
If there isn't window event (like move mouse) there isn't drawing.
I'm going further by saying that those who don't have 4000 messages can't write
I'm going further by saying that those who don't have 4000 messages can't write

Re: why I cannot write a procedure in the loop event
I'm not that good in window gadgets and things, so I'm not sure if this is a good practice or a bad one.
Code: Select all
OpenWindow(0,0,0,0,0,"")
Repeat
Repeat
myevent = WindowEvent()
Select myevent
Case #PB_Event_CloseWindow
End
Case #PB_Event_Timer
; the first option
Case #PB_Event_Gadget
Select EventGadget()
Case 0
; code
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
Until myevent = 0
; the second option
i + 1
SetWindowTitle(0,Str(i))
If i > 100 ; 100 - how often will the code be executed. If a window loses focus, it reduces the frequency of event polling.
i = 0
; Procedure call
; it should be executed quickly to avoid slowing down the window
EndIf
ForEver
Re: why I cannot write a procedure in the loop event
Call up recurring tasks with a timer.
Write down the processes for the tasks in advance.
A ( meaningful) structure ...
Template
Write down the processes for the tasks in advance.
A ( meaningful) structure ...
Template
Code: Select all
;-TOP
#ProgramTitle = "Main Window"
#ProgramVersion = "v1.01.2"
Enumeration Windows
#Main
EndEnumeration
Enumeration MenuBar
#MainMenu
EndEnumeration
Enumeration MenuItems
#MainMenuAbout
#MainMenuExit
EndEnumeration
Enumeration Gadgets
#MainCanvas
EndEnumeration
Enumeration StatusBar
#MainStatusBar
EndEnumeration
; ----
Procedure DrawCanvas()
Protected dx, dy, width, cnt.d
dx = GadgetWidth(#MainCanvas)
dy = GadgetHeight(#MainCanvas)
If StartDrawing(CanvasOutput(#MainCanvas))
Box(0, 0, dx, dy, #White)
cnt = Mod(ElapsedMilliseconds() * 0.001, 10)
width = dx * cnt / 10
Box(0, 0, width, dy, #Blue)
StopDrawing()
EndIf
EndProcedure
; ----
Procedure DoTimerEvent_1s()
StatusBarText(#MainStatusBar, 0, FormatDate(" %HH:%II:%SS", Date()))
DrawCanvas()
EndProcedure
; ----
Procedure UpdateWindow()
Protected dx, dy
dx = WindowWidth(#Main)
dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
; Resize gadgets
ResizeGadget(#MainCanvas, 5, 5, dx - 10, 30)
DrawCanvas()
EndProcedure
; ----
Procedure Main()
Protected dx, dy
#MainStyle = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 800, 600, #ProgramTitle , #MainStyle)
; Menu
CreateMenu(#MainMenu, WindowID(#Main))
MenuTitle("&File")
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
MenuItem(#PB_Menu_About, "")
CompilerElse
MenuItem(#MainMenuAbout, "About")
CompilerEndIf
; Menu File Items
CompilerIf Not #PB_Compiler_OS = #PB_OS_MacOS
MenuBar()
MenuItem(#MainMenuExit, "E&xit")
CompilerEndIf
; StatusBar
CreateStatusBar(#MainStatusBar, WindowID(#Main))
AddStatusBarField(#PB_Ignore)
; Gadgets
dx = WindowWidth(#Main)
dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
CanvasGadget(#MainCanvas, 5, 5, dx - 10, 30, #PB_Canvas_Border)
; Bind Events
BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), #Main)
BindEvent(#PB_Event_Timer, @DoTimerEvent_1s(), #Main, 1)
; Add Timer
AddWindowTimer(#Main, 1, 1000)
; Event Loop
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Select EventWindow()
Case #Main
Break
EndSelect
Case #PB_Event_Menu
Select EventMenu()
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
Case #PB_Menu_About
PostEvent(#PB_Event_Menu, #Main, #MainMenuAbout)
Case #PB_Menu_Preferences
Case #PB_Menu_Quit
PostEvent(#PB_Event_CloseWindow, #Main, #Null)
CompilerEndIf
Case #MainMenuAbout
MessageRequester("About", #ProgramTitle + #LF$ + #ProgramVersion, #PB_MessageRequester_Info)
Case #MainMenuExit
PostEvent(#PB_Event_CloseWindow, #Main, #Null)
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
EndSelect
ForEver
EndIf
EndProcedure : Main()
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive