WINDOW RELEASE

HMG en Español

Moderator: Rathinagiri

User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

WINDOW RELEASE

Post by SALINETAS24 »

Hola a todos..., sigo haciendo pruebas.
Tengo un programa que llama a una función que define una WINDOW y dentro de esta WINDOW define otra WINDOW.
El programa activa la primera, y que la segunda se activará dependiendo de la opciones que introduzca el usuario.

(Si.., ya que que puedo llamar a una función y activarla fuera de esa WIN, pero como he indicado al principio estoy de pruebas.) :P

El caso es que aparentemente funciona, pero tengo un problema y es que cuando abandono sin llegar a activar la WIN_2, salgo haciendo un "release" sobre la WIN_1. Si a continuación quiero volver a entrar me da un error y me dice que la WIN_2 ya esta definida...., y digo yo.., al abandonar la WIN_1 o WIN_pricipal NO SE DEBERIAN TAMBIEN ELIMINAR DE LA MEMORIA EL RESTO DE OBJETOS QUE DEPENDEN DE ESTA.
Acaso la 2 WIN no la tengo que declarar MODAL...?

Si salgo sin llegar a activar la WIN_2 y hago un release sobre esta ultima me da error el programa, me dice que no fue activada.

Lo que más me preocupa es porque se queda definida la 2ª WIN.., ocupando memoria.., es esto estable..?
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: WINDOW RELEASE

Post by andyglezl »

Porqué no posteas tu prg de prueba ???

Porque una cosa es "platicarlo" y otra verlo como es exactamente.

Cada persona que lea este post interpretará a su modo lo que quieres decir,
y lo que te sugieran será en base a eso.
Sin embargo, si posteas el prg todos sabrán a lo que te estas refiriendo.
-----------------------------------------------------------------------------------------------
Why do not you post your test prg ???

Because one thing is to "talk" and another to see it exactly as it is.

Each person who reads this post will interpret in your own way what you want to say,
and what you suggest will be based on that.
However, if you post the prg they will all know what you are referring to.
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Re: WINDOW RELEASE

Post by hmgchang »

Hello everyone ..., I'm still doing tests.
I have a program that calls a function that defines a WINDOW and within this WINDOW defines another WINDOW.
The program activates the first, and the second will be activated depending on the options that the user enters.

