label at runtime

Moderator: Rathinagiri

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

Re: label at runtime

Post by mol » Fri Oct 20, 2017 9:02 am

It does not work :-(

edk
Posts: 171
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 50 times
Been thanked: 99 times

Post by edk » Fri Oct 20, 2017 11:00 am

Here is working demo ;)

Code: Select all

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

#include "hmg.ch"

Function Main
Local aRows [20] [3]

	aRows [1]	:= {'Simpson','Homer','555-5555'}
	aRows [2]	:= {'Mulder','Fox','324-6432'} 
	aRows [3]	:= {'Smart','Max','432-5892'} 
	aRows [4]	:= {'Grillo','Pepe','894-2332'} 
	aRows [5]	:= {'Kirk','James','346-9873'} 

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 640 HEIGHT 480 ;
		TITLE 'HMG Demo' ;
		MAIN 

		DEFINE TAB Tab_1 ;
			AT 10,10 ;
			WIDTH 600 ;
			HEIGHT 400 ;
			VALUE 1 ;
			TOOLTIP 'Tab Control' 

			PAGE 'Page 1' 

			      @ 100,250 BUTTON Button_1 CAPTION "Add Label On Page 4" WIDTH 150 HEIGHT 50 ACTION Make_label()
			      @ 180,250 BUTTON Button_2 CAPTION "Release Label On Page 4" WIDTH 150 HEIGHT 50 ACTION IF (IsControlDefined (NewLabel2 , Form_1) , DoMethod('Form_1','NewLabel2','Release') , Nil )
			      
			END PAGE

			PAGE 'Page &2' 

				DEFINE RADIOGROUP R1
					ROW	100
					COL	100
					OPTIONS	{ '1','2','3' }
					VALUE	1
				END RADIOGROUP
				
			END PAGE

			PAGE 'Page 3' 

				@ 100,250 SPINNER Spinner_1 ;
				RANGE 0,10 ;
				VALUE 5 ;
				WIDTH 100 ;
				TOOLTIP 'Range 0,10' ; 
				ON CHANGE PlayBeep() 

			END PAGE

			PAGE 'Page 4' 

				@ 50,50 GRID Grid_1 ;
					WIDTH 200 ;
					HEIGHT 330 ;
					HEADERS {'Last Name','First Name','Phone'} ;
					WIDTHS {140,140,140};
					ITEMS aRows ;
					VALUE 1 

			END PAGE

		END TAB


	END WINDOW

	Form_1.Center

	Form_1.Activate

Return Nil


***********************
FUNCTION Make_label()
 define label NewLabel2
			parent Form_1
			row 150
			col 300
			backColor {96,96,96}
			value "BAR"
			height 80
			width  30
end label
//_AddTabControl ( TabName , ControlName , ParentForm , PageNumber , Row , Col )
_AddTabControl ( 'Tab_1' , 'NewLabel2' , 'Form_1' , 4 , 150 , 300 )
RETURN


User avatar
Rathinagiri
Posts: 5173
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 136 times
Been thanked: 131 times
Contact:

Post by Rathinagiri » Fri Oct 20, 2017 11:03 am

It is very simple.

First define the control having the parent as the same window where the tab resides.

Then use the following method to add the control the the tab page.

Code: Select all

<WindowName>.<ControlName>.AddControl ( ControlName , nPagenumber , nRow , nCol )
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

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

Post by mol » Fri Oct 20, 2017 11:24 am

Thanks guys!

Post Reply