Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[VFP] Modal Window not displaying
#1
This is the first I've come across this problem, which seems to be specific to this ActiveX control.

VFP has the ability to display forms within a Top-Level form as a Modal. With a Modal Window no user input (keyboard or mouse) can occur in any other form or in the menu until the modal form is hidden or released. Showing it "In a Top-Level Form" means the form is a child form of the active top-level form, which can be the main Visual FoxPro window or another top-level form.

I'm using the provided VFP form as a sample, which works great.

Basically, I'd like the form with the AntView control to be confined within my main application's window and be the only window that can receive events or be interacted with. If I use the normal settings (In Top-Level Form and Modal), the form never appears. It's init methods run, as well as it's destroy and release methods.

The form appears as normal when setting it to be Modeless.

It's almost as if the ActiveX control is preventing the window from displaying.
Reply
#2
Hi,

Thanks for the report.
This is when setting a property on the form that hosts the AntView control if I'm not mistaken. In particular when the form property Windowstype is set to Modal instead of Modeless, right?

If so I have a bug report open on this and it seems like that that one slipped through the cracks. I need to install VFP9 on my development machine to run this through a debugger and see if I can figure out what is happening.

--
Wil
Reply
#3
(2022-10-13, 12:43:49)wila Wrote: Hi,

Thanks for the report.
This is when setting a property on the form that hosts the AntView control if I'm not mistaken. In particular when the form property Windowstype is set to Modal instead of Modeless, right?

If so I have a bug report open on this and it seems like that that one slipped through the cracks. I need to install VFP9 on my development machine to run this through a debugger and see if I can figure out what is happening.

--
Wil

Exactly Wil, the Form.WindowType is set to 1 (Modal). In my instance, Form.ShowWindow is also set to 1 (In Top-Level Form). In my form Init, I'm immediately navigating to a URL; which I can confirm (with Fiddler) does successfully execute.
Reply
#4
(2022-10-13, 14:13:42)echolis Wrote: Exactly Wil, the Form.WindowType is set to 1 (Modal). In my instance, Form.ShowWindow is also set to 1 (In Top-Level Form). In my form Init, I'm immediately navigating to a URL; which I can confirm (with Fiddler) does successfully execute.

Hi,

Running this in a debugger didn't really help much, beyond that it all seems to run normal from the point of view of AntView.
My suspicion is that the creation of the out-of-process WebView2 control is playing havoc with the form initialization of the modal Fox Pro form.

One thing I tried was to see if I could change the form modality once the webview2 control is created by setting Form.WindowType to 1 from the OnCreateWebViewCompleted event.
eg.
Code:
thisform.WindowType = 1

But that triggers a readonly error.
My guess is that VFP does not allow you to change that after the form has been created (which is not uncommon for Windows)

Next thing I did - and that appears to work - is to set Form.ShowWindow to 2.
In that case the Form is created.

As you mentioned having ShowWindow set to 1, you might already know that, so I'm not sure how useful that is.

If the above doesn't help then I think I would try to create the AntView control dynamically.
Sadly that is currently a bit out of my league in as far as my current FoxPro knowledge goes. I will have a go at that, but figured to at least give you my current feed back on this issue.
--
Wil
Reply
#5
I might have a workaround.

Got the idea from here:
https://www.tek-tips.com/viewthread.cfm?qid=77132

The idea to change the modal state of the form from the OnCreateWebViewCompleted seems that it is possible if you temporarily set the form's visibility to false for a moment.

eg.

Code:
*** ActiveX Control Event ***
LPARAMETERS hresult

thisform.Visible = .F.
thisform.WindowType = 1
thisform.Visible = .T.

That actually runs for me and the form is displayed as expected.

The other interesting part from the link above is that there are other controls that have this issue. Would be nice to know if there's a way for me to handle this in the control, but so far I haven't found what I should do for addressing that.
--
Wil
Reply
#6
(2022-10-17, 12:46:28)wila Wrote: I might have a workaround.

Got the idea from here:
https://www.tek-tips.com/viewthread.cfm?qid=77132

The idea to change the modal state of the form from the OnCreateWebViewCompleted seems that it is possible if you temporarily set the form's visibility to false for a moment.

eg.

Code:
*** ActiveX Control Event ***
LPARAMETERS hresult

thisform.Visible = .F.
thisform.WindowType = 1
thisform.Visible = .T.

That actually runs for me and the form is displayed as expected.

The other interesting part from the link above is that there are other controls that have this issue. Would be nice to know if there's a way for me to handle this in the control, but so far I haven't found what I should do for addressing that.
--
Wil

This works great to get the form to display. But, the control itself doesn't actually display; I can see that the navigate fires and is successful. The control is just in it's default "grey" state.

I was able to fix that by setting the control to visible = .f. and then .t., see below:

Code:
*** ActiveX Control Event ***
LPARAMETERS hresult

this.Visible = .f.
thisform.Visible = .F.
thisform.WindowType = 1
thisform.Visible = .T.
this.Visible = .t.
Reply
#7
(2022-10-31, 16:25:07)echolis Wrote: This works great to get the form to display. But, the control itself doesn't actually display; I can see that the navigate fires and is successful. The control is just in it's default "grey" state.

I was able to fix that by setting the control to visible = .f. and then .t., see below:

Code:
*** ActiveX Control Event ***
LPARAMETERS hresult

this.Visible = .f.
thisform.Visible = .F.
thisform.WindowType = 1
thisform.Visible = .T.
this.Visible = .t.

Glad to hear you got a functioning workaround.

I'd much rather fix it in the control though.
Sadly don't know what to do in order to make it behave like VFP expects.
There's not a lot of low level info out on VFP anymore (or at least I don't know where to find it).
Good tips on books etc.. are welcome.
--
Wil
Reply
#8
I had the same issue.
This is my work around in the forms activate event
IF THISFORM.flactivate && initially true

     THISFORM.flactivate = .F.

     THISFORM.timer1.INTERVAL = 500

     THISFORM.VISIBLE = .T.

     THISFORM.oBrowser.Navigate(THISFORM.fcLink)

ENDIF
Reply
#9
(2022-10-12, 22:35:42)echolis Wrote: This is the first I've come across this problem, which seems to be specific to this ActiveX control.
...
It's almost as if the ActiveX control is preventing the window from displaying.

Try to fix the ActiveX. Big Grin 

Code:
*========================================================================================
* HWND des ActiveX Controls aus dem Activate des Formulares heraus aufgerufen werden.
*========================================================================================
Function ActiveFix
LParameters tnHWND
    Declare Long GetParent in Win32API Long
    Declare Long EnableWindow in WIn32API Long, long
    EnableWindow( GetParent(m.tnHWND), 1 )
EndFunc

Code is courtesy of Christof W. (Foxpert)
Thanks in advance and best regards, Jochen

"The only frontiers are in your mind."
Reply
#10
This is something I am going to look into as it is best fixed in the ActiveX control itself.
Sorry have been a tad busy, so it is still on the list, but should be able to get to it pretty soon.
--
Wil
Reply
#11
Hi,

FYI, I have tried the proposed fix and it did not work for me when trying to patch it in the ActiveX.

Does it work in when using the above in VFP? If so can you get me a code example where it works?
There might be some timing issue or something else very specific that makes it work for you, but not for me.

--
Wil
Reply
#12
I solved it with a simple "show window" in the SHOW of the form.


Code:
PROCEDURE SHOW(nStyle)
   dodefault(nStyle)
   IF thisform.WindowType == 1
      SHOW WINDOW (thisform.name) SAME
   ENDIF
  ...
ENDPROC

But it work also if you call the show window at the init of the form.

.Mat
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)