BMaxNG launching program twice?

Started by TwoCatsYelling, December 21, 2021, 02:20:02

Previous topic - Next topic

TwoCatsYelling

Hello,

So, while learning and testing out code stuff, I'm noticing that BMax runs the program twice. It runs, I press Esc to close it, and it runs a second time.

Any idea why this might happen? Is it a common thing, or am I just lucky enough to have found a rare bird?

Thanks!

Pebender


Pebender

if you close a window or you make something, there will be a event...
the code below creates a window, windowslike and you can close it with pressing the cross, nothing will happend twice.

SuperStrict

Import MaxGui.Drivers

Local Window1:TGadget = CreateWindow("Window1",597,250,501,266,Null,WINDOW_TITLEBAR|WINDOW_RESIZABLE |WINDOW_STATUS |WINDOW_CLIENTCOORDS )

Repeat
WaitEvent()
Select EventID()
Case EVENT_WINDOWCLOSE
Select EventSource()
Case Window1 Window1_WC( Window1 )
End Select

End Select
Forever

Function Window1_WC( Window:TGadget )
DebugLog "Window Window1 wants to be closed"
End
End Function


the programm do nothing, but if you press the cross to close the windows, there is the event  EVENT_WINDOWCLOSE this will be call the Function .....Function Window1_WC( Window:TGadget )

in this functons ist the code to close the window......


Midimaster

#3
We need to know, whether you run your app as a MaxGui-App or a "normal" BlitzMax-App. Pebender showed you a example for a Maxgui-App.

Normally you need only this standard-code. This has 3 phases: "before", "during" and "after" the main loop:

Code (BlitzMax) Select
SuperStrict
Graphics 800,600

   ' code here runs once before the main loop
'
Repeat
    Cls
       ' code here runs 60 times per second
    Flip
Until KeyHit (KEY_ESCAPE)
'
   'code here runs once shortly before the app stops
End



Here is an example:
Code (BlitzMax) Select
SuperStrict
Graphics 800,600
   ' code here runs once before the main loop
Global x:Int=10, y:Int=300
'
Repeat
    Cls
       ' code here runs 60 times per second
    x=x+1
    DrawCircle x,y,10,10
    Flip
Until KeyHit (KEY_ESCAPE)
'
   'code here runs once shortly before the app stops
Print " the circle endet a position x=" + x
End

...back from North Pole.

TwoCatsYelling

Quote from: Pebender on December 21, 2021, 07:12:15
can you show the code??

I'd coded it at work (it's been super dead at work this week heh) as part of a small 'challenge project' so I didn't keep it.
I can't get it to happen again now.

But all I was doing was basically:

Graphics,800,600,0

While Not KeyHit(Key_Esc)
Cls

---- a bunch of rectangles drawn at different locations, in different colors ----

Flip
Wend

It was literally just that.

If it happens again, I'll capture the code and paste it here. But for now, I can't get it to happen again.

Actually, something occurred to me while typing this.
I think it's an anti-virus thing. I've used an anti-virus in the past (Avast) where the program will run, but then be shut down 'cause Avast captures it to scan it. Then, once it's cleared, it starts again. I wonder if that's why. We use Avast for business at my job. I use MalwareBytes at home, and it's not happening here.

So it could very well have nothing to do with the code at all.