How to get Active Object in MDI app

How to get Active Object in MDI app

Postby fraxzi » Thu Jul 08, 2010 7:53 am

Dear All,

How can I get/know active object (focused object) without going through an active dialog/window..
Is this possible?


Regards,
Frances
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: How to get Active Object in MDI app

Postby frose » Thu Jul 08, 2010 12:58 pm

Frances,

Code: Select all  Expand view
oWndActiveChild := WndMain():oWndClient:getActive()

HTH
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: How to get Active Object in MDI app

Postby fraxzi » Fri Jul 09, 2010 12:08 am

Dear Mr. Frank,

Thank you for the reply.

I already tried that approach but it returns only the active window..

I'm looking for the active object with the current focus of the active window or dialog.


I tried WndMain():oWndActive:oCtlFocus.. If I have TFolder active, it returns the object but not the active object (e.g. xbrowse) of the TFolder..
It's a work around for now..


Regards,
Frances
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: How to get Active Object in MDI app

Postby Antonio Linares » Fri Jul 09, 2010 5:37 am

Frances,

Try with:

oWndFromHwnd( GetFocus() )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to get Active Object in MDI app

Postby fraxzi » Fri Jul 09, 2010 1:04 pm

Antonio Linares wrote:Frances,

Try with:

oWndFromHwnd( GetFocus() )



Dear Mr. Antonio,

Thanks for the reply..

It returns NIL on active dialog..

Maybe an active child window can be determine.. how about an active dialog? and an active object of that dialog?..


Regards,
Frances
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: How to get Active Object in MDI app

Postby Antonio Linares » Fri Jul 09, 2010 4:56 pm

Frances,

Please run this:

MsgInfo( GetClassName( GetFocus() ) )

and let me know what you get
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to get Active Object in MDI app

Postby Antonio Linares » Fri Jul 09, 2010 5:04 pm

Frances,

For a dialog you have to use:

oDlgFromHwnd( GetFocus() )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to get Active Object in MDI app

Postby nageswaragunupudi » Fri Jul 09, 2010 9:15 pm

Mr. Antonio

Can this modification be done in control.prg?
Code: Select all  Expand view

static oCtrlFocus
...
...
...
method GotFocus() CLASS TControl
...
..
// after ::oWnd:oCtrlFocus := Self
// Insert this line
oCtrlFocus := Self
...
...
// at the end of the module
function CtrlFocus()
return oCtrlFocus

 


Mr. Frances,
Can you test by making this change and see if you get the right result?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10628
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: How to get Active Object in MDI app

Postby fraxzi » Mon Jul 12, 2010 12:35 am

Dear Mr. RAO, Mr. Antonio,

Here are the test results.. looks promising :) :D


With the revised control.prg instructed by Mr. RAO

A little concern on no active object or only container (window/dialog) is active..


Image


Here is the result of unmodified control.prg

Image


I used MsgInfo( GetClassName( GetFocus() ) ) for both window/dialog


Using:
Code: Select all  Expand view

       oObj := oWinMDI:oWndClient:GetActive()
       msginfo( oObj:CtrlFocus() )
 
Returns NIL.. error. Maybe I used it incorrectly..

Best regards for both of you,
Frances
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: How to get Active Object in MDI app

Postby nageswaragunupudi » Mon Jul 12, 2010 3:35 am

Mr Frances

In the revised control.prg, wherever you find "::oWnd:oCtlFocus = nil", also please add another line "oCtrlFocus := nil".

Now in our application, you can query for oCtrl := CtrlFocus(). If the result is not nil, then that is the control having focus.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10628
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: How to get Active Object in MDI app

Postby fraxzi » Mon Jul 12, 2010 5:13 am

nageswaragunupudi wrote:Mr Frances

In the revised control.prg, wherever you find "::oWnd:oCtlFocus = nil", also please add another line "oCtrlFocus := nil".

Now in our application, you can query for oCtrl := CtrlFocus(). If the result is not nil, then that is the control having focus.



Dear Mr. RAO,

I works like a charm...


I hope this mod be included in the next build..

Regards,
Frances
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: How to get Active Object in MDI app

Postby nageswaragunupudi » Mon Jul 12, 2010 6:58 am

I hope this mod be included in the next build..

We don't know if Mr. Antonio has a better solution.

We can have a function to return control in focus ( or nil if none ) even without modifying the fwh libraries.

Here is the pseudo logic:
find active window.
find control in focus of that window
if that control is tfolder
find the active dialog
find the control in focus of that dialog

You may try this approach too and make a genral function and test it.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10628
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: How to get Active Object in MDI app

Postby fraxzi » Mon Jul 12, 2010 7:03 am

nageswaragunupudi wrote:
I hope this mod be included in the next build..

We don't know if Mr. Antonio has a better solution.

We can have a function to return control in focus ( or nil if none ) even without modifying the fwh libraries.

Here is the pseudo logic:
find active window.
find control in focus of that window
if that control is tpanel
find the active dialog
find the control in focus of that dialog

You may try this approach too and make a genral function and test it.


Dear Mr. RAO,

I tried that approach but it too much code. Your solution works ok.


Best regards,
Frances
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: How to get Active Object in MDI app

Postby Antonio Linares » Mon Jul 12, 2010 7:20 am

It seems as Rao's solution is very simple and it works fine :-)

And we may enhance it in the future, as described for folders, in case that we need to extend its functionality
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to get Active Object in MDI app

Postby nageswaragunupudi » Wed Jul 14, 2010 11:01 am

Mr. Frances

This seems to be a much simpler solution. Can you please test and confirm if it works for you?
Code: Select all  Expand view
function ActiveControl()

   local oWnd := oWndFromHwnd( GetFocus() )

return If( oWnd:IsKindOf( 'TCONTROL' ), oWnd, nil )
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10628
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 68 guests