Release CHILD window problem

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Release CHILD window problem

Post by esgici »

Hi all

I have a problem while releasing a CHILD window :

Code: Select all

/*
 * HMG - Harbour Win32 GUI library Demo
 *
 * Copyright 2010 Roberto Lopez <mail.box.hmg@gmail.com>
 * http://www.hmgforum.com//
*/

#include "hmg.ch"

PROC Main()
 
	DEFINE WINDOW frmRelChTest;
		AT 0,0 ;
		WIDTH 640 HEIGHT 480 ;
		TITLE 'Release child window test';
		MAIN 
     
    ON KEY ESCAPE ACTION ThisWindow.Release                      

    @ 50,  50 BUTTON btnMake CAPTION "Make a child window"   ACTION MakeAChild()   WIDTH 200 HEIGHT 30      
    @ 50, 300 BUTTON btnTest CAPTION "Release child window"  ACTION ReleaseChild() WIDTH 200 HEIGHT 30 

	END WINDOW   
    
	frmRelChTest.Center()

	frmRelChTest.Activate()

RETU // Main()

*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

PROC MakeAChild()
    
   DEFINE WINDOW frmChild AT 300, 300 ;
       WIDTH 400 ;
       HEIGHT 200 ;
       CHILD ;   
       TITLE "This is a CHILD window"  
   END WINDOW
    
   frmChild.Center 
   frmChild.Activate             

RETU // MakeAChild()

*~~~~~~~~~~~~~~~~~~~~~~~~

PROC ReleaseChild()

   IF IsWindowDefined( frmChild )   
      frmChild.Release
      MsgInfo( "frmChild released." )  // never seen :( 
   ELSE
      MsgStop( "frmChild not defined" )
   ENDIF   
       
RETU // ReleaseChild()

*~~~~~~~~~~~~~~~~~~~~~~~~

