Topic: Handling multiple window

Friendly greetings !

Using appgraphic, on windows 10 :
I have 2 windows ("main_screen" and "printer_screen") created with initwindow on startup. One with closeflag TRUE and the other one FALSE.
When i close any of them, the whole program close.

Is this supposed to happens ?

My main is really simple :

CALL initsomestuff()
CALL initsomeotherstuff()
CALL loop()
CALL closewindow(main_screen)
END PROGRAM

Thank you

Re: Handling multiple window

When any window is closed in AppGraphics, it also triggers a call to stopidle.  I don't believe the documentation explicitly outlines this, but it is indeed true.  In your program, when you close either window, the program will exit the loop call immediately.

I do see a problem with this configuration, though.  AppGraphics maybe does require a more explicit way of determining the event that caused stopidle to be called.

Jeff Armstrong
Approximatrix, LLC

Re: Handling multiple window

Do you have any workaround idea for this ?
and i don't understand the purpose of the closeflag if it's not for this exact problem hmm

thank you smile

Re: Handling multiple window

You can reliably count on closeflag to end the program if set to .TRUE..  So in your case, I would rewrite the program as:

CALL initsomestuff()
CALL initsomeotherstuff()
DO WHILE(.TRUE.)
    CALL loop()
    CALL setcurrentwindow(main_screen)
END DO
CALL closewindow(main_screen)
END PROGRAM

The above assumes that, after closing a secondary window, you always want main_screen to be the current window.

What AppGraphics really should have is the option for a callback when a window is closed so that your code can handle anything it might need to do like set a different window as current or possibly end the program more gracefully than what closeflag allows.

Jeff Armstrong
Approximatrix, LLC

Re: Handling multiple window

Thank you ! I'll work with that smile