Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Desktop Windows on Top
Message
From
14/07/2020 08:40:59
 
 
To
14/07/2020 03:06:21
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01675146
Message ID:
01675165
Views:
93
I've thought of a couple ways you can work around this.

The easiest might be to have a parent class for your Form (if you don't already), and then add a method (called mth_bring_to_front) which you call which examines the form's thisForm.oParentForm property, and if valid, then call the thisForm.oParentForm.mth_bring_to_front(), and when there is nothing else to call, then:
DECLARE INTEGER SetWindowPos IN WIN32API ;
    INTEGER nHWnd, ;
    INTEGER nHWndInsertAfter, ;
    INTEGER nX, ;
    INTEGER nY, ;
    INTEGER nCx, ;
    INTEGER nCy, ;
    INTEGER nFlags

#define SWP_NOSIZE          0x0001
#define SWP_NOMOVE          0x0002
#define SWP_NOZORDER        0x0004
#define SWP_NOREDRAW        0x0008
#define SWP_NOACTIVATE      0x0010
#define SWP_FRAMECHANGED    0x0020  /* The frame changed: send WM_NCCALCSIZE */
#define SWP_SHOWWINDOW      0x0040
#define SWP_HIDEWINDOW      0x0080
#define SWP_NOCOPYBITS      0x0100
#define SWP_NOSENDCHANGING  0x0400  /* Don't send WM_WINDOWPOSCHANGING */
#define SWP_NOREPOSITION    0x0200  /* Don't do owner Z ordering */

SetWindowPos(thisForm.HWnd, thisForm.oParentForm.HWnd, 0, 0, 0, 0, SWP_NOSIZE + SWP_NOMOVE + SWP_NOACTIVATE + SWP_SHOWWINDOW)
By having each new modal form call its parent, all the way to the root, and then executing this sequence to bring them to the top using a Windows' function call, it should bring the topmost form to the top. I haven't tested it, but it or something like it should work. If not, let me know and I'll get it working.

>>You could use a similar method to set the AlwaysOnBottom property to .t., or leave it as-is and set the AlwaysOnTop to .t. on the form that has focus.
>>
>>There are some tweaks you can use to workaround what you're doing.
>
>Hi Rick,
>
>I also tried that (was actually my first guess), but apparently all events and all properties are ignored when I click on the form coming from outside of the VFP area. Even the activate event does not get triggered, neither ON KEY LEFTMOUSE etc. The only thing that gets always triggered is the WM_NCLBUTTONDOWN on the Titlebar of a form.
>
>I managed to solve the problem by ON KEY LABEL LEFTMOUSE triggering SetLastWindowToForeground() which uses the stack of window handles to move the current modal form to the front.
>
>So now when the user clicks into a background form (not the titlebar), this form gets activated nevertheless and the LEFTMOUSE does not get triggered. But a second click will then trigger the LEFTMOUSE call and sets the modal form to the front. This is already much better than before.
>WIth click in Titlebar that works perfectly because the first click already raises the event. It would be best if there is a similar event when clicking anywhere, but have not yet figured that out.
>
>In the following example it demonstrates that a click on the Titlebar on the main form does not trigger Activate(), when you do that from outside of VFP. Now a click on the form itself does not activate the main form, but in my case this is different because many forms are based on formsets with WindowType = 2 (READ), so this adds another level of complication I suppose.
>
>
>loForm = CREATEOBJECT("DesktopForm")
>loForm.Show(0)
>
>DEFINE CLASS DesktopDialog AS FORM
>	Desktop = .T.
>	AlwaysOnBottom = .F.
>	AlwaysOnTop = .T.
>ENDDEFINE
>
>DEFINE CLASS DesktopForm AS DesktopDialog
>	
>	AlwaysOnBottom = .T.
>	AlwaysOnTop = .F.
>	
>	ADD OBJECT cmd AS CommandButton WITH ;
>			Caption = "Open"
>			
>	PROCEDURE INIT
>		_SCREEN.AddProperty(SYS(2015), THIS)
>	ENDPROC
>	
>	PROCEDURE Activate
>		WAIT WINDOW "Activate" TIMEOUT 1
>	ENDPROC
>	
>	PROCEDURE cmd.Click
>		loDialog = CREATEOBJECT("DesktopDialog")
>		loDialog.Left = 100
>		loDialog.Top = 100
>		loDialog.Show(1)
>	ENDPROC
>	
>ENDDEFINE
>
Previous
Reply
Map
View

Click here to load this message in the networking platform