After executed frmChild.Release statement, program became unstable ( no responding anything ) only closed via task manager :(

Any idea ?

Viva HMG :D
Viva INTERNATIONAL HMG :D
User avatar
dragancesu
Posts: 920
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: Release CHILD window problem

Post by dragancesu »

main window:

Code: Select all

   
   DEFINE WINDOW Win_1 ;
      AT 20,20 ;
      WIDTH 800 ;
      HEIGHT 700 ;
      TITLE "Form definition" ;
      MAIN ; 
      ON RELEASE close_3228()
      
      @ 580,250 BUTTON PREVIEW_3228 ;
         CAPTION "Preview" ;
         ACTION frm_Preview_3228() ;
         WIDTH 100 ;
         HEIGHT 40       
      

Code: Select all

FUNCTION close_3228()

   if IsWindowActive( FormPrev )
       DoMethod( 'FormPrev', "RELEASE" )
   endif

child window:

Code: Select all

FUNCTION frm_preview_3228 ( )

   if IsWindowActive( FormPrev )
       DoMethod( 'FormPrev', "RELEASE" )
   endif
   
   DEFINE WINDOW FormPrev ;
      AT 20, 100 ;
      WIDTH 1000 ; 
      HEIGHT 800 ;
      TITLE 'Preview Form' ;
      CHILD
      
it's work
User avatar
gfilatov
Posts: 1060
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Release CHILD window problem

Post by gfilatov »

esgici wrote:Hi all

I have a problem while releasing a CHILD window :
...
After executed frmChild.Release statement, program became unstable ( no responding anything ) only closed via task manager :(

Any idea ?
Hi Esgici,

It is an expected problem after the following modification in the function _ReleaseWindow ():
SendMessage( _HMG_SYSDATA [ 67 ] , WM_CLOSE, 0, 0 ) // ADD October 2015

instead of the old code
SendMessage ( _HMG_SYSDATA [ 67 ] , WM_SYSCOMMAND, SC_CLOSE, 0 )

The solution of above problem is a very simple: you should add the DO EVENTS statement after releasing of a Child window for
proper processing of the form's closing.

Hope that helps :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Release CHILD window problem

Post by esgici »

gfilatov wrote: ...
The solution of above problem is a very simple: you should add the DO EVENTS statement after releasing of a Child window for
proper processing of the form's closing.
Hi Grigory

Problem solved, thank you very much :arrow:

Viva HMG :D
Viva INTERNATIONAL HMG :D
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Release CHILD window problem

Post by esgici »

dragancesu wrote: ...
it's work
Hi Dragan

Thank to interest

Your suggested sample is basically same as mine; only difference is MsgInfo() function after DoMethod() calling.

When added a Msgxxx() call, your sample became as mine : problematic.

This is also an interesting point ( a message function hang up program ) :?

So problem solved with DO EVENTS command suggested by Grigory :arrow:

Viva HMG and HMG friendship :D
Viva INTERNATIONAL HMG :D
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Release CHILD window problem

Post by serge_girard »

Thanks !
I once also had this problem, can't remember how I solved it....

Serge
There's nothing you can do that can't be done...
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Release CHILD window problem

Post by srvet_claudio »

gfilatov wrote:
esgici wrote:Hi all

I have a problem while releasing a CHILD window :
...
After executed frmChild.Release statement, program became unstable ( no responding anything ) only closed via task manager :(

Any idea ?
Hi Esgici,

It is an expected problem after the following modification in the function _ReleaseWindow ():
SendMessage( _HMG_SYSDATA [ 67 ] , WM_CLOSE, 0, 0 ) // ADD October 2015

instead of the old code
SendMessage ( _HMG_SYSDATA [ 67 ] , WM_SYSCOMMAND, SC_CLOSE, 0 )

The solution of above problem is a very simple: you should add the DO EVENTS statement after releasing of a Child window for
proper processing of the form's closing.

Hope that helps :idea:

Thanks Grigory,
I will fix
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Release CHILD window problem

Post by andyglezl »

Hola, yo no se si sea lo mismo, pero con ventanas MODAL también pasa igual.
Tengo un .prg compilado con HMG3.15 y funciona bien, lo compilé con HMG3.4 y se
"congela" al momento de dar el WndPidParam.Release.
------------------------------------------------------------------------------------------------------
Hi, I do not know if it is the same, but with windows MODAL also happens alike.
I have compiled a .prg HMG3.15 and works well, and compiled with HMG3.4
"freezes" when giving the WndPidParam.Release.

FUNCTION PideFechas()
LOCAL cSizeFontTB:=12, lCanc:=.F., cSelec, ffecDesd, ffecHast

DEFINE WINDOW WndPidParam AT 0, 0 WIDTH 300 HEIGHT 200 ;
TITLE O2A("Reporte de Cobranza") MODAL NOSIZE NOSYSMENU BACKCOLOR MALVA

DEFINE DATEPICKER T_fecDesd
ROW 25 ; COL 30 ; WIDTH 115 ; HEIGHT 24
VALUE Date()
FONTNAME "Arial" ; FONTSIZE cSizeFontTB
TABSTOP .T. ; VISIBLE .T.
ONCHANGE (WndPidParam.T_fecHast.SetFocus)
END DATEPICKER

DEFINE DATEPICKER T_fecHast
ROW 98 ; COL 30 ; WIDTH 115 ; HEIGHT 24
VALUE Date()
FONTNAME "Arial" ; FONTSIZE cSizeFontTB
TABSTOP .T. ; VISIBLE .T.
ONCHANGE (WndPidParam.btnOk.SetFocus)
END DATEPICKER

@ 045,190 BUTTON btnOk ;
CAPTION "&Aceptar" ;
ACTION {|| lCanc:=.F.,ffecDesd:=WndPidParam.T_fecDesd.Value, ;
ffecHast:=WndPidParam.T_fecHast.Value, ;
WndPidParam.Release } ;
WIDTH 70 HEIGHT 25 FONT "Verdana" SIZE 8

@ 085,190 BUTTON btnCnc ;
CAPTION "&Cancelar" ;
ACTION {|| lCanc:=.T., WndPidParam.Release } ;
WIDTH 70 HEIGHT 25 FONT "Verdana" SIZE 8

END WINDOW
CENTER WINDOW wndPidParam
ACTIVATE WINDOW wndPidParam
RETURN( { lCanc, ffecDesd, ffecHast } )
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Release CHILD window problem

Post by andyglezl »

Si oprimo 2 veces cualquiera de los botones, entonces se cancela...
--------------------------------------------------------------------------------
If I press 2 times either of the buttons, then canceled ...
Release WIN MODAL.jpg
Release WIN MODAL.jpg (134.72 KiB) Viewed 5045 times
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Release CHILD window problem

Post by srvet_claudio »

I fixed.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
Post Reply