Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling WPF form from VFP9.0
Message
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Miscellaneous
Thread ID:
01651997
Message ID:
01652031
Views:
81
It's possible but it's very finicky and I wouldn't recommend. First off you can't just call a WPF or WinForms app as is - you have to create a new STA thread and run the form of off that thread in order to be able to interact with it.
This works - sort of - but is likely to frequently crash on you and you'll be fighting major focus issues due to the Windows handles getting mixed up between your Fox app and the WPF app.

If that doesn't scare you I wrote a short blog article 13 years ago (scary that!) that talks about the mechanics of running WinForms off a thread. But again I would NOT recommend doing that.

https://weblog.west-wind.com/posts/2004/Aug/02/Automating-a-NET-WinForm-through-COM-Interop

A better way IMHO is to build the form as a standalone EXE that you can launch from FoxPro. Do what you need to do with the form and when you're done write out a file with the results that you need. If you need something a bit more interactive you can look into some interprocess application mechanisms like Named Pipes or WebSockets/SignalR, but I this tends to be much more reliable than doing direct interfop with a UI assembly from FoxPro.



+++ Rick ---




>Hello all....
>
>Here is what I want to do.
>1) create a simple WPF form using c#
>2) Create a dll that will launch the WPF form
>3) Call the dll from VFP app. The dll will launch the WPF form and pass back the form's handle to the VFP app.
>
>
>Is this possible to do? If so, would VFP know what the WPF form handle is?
>
>Thanks in advance.
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Reply
Map
View

Click here to load this message in the networking platform