Thanks Mike,

I will give it a go.

Dennis

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of MikeB
Sent: Saturday, March 14, 2009 12:32 PM
To: RBASE-L Mailing List
Subject: [RBASE-L] - Re: Form Focus Question

OK.. Here is the RBASE Only solution {TESTED}:

1.  In your CallingMDI forms onBefore declare the following Vars and STDCALL 
declaration:
  Set var vCallerHWND integer = 0
  SET VAR vforegrnd INTEGER = 0
{This will return the HWND of whatever window you have clicked on or 
setFocus to}
IF (chkfunc('GetForegroundWindow')) = 0 THEN
  STDCALL function 'GetForegroundWindow' () : integer
ENDIF

2.  In your CallingMDI forms OnAfter:
-- Get the window handle of this form
SET VAR vThisWndtxt TEXT = NULL
GETPROPERTY RBASE_FORM HANDLE 'vThisWndtxt'
SET VAR vCallerHWND = (INT(.vThisWndtxt))
recalc variables

3.  In your CallingMDI forms Timer event:

{This will return the HWND of whatever window you have clicked on or 
setFocus to}
SET VAR vforegrnd = (dlcall('user32.dll', 'GetForegroundWindow'))
RECALC VARIABLES
IF vforegrnd = .vcallerhwnd THEN
  SETFOCUS mditimer
ENDIF



----- Original Message ----- 
From: "Lawrence Lustig" <[email protected]>
To: "RBASE-L Mailing List" <[email protected]>
Sent: Friday, March 13, 2009 2:40 PM
Subject: [RBASE-L] - Re: Form Focus Question


<<
The two forms move around the desktop
together, one below the other, using a timer to achieve this.
I thought we could use this eep but we can
only tell when the forms have moved, not whether focus has returned to one 
of
them.
>>

Well, I think you could work along these lines.  I suspect there's either a 
direct call you can make into Windows to learn whether a particular window 
is on top, or to get it's zorder, or has focus, or belongs to the 
_application_ with focus; or else it would be fairly straightforward to 
write a UDF to do this.  You could make that call in your timer and then, if 
it turns out your window or application is on top, bring the other window to 
the fore as well.

Another idea.  Are the two forms in your application ALWAYS linked this way, 
or are they used separately elsewhere?  If they're always associated, what I 
sometimes to is write a single form with two "appearances".  The user switch 
between them with a "Details" button, which makes the form larger and 
exposes some more controls.  This has a similar effect, but uses only one 
window.
--
Larry


Reply via email to