(Yes ..., since I can call a function and activate it outside of that WIN, but as I indicated at the beginning I'm testing.) 

The case is that apparently it works, but I have a problem and is that when I leave without activating the WIN_2, I leave doing a "release" on the WIN_1. If I want to go back in, I get an error and it tells me that the WIN_2 is already defined ..., and I say ..., when leaving the WIN_1 or WIN_pricipal THE REST OF OBJECTS THAT SHOULD NOT BE REMOVED FROM THE MEMORY SHOULD ALSO BE REMOVED DEPEND ON THIS.
Maybe 2 WIN do not have to declare MODAL ...?

If I leave without activating WIN_2 and I make a release on this last one, the program gives me an error, it tells me that it was not activated.

What worries me the most is because the 2nd WIN remains defined, occupying memory .., is this stable ..?
Just Hmg It !
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: WINDOW RELEASE

Post by mustafa »

Hola amigo SALINETAS24
No se si este sample puede servir ?
Como dicen los compañeros mejor que cuelgues el Prg que te está dando problemas
Encontre en la Web ---> https://es.groups.yahoo.com/neo/groups/ ... pics/29821
no se si puede servir para este tema ?

Code: Select all


#include "hmg.ch"  

DECLARE WINDOW Win_1 
DECLARE WINDOW Win_2

PROC Main()
   
   DEFINE WINDOW Form_1                ; 
      AT     0,0                       ;
      WIDTH  775                       ;
      HEIGHT 600                       ;
      TITLE  "Window Abiertos"         ;
      MAIN  NOMAXIMIZE   NOSIZE             

      ON KEY ESCAPE ACTION Form_1.Release

      DEFINE TIMER Timer_1 INTERVAL 1000  ACTION (RELEASE MEMORY)

    @ 240,250 LABEL Label_02  WIDTH  350   VALUE "Window Abiertos" FONT "Arial" SIZE 20 BOLD ITALIC
       
    DEFINE BUTTON Web1
         ROW    440
         COL    101
         WIDTH  090  
         HEIGHT 030
         CAPTION SPACE(5)-"Win_01" 
         TOOLTIP ""           
         ACTION  Window_01()
      END BUTTON   
 
      DEFINE BUTTON Web
         ROW    440
         COL    301 
         WIDTH  090  
         HEIGHT 030
         CAPTION SPACE(5)-"Win_02" 
         TOOLTIP ""           
         ACTION  Window_02()
      END BUTTON   

      DEFINE BUTTON But_Exit
         ROW    440
         COL    501  
         WIDTH  090  
         HEIGHT 030
         CAPTION SPACE(5)-"&Exit" 
         TOOLTIP "Exit"           
         ACTION Form_1.Release
      END BUTTON   

  END WINDOW
 
   Form_1.Center
   Form_1.Activate 

RETU

*---------------------------------*
 Function Window_01()
*---------------------------------*

   IF IsWindowDefined( Win_1 ) 
       msgStop(  SPACE(3)+"Window is in Use -> Win_1","Attention !!!" )
       RETURN NIL
   ENDIF 

     DEFINE WINDOW Win_1     ;
            AT 0,0           ;
            WIDTH 500        ;
            HEIGHT 300       ; 
            TITLE "Ventana 1 Child";
            CHILD  NOSIZE NOMAXIMIZE
        
            ON KEY ESCAPE ACTION Win_1.Release

   @ 100,100 LABEL Label_03  WIDTH  350   VALUE "Window Win_1 Child" FONT "Arial" SIZE 20 BOLD ITALIC

      DEFINE BUTTON But_Exit_1
         ROW    200
         COL    301  
         WIDTH  090  
         HEIGHT 030
         CAPTION SPACE(5)-"&Exit" 
         TOOLTIP "Exit"           
         ACTION Win_1.Release
      END BUTTON   
 
     END WINDOW
     
   Win_1.Center
   Win_1.Activate 

Return .T.

*---------------------------------*
 Function Window_02()
*---------------------------------*
   
   IF IsWindowDefined( Win_2 ) 
       msgStop( SPACE(3)+"Window is in Use -> Win_2","Attention !!!" )
       RETURN NIL
   ENDIF 

       DEFINE WINDOW Win_2   ;
              AT 0,0         ;
              WIDTH  500     ; 
              HEIGHT 300     ;  
              TITLE "Ventana 2 Child";
              ICON "Logo"    ;    
              CHILD  NOSIZE NOMAXIMIZE      
              ON KEY ESCAPE ACTION Win_2.Release

     @ 100,100 LABEL Label_04  WIDTH  350   VALUE "Window Win_2 Child" FONT "Arial" SIZE 20 BOLD ITALIC

      DEFINE BUTTON But_Exit_2
         ROW    200
         COL    301  
         WIDTH  090  
         HEIGHT 030
         CAPTION SPACE(5)-"&Exit" 
         TOOLTIP "Exit"           
         ACTION Win_2.Release
      END BUTTON   
 
     END WINDOW
     
   Win_2.Center
   Win_2.Activate 


Return .T.

Saludos /Regars
Mustafa :idea: :lol:
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: WINDOW RELEASE

Post by SALINETAS24 »

Hola, y muchas gracias. Teneís razón. Debería de haber puesto un ejemplo.
En este caso me aprovecho del que ha puesto el amigo Mustafa, lo modifico y aquí lo tenéis. Esta tal cual lo tengo (mas o menos),el problema si entras en la "WIN_1" y sales e intentas volver a entrar en la WIN_1 da error.

Code: Select all


#include "hmg.ch"  

PROC Main()
   
   DEFINE WINDOW Form_1                ; 
      AT     0,0                       ;
      WIDTH  775                       ;
      HEIGHT 600                       ;
      TITLE  "Window Abiertos"         ;
      MAIN  NOMAXIMIZE   NOSIZE             

      ON KEY ESCAPE ACTION Form_1.Release

      DEFINE TIMER Timer_1 INTERVAL 1000  ACTION (RELEASE MEMORY)

    @ 240,250 LABEL Label_02  WIDTH  350   VALUE "Window Abiertos" FONT "Arial" SIZE 20 BOLD ITALIC
       
		DEFINE BUTTON Web1
			ROW    440
			COL    101
			WIDTH  090  
			HEIGHT 030
			CAPTION SPACE(5)-"Win_01" 
			TOOLTIP ""           
			ACTION  Window_01()
		END BUTTON   
 
		DEFINE BUTTON But_Exit
			ROW    440
			COL    501  
			WIDTH  090  
			HEIGHT 030
			CAPTION SPACE(5)-"&Exit" 
			TOOLTIP "Exit"           
			ACTION Form_1.Release
		END BUTTON   

  END WINDOW
 
   Form_1.Center
   Form_1.Activate 

RETURN

*---------------------------------*
 Function Window_01()
*---------------------------------*
LOCAL aField1, aField2:=""

     DEFINE WINDOW Win_1     ;
            AT 0,0           ;
            WIDTH 500        ;
            HEIGHT 300       ; 
            TITLE "Ventana 1 Child";
            MODAL 
			
        
            ON KEY ESCAPE ACTION Win_1.Release

			@ 100,100 LABEL Label_03  WIDTH  350   VALUE "Window Win_1 Child" FONT "Arial" SIZE 20 BOLD ITALIC 
			@ 120,100 TEXTBOX GET_1 WIDTH 85 VALUE aField1 MAXLENGTH 10 ;
				      ON ENTER Window_02()

			DEFINE WINDOW Win_2   ;
              AT 0,0         ;
              WIDTH  500     ; 
              HEIGHT 300     ;  
              TITLE "Ventana 2 ";
              MODAL
			  
              ON KEY ESCAPE ACTION Win_2.Release
		
				@ 100,100 LABEL Label_04  WIDTH  350   VALUE "Window Win_2 Child" FONT "Arial" SIZE 20 BOLD ITALIC
				@ 120,100 TEXTBOX GET_2 WIDTH 85 VALUE aField2 MAXLENGTH 10 ;
				      ON ENTER Win_2.Release
					  
				DEFINE BUTTON But_Exit_1
					ROW    200
					COL    301  
					WIDTH  090  
					HEIGHT 030
					CAPTION SPACE(5)-"&Exit" 
					TOOLTIP "Exit"           
					ACTION Win_2.Release
				END BUTTON   
			END WINDOW
			
     END WINDOW
     
   Win_1.Center
   Win_1.Activate 

Return .T.

*---------------------------------*
 Function Window_02()
*---------------------------------*
 
  		CENTER WINDOW Win_2
		ACTIVATE WINDOW Win_2

Return .T.

Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: WINDOW RELEASE

Post by andyglezl »

No se que es lo que quieres hacer, pero de esta forma funciona...
---------------------------------------------------------------------------------
I do not know what you want to do, but this way it works ...

Code: Select all

#include "hmg.ch"  

PROC Main()
   
   DEFINE WINDOW Form_1                ; 
      AT     0,0                       ;
      WIDTH  775                       ;
      HEIGHT 600                       ;
      TITLE  "Window Abiertos"         ;
      MAIN  NOMAXIMIZE   NOSIZE             

      ON KEY ESCAPE ACTION Form_1.Release

      DEFINE TIMER Timer_1 INTERVAL 1000  ACTION (RELEASE MEMORY)

    @ 240,250 LABEL Label_02  WIDTH  350   VALUE "Window Abiertos" FONT "Arial" SIZE 20 BOLD ITALIC
       
		DEFINE BUTTON Web1
			ROW    440
			COL    101
			WIDTH  090  
			HEIGHT 030
			CAPTION SPACE(5)-"Win_01" 
			TOOLTIP ""           
			ACTION  Window_01()
		END BUTTON   
 
		DEFINE BUTTON But_Exit
			ROW    440
			COL    501  
			WIDTH  090  
			HEIGHT 030
			CAPTION SPACE(5)-"&Exit" 
			TOOLTIP "Exit"           
			ACTION Form_1.Release
		END BUTTON   

  END WINDOW
 
   Form_1.Center
   Form_1.Activate 

RETURN

*---------------------------------*
 Function Window_01()
*---------------------------------*
LOCAL aField1, aField2:=""

     DEFINE WINDOW Win_1     ;
            AT 0,0           ;
            WIDTH 500        ;
            HEIGHT 300       ; 
            TITLE "Ventana 1 Child";
            MODAL 
			
        
            ON KEY ESCAPE ACTION Win_1.Release

			@ 100,100 LABEL Label_03  WIDTH  350   VALUE "Window Win_1 Child" FONT "Arial" SIZE 20 BOLD ITALIC 
			@ 120,100 TEXTBOX GET_1 WIDTH 85 VALUE aField1 MAXLENGTH 10 ;
				      ON ENTER Window_02()

*		DEFINE WINDOW Win_2   ;
*              AT 0,0         ;
*              WIDTH  500     ; 
*              HEIGHT 300     ;  
*              TITLE "Ventana 2 ";
*              MODAL
*			  
*              ON KEY ESCAPE ACTION Win_2.Release
		
				@ 100,100 LABEL Label_04  WIDTH  350   VALUE "Window Win_2 Child" FONT "Arial" SIZE 20 BOLD ITALIC
				@ 120,100 TEXTBOX GET_2 WIDTH 85 VALUE aField2 MAXLENGTH 10 //;
				      //ON ENTER Win_2.Release
					  
				DEFINE BUTTON But_Exit_1
					ROW    200
					COL    301  
					WIDTH  090  
					HEIGHT 030
					CAPTION SPACE(5)-"&Exit" 
					TOOLTIP "Exit"           
					ACTION Win_1.Release
					*ACTION Win_2.Release
				END BUTTON   
*			END WINDOW
			
     END WINDOW
     
   Win_1.Center
   Win_1.Activate 

Return .T.

*---------------------------------*
 Function Window_02()
*---------------------------------*
 
	DEFINE WINDOW Win_2   ;
              AT 110,110         ;
              WIDTH  500     ; 
              HEIGHT 300     ;  
              TITLE "Ventana 2 ";
              MODAL
			  
              ON KEY ESCAPE ACTION Win_2.Release 
	    @ 100,100 LABEL Label_03  WIDTH  350   VALUE "Window Win_3 Child" FONT "Arial" SIZE 20 BOLD ITALIC

	END WINDOW
	*CENTER WINDOW Win_2
	ACTIVATE WINDOW Win_2

Return .T.
windemo.png
windemo.png (15.69 KiB) Viewed 3763 times
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: WINDOW RELEASE

Post by SALINETAS24 »

Hola Andy y gracias. Tengo claro (lo puse en el primer mensaje) que si llamo a una funcion no hay problema. Pero necesito tener una ventana dentro de otra... , pruebas que estoy haciendo.., y he detectado que cuando cierra las ventana no todos los controles, objetos se borran....
La cuestion es...
Es posible declarar una ventana dentro de una ventana..?
Acaso es un bugs y que cuando se hace un release no elimina totalmente todos los objetos dependientes de esa ventana que acabamos de cerrar..?
O es que en el ejemplo que yo he puesto las ventanas dependientes hay que declararla de otra forma...?
Gracias..
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: WINDOW RELEASE

Post by andyglezl »

Algo simple y rápido, si analizas la situación, cuando tienes un error
o es problema de sintaxis o es problema de no adecuada programación.

Si defines una ventana y controles que no sabes si la vas a utilzar,
estás consumiendo recursos.

Lo adecuado sería que hasta el momento en que te oprimen el boton indicado,
definas la ventana y los controles necesarios y activarla, que a su vez al momento
de cerrar dicha ventana se libera lo que creaste. ( y no tendrías que estar checando
cada x tiempo para que libere la memoria).

En mi caso particular, cuando yo hago pruebas, las hago en base a algo
que ya está hecho siguiendo esa misma estructura y me refiero a los
ejemplos que trae HMG, porque ya alguien le dedicó tiempo a hacerlos
y a probarlos. ( y gracias por ello )

Claro que hay sus excepciones, pero creo que es parte de la tarea que
nos corresponde al foro, probar y reportar si dicha forma no funciona.

Todo es factible de mejorar y con el tiempo, aprendes a hacer las cosas
de diferente manera y más adecuado a tus necesidades.

(Aclarando que es solo mi opinión)
-----------------------------------------------------------------------------------------------
Something simple and fast, if you analyze the situation, when you have an error
It is a syntax problem or it is a problem of inadequate programming.

If you define a window and controls that you do not know if you are going to use it,
You are consuming resources.

The appropriate thing would be that until the moment you press the indicated button,
define the window and the necessary controls and activate it, which in turn to the moment
closing that window releases what you created. (and you should not be checking
every x time to release the memory).

In my particular case, when I do tests, I do them based on something
that is already done following that same structure and I refer to the
examples that HMG brings, because someone already dedicated time to make them
and to try them. (and thanks for that)

Of course there are exceptions, but I think it's part of the task that
It is up to the forum to test and report if this form does not work.

Everything is feasible to improve and over time, you learn to do things
in a different way and more suited to your needs.

(Clarifying that it is only my opinion)
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: WINDOW RELEASE

Post by SALINETAS24 »

Hola Andy y gracias.
Respecto a lo que dices ...
Algo simple y rápido, si analizas la situación, cuando tienes un error
o es problema de sintaxis o es problema de no adecuada programación.
En este caso estoy en desacuerdo contigo. Está claro que en ocasiones tenemos que cambiar la forma de pensar, pero lo que nos ocupa es la declaración de un ERROR, de un BUG que OBLIGA a tener que REPLANTEAR la solución, pero no por un error de Análisis de planteamiento ni de quebrantamiento del flujo del programa, es porque la salida de un RELEASE no elimina totalmente los objetos que cuelgan de la VENTANA.., y no hay nada más.

De esto deben tomar nota los magníficos diseñadores de la HMG y ver la posibilidad de implementarlo en la próxima revisión. No obstante y hasta llegado ese momento y por si alguien esta intentado hacer multiventanas heredando clases y se ha encontrado con los mismos problemas he encontrado estas funciones que permitirán un correcto funcionamiento.

IsControlDefined - ISWINDOWACTIVE

Ahora no tengo tiempo, pero a la que pueda modifico el ejemplo y lo pongo.
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
Post Reply