Reset the HMG4 environment

Moderator: Rathinagiri

Post Reply
User avatar
concentra
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Reset the HMG4 environment

Post by concentra »

Hi all.
I am playing with converting a huge console application to GUI one program at a time.
To do so, the console application uses the HB WVT pseudo console that calls HMG4 when needed and came back, all in the same EXE.
But to this to work, every time HMG4 is called the HMG4 environment must be resettled while backing to WVT.
To do this, I call this before returning:

Code: Select all

   oWindow:s_qApp:quit()
   oWindow:s_qApp          := NIL
   oWindow:s_qRes          := NIL
   oWindow:s_aResources    := {}
   oWindow:oDefaultParent  := NIL
   oWindow:nObjectCounter  := 0
   oWindow:oMainWindow     := NIL
   oWindow:lGridCellFlag   := .F.
   oWindow := NIL
I implemented a function called HMG4_Reset() in application.prg to do this task this way:

Code: Select all

#include "hbclass.ch"
#include "common.ch"

/*----------------------------------------------------------------------*/

CLASS APPLICATION

   CLASS VAR s_qApp                               INIT   NIL      SHARED

   CLASS VAR s_qRes                               INIT   NIL      SHARED
   CLASS VAR s_aResources                         INIT   {}       SHARED

   CLASS VAR oDefaultParent                       INIT   NIL      SHARED
   CLASS VAR nObjectCounter                       INIT   0        SHARED

   CLASS VAR oMainWindow                          INIT   NIL      SHARED
   CLASS VAR lGridCellFlag                        INIT   .F.      SHARED

   METHOD New

ENDCLASS

/*----------------------------------------------------------------------*/

METHOD New() CLASS APPLICATION

   RETURN Self

/*----------------------------------------------------------------------*/

FUNCTION HMG4_Reset()

   LOCAL oApplication

   oApplication := APPLICATION():New()

   oApplication:s_qApp:quit()
   oApplication:s_qApp          := NIL
   oApplication:s_qRes          := NIL
   oApplication:s_aResources    := {}
   oApplication:oDefaultParent  := NIL
   oApplication:nObjectCounter  := 0
   oApplication:oMainWindow     := NIL
   oApplication:lGridCellFlag   := .F.

   oApplication := NIL

   RETURN NIL
It works.
Is this ok ?
Does anyone have a better idea ?
[[]] Mauricio Ventura Faria
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Reset the HMG4 environment

Post by l3whmg »

Hi Mauricio.
I'm sorry, I don't see this post and your question, before give you my opinion after your build.
My opinion is here viewtopic.php?f=32&t=1995

Best regards
Luigi from Italy
www.L3W.it
Post Reply