Mixed-Mode: Continue console after gui-window is released

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
raumi75
Posts: 135
Joined: Wed Dec 17, 2008 2:31 am
Location: Lünen, Germany
Contact:

Mixed-Mode: Continue console after gui-window is released

Post by raumi75 » Tue Dec 23, 2008 11:05 am

Hello,

right now, I am trying to improve some very old clipper-code. The program runs as a console-Application and I plan to rewrite it into using HMG step by step. I am very excited, about all the new possibilities we have with hmg!

Now to my problem: From within my old console-application, I can launch a window, but when it is released, the program does not continue.

Here is a sample to demonstrate:

Code: Select all

#include <minigui.ch>

procedure main
   ? "Hello world"
   gui_function()
   ? "Welcome back!"
   wait(10)
return

function gui_function()
   Load Window window1 as main
   Main.Center
   main.activate
return
I would expect the program to continue running, after the Main-Window is closed and released. Instead it aborts and the Line

Code: Select all

? "Welcome back!"
never gets executed.

What am I doing wrong?

Thanks for helping an eager hmg newbee.

Jan

User avatar
mol
Posts: 3069
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 179 times
Been thanked: 96 times
Contact:

Post by mol » Tue Dec 23, 2008 12:00 pm

In my opinion, closing window, which is activated as main terminates program.
Try to define other main window and keep it hidden and then load your window as MODAL.
On the end of your program, release main window.

I think, it should work.

Best regards, Marek

User avatar
esgici
Posts: 4471
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 351 times
Been thanked: 104 times
Contact:

Post by esgici » Tue Dec 23, 2008 12:18 pm

Hello Jan, Welcome aboard :)
raumi75 wrote:Hello,

... I plan to rewrite it into using HMG step by step.
IMHO this is the best way. Begin with huge scenarios will be quickly painful.
I am very excited, about all the new possibilities we have with hmg!
You aren't alone; personally, after years I am excited as first days !

This is HMG power :)
Now to my problem: From within my old console-application, I can launch a window, but when it is released, the program does not continue.

I would expect the program to continue running, after the Main-Window is closed and released. Instead it aborts ...

What am I doing wrong?
Your expectation is right true by non-Window programming viewpoint. But in Windows some concepts comes different.

Your program is in mixed mode, no console only. If you have a MAIN window/form and when you ACTIVATE it, control of program passes to this window/form and main loop begins. All other events becomes fact within this loop. So, when main window/form released, the main loop and the program ends; whatever you have after ACTIVATE command goes away. There isn't any way to execute them. This isn't "abort", but normal program termination.

Happy HMG'ing :)

Regards

--

esgici
Viva INTERNATIONAL HMG :D

User avatar
raumi75
Posts: 135
Joined: Wed Dec 17, 2008 2:31 am
Location: Lünen, Germany
Contact:

Post by raumi75 » Tue Dec 23, 2008 3:01 pm

mol wrote:Try to define other main window and keep it hidden and then load your window as MODAL.
On the end of your program, release main window.
Thank you Marek, I tried it and it works great. This will make the gradual transition a lot easier.

I rewrote my sample. It now does what I want.

Code: Select all

#include <minigui.ch>

procedure main
   Load Window dummy as main && is an invisble main window, that calls dummy_onInit()
   main.Activate
return

function dummy_onInit()
   * Console-Part
   ? "Hello world"
   gui_function() && Calls the visible window
   * After the user closes the window, the console-part will continue
   ? "Welcome back!"
   ? "Program will terminate in 5 seconds"
   inkey(5)
   main.release
return

function gui_function()
   Load Window window1 && is a MODAL window
   window1.Center
   window1.activate
return
This is going to be a great christmas-time ;-)

Jan

Post Reply