Can a panel window be hidden/shown by code

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
bluebird
Posts: 154
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF
Has thanked: 41 times
Been thanked: 7 times

Can a panel window be hidden/shown by code

Post by bluebird » Sat Mar 24, 2018 1:15 am

Dear HMG

I tried to implement a panel window for the first time, wanting to show/hide it by code.
Modifying an old post example, my attempts failed to compile. i have included the
sample code with my attempts at hiding shown within /*....*/

Is it possible to Hide/Show a panel window?

Thanks for looking at my post. More thanks if there is a solution. :? :?
#include "hmg.ch"

FUNCTION main()

p000_Define()
p001_Define()
ACTIVATE WINDOW p001win, p000win
RETURN NIL

/************************************************************
* Main form definition
************************************************************/
STATIC FUNCTION p000_Define()
DEFINE WINDOW p000win ;
AT 0,0 ;
WIDTH 860 ;
HEIGHT 645 ;
TITLE 'Panel tester' ;
WINDOWTYPE MAIN ;
FONTNAME "Arial" FONTSIZE 12

DEFINE MAIN MENU
DEFINE POPUP '&File'
MENUITEM 'e&Xit' ACTION p000win.Release
END POPUP
DEFINE POPUP '&Open Form'
MENUITEM '&Do' ACTION p000_OpenForm()
END POPUP
END MENU

END WINDOW
p000win.Center
RETURN NIL

/************************************************************
* Sub (and panel) form definition
************************************************************/
STATIC FUNCTION p001_Define()
DEFINE WINDOW p001win ;
AT 0,0 ;
WIDTH 700 ;
HEIGHT 525 ;
TITLE 'Sub Form' ;
WINDOWTYPE CHILD ;
NOAUTORELEASE ;
ONINIT p001win.Hide ;
FONTNAME "Arial" FONTSIZE 12

ON Key ALT+C of p001win ACTION {||(win_2.visible:=.F.)} //win_2.HIDE does not work either

DEFINE TOOLBAR toolbar1 ;
BUTTONSIZE 60,30 ;
FONT "Arial" ;
SIZE 10 ;
FLAT ;
BORDER

BUTTON bt_exit ;
CAPTION 'e&Xit' ;
ACTION p001win.Hide ;
SEPARATOR
/*
BUTTON bt_hide ;
CAPTION '&Hide_Panel' ;
ACTION poo1win.win_2.Hide ;
SEPARATOR

BUTTON bt_SHOW ;
CAPTION '&Show_Panel' ;
ACTION Win_2.Hide ;
*/

END TOOLBAR

DEFINE WINDOW Win_2 ;
ROW 80 ;
COL 30 ;
WIDTH 300 ;
HEIGHT 200 ;
VIRTUALWIDTH 400 ;
VIRTUALHEIGHT 400 ;
WINDOWTYPE PANEL

DEFINE LABEL lb_label1
ROW 10
COL 10
VALUE 'Panel window...'
WIDTH 300
END LABEL
END WINDOW

END WINDOW
p001win.Center
RETURN NIL

/************************************************************
* Sub (and panel) form open
************************************************************/
STATIC FUNCTION p000_OpenForm()
p001win.Show
p001win.Setfocus
RETURN NIL

User avatar
andyglezl
Posts: 940
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 16 times
Been thanked: 38 times
Contact:

Post by andyglezl » Sat Mar 24, 2018 5:44 am

Try with this...
DoMethod( "Win_2", "Hide" )


Samples...
HMG\3.4.4\SAMPLES\Controls\Panel
Andrés González López
Desde Guadalajara, Jalisco. México.

bluebird
Posts: 154
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF
Has thanked: 41 times
Been thanked: 7 times

Post by bluebird » Sat Mar 24, 2018 2:57 pm

Thanks , I'll try that idea

Who would have thought of Do Method. I did not notice a close of the panel in the samples though.

User avatar
andyglezl
Posts: 940
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 16 times
Been thanked: 38 times
Contact:

Post by andyglezl » Sat Mar 24, 2018 9:52 pm

Deberìa de funcionar como dice la ayuda de HMG
Quizá la programación este mal.
--------------------------------------------------------------
It should work as the HMG help says
Maybe the programming is wrong.


\HMG\3.4.4\DOC\hmgdoc.htm
Help-HMG.png
Help-HMG.png (158.46 KiB) Viewed 360 times
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
andyglezl
Posts: 940
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 16 times
Been thanked: 38 times
Contact:

Post by andyglezl » Sun Mar 25, 2018 3:30 am

Try this...

Code: Select all

/*
* HMG Embedded Child Window Demo
* (c) 2002-2010 Roberto Lopez <mail.box.hmg@gmail.com>
*/

#include "hmg.ch"

Function Main

	SET SCROLLSTEP TO 10

	DEFINE WINDOW Win_1 ;
		ROW 0 ;
		COL 0 ;
		WIDTH 400 ;
		HEIGHT 400 ;
		TITLE 'HMG Panel Window Demo' ;
		WINDOWTYPE MAIN  


		DEFINE WINDOW Win_2 ;
			ROW 30 ;
			COL 30 ;
			WIDTH 300 ;
			HEIGHT 200 ;
			VIRTUALWIDTH 400 ;
			VIRTUALHEIGHT 400 ;
			WINDOWTYPE PANEL

			DEFINE LABEL LABEL_1
				ROW		10
				COL		10
				VALUE		'Panel windows...'
				WIDTH		300
			END LABEL

			DEFINE BUTTON BUTTON_1
				ROW		40
				COL		10
				CAPTION		'Click Me!'
				ACTION		MsgInfo('Clicked!')
			END BUTTON

			DEFINE LABEL LABEL_2
				ROW		90
				COL		10
				VALUE		"Can do this!"
				WIDTH		300
			END LABEL

			DEFINE TEXTBOX TEXT_1
				ROW		120
				COL		10
				VALUE		'Test'
			END TEXTBOX

			DEFINE TEXTBOX TEXT_2
				ROW		150
				COL		10
				VALUE		'Test'
			END TEXTBOX

			DEFINE TEXTBOX TEXT_3
				ROW		180
				COL		10
				VALUE		'Test'
			END TEXTBOX
	
			DEFINE TEXTBOX TEXT_4
				ROW		210
				COL		10
				VALUE		'Test'
			END TEXTBOX

			DEFINE TEXTBOX TEXT_5
				ROW		240
				COL		10
				VALUE		'Test'
			END TEXTBOX

		END WINDOW


		DEFINE BUTTON BUTTON_1
			ROW		300
			COL		10
			WIDTH		50
			CAPTION		'Hide'
			ACTION		Win_2.Hide
			*ACTION		DoMethod( "Win_2", "Hide" )
		END BUTTON

		DEFINE BUTTON BUTTON_2
			ROW		300
			COL		100
			WIDTH		50
			CAPTION		'Show'
			ACTION		Win_2.Show
			*ACTION		DoMethod( "Win_2", "Show" )
		END BUTTON

	END WINDOW


	Win_1.Center 

	// Panel windows are automatically activated through its parent
	// so, only Win_1 must be activated.

	Activate Window Win_1 

Return
Andrés González López
Desde Guadalajara, Jalisco. México.

Post Reply