Current control name - how to get this information?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Current control name - how to get this information?

Post by mol »

Hi!
I want to define hotkey eg. F6 which will realize different functions upon the control which has focus currently.

Is it possible to determine, which control has focus now?

I can't find such a information...

Marek
User avatar
gfilatov
Posts: 1116
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Current control name - how to get this information?

Post by gfilatov »

mol wrote:Hi!
I want to define hotkey eg. F6 which will realize different functions upon the control which has focus currently.

Is it possible to determine, which control has focus now?

I can't find such a information...
Hi Marek,

Please try the following simple sample from the HMG distribution:

Code: Select all

/*
 * HMG - Harbour Win32 GUI library Demo
 *
 * Copyright 2002 Roberto Lopez <mail.box.hmg@gmail.com>
 * http://sites.google.com/site/hmgweb/
*/

#include "hmg.ch"

Function Main

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

		ON KEY F2 ACTION MsgInfo ( ThisWindow.FocusedControl )

		@ 10,10 TEXTBOX Text_1 
		@ 50,10 TEXTBOX Text_2 
		@ 90,10 TEXTBOX Text_3 


	END WINDOW

	Form_1.Center

	Form_1.Activate

Return Nil
Hope that useful :!:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Current control name - how to get this information?

Post by Rathinagiri »

Hi Marek,

Why don't you use 'this'?

From HMG Reference:

Code: Select all

 

      This.<Property/MethodName>

 

It provides a reference to the current control/window in event code.

East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Current control name - how to get this information?

Post by mol »

gfilatov wrote:
mol wrote:Hi!
I want to define hotkey eg. F6 which will realize different functions upon the control which has focus currently.

Is it possible to determine, which control has focus now?

I can't find such a information...
Hi Marek,

Please try the following simple sample from the HMG distribution:

Code: Select all

/*
 * HMG - Harbour Win32 GUI library Demo
 *
 * Copyright 2002 Roberto Lopez <mail.box.hmg@gmail.com>
 * http://sites.google.com/site/hmgweb/
*/

#include "hmg.ch"

Function Main

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

		ON KEY F2 ACTION MsgInfo ( ThisWindow.FocusedControl )

		@ 10,10 TEXTBOX Text_1 
		@ 50,10 TEXTBOX Text_2 
		@ 90,10 TEXTBOX Text_3 


	END WINDOW

	Form_1.Center

	Form_1.Activate

Return Nil
Hope that useful :!:
It really works!!!
Thanks for your quick responce.
You are BIG, Grigori :D
rathinagiri wrote:Hi Marek,

Why don't you use 'this'?

From HMG Reference:

Code: Select all

 

      This.<Property/MethodName>

 

It provides a reference to the current control/window in event code.

I've tried this way, but it doesn't want to work and generate runtime error:

Code: Select all

Control: Of OknoSystem Not defined. Program Terminated
(empty control name...)

Best regards, Marek
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Current control name - how to get this information?

Post by Rathinagiri »

Yes. Perhaps it doesn't work on 'On Key'.

Thanks a lot Grigory.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply