Page 1 of 1

Current control name - how to get this information?

Posted: Fri Mar 23, 2012 6:23 pm
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

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

Posted: Fri Mar 23, 2012 6:36 pm
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 :!:

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

Posted: Fri Mar 23, 2012 6:36 pm
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.


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

Posted: Fri Mar 23, 2012 6:49 pm
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

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

Posted: Fri Mar 23, 2012 7:51 pm
by Rathinagiri
Yes. Perhaps it doesn't work on 'On Key'.

Thanks a lot Grigory.