Hi Nick,
per your request in this forum
I know who to interface a .net win32 C# dll from VO using COM interop. ( That is how I am firing up the Crystal reports, modify a report using the RAS API and fire up the viewer)
Now I need to fire up a WPF view that has an user control on it. I assume it is going to work in a similar way, probably a bit different how to pass an window handle from VO and how to deal with it in
the WPF side
So, any hints or sample surely are welcome
Thanks
Oskar
VO and .net WPF interoperabiliy
-
- Posts: 248
- Joined: Fri Oct 14, 2016 7:09 am
VO and .net WPF interoperabiliy
Hi Oskar (apologies, I put you as Oscar on the Google forum)
To call into a WPF app is very simple. On the WPF end it could be something like this (in pseudo-code)
Then on the VO end you could call it with
The WindowsInteropHelper allows you to make the VO window the owner of the WPF window, so if you minimise the VO app, the WPF window will minimise automatically.
If you need to do callbacks into the VO app, let me know, I have code for that using delegates.
HTH
NIck
To call into a WPF app is very simple. On the WPF end it could be something like this (in pseudo-code)
Code: Select all
[ComVisible(true)]
public class WPFVOVisible
{
private WindowInteropHelper _wih;
private IntPtr _ownerHwnd;
private Int32 _intvar;
private string _stringvar;
private WPFView _myview;
public WPFVOVisible() { }
public void StartWPFView(Int32 ownerHwnd, string param1, Int32 param2)
{
_ownerHwnd = (IntPtr)ownerHwnd;
_stringvar = param1;
_intvar = param2;
try
{
_myview = new WPFView();
_wih = new WindowInteropHelper(_myview);
_wih.Owner = _ownerHwnd
_myview.Show();
}
catch (Exception excep)
{
.....
}
}
}
Code: Select all
oWPF:=OleAutoObject{"MyWPFProg.WPFVOVisible"}
IF oWPF:fInit
oWPF:StartWPFView(SELF:Owner:Handle(),"a string",10)
ENDIF
If you need to do callbacks into the VO app, let me know, I have code for that using delegates.
HTH
NIck
VO and .net WPF interoperabiliy
Hi Nick,
thank you very much, this is very interesting, and I'm pretty sure I will need that sometimes...
Could you show please also how to do the callback into the VO application?
TIA
Wolfgang
thank you very much, this is very interesting, and I'm pretty sure I will need that sometimes...
Could you show please also how to do the callback into the VO application?
TIA
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
-
- Posts: 248
- Joined: Fri Oct 14, 2016 7:09 am
VO and .net WPF interoperabiliy
Hi Wolfgang,
At the WPF end you need something like this (sending an int back to VO as a paramter)
which you can then call simply as
At the VO end you need
And that's it. Obviously you can register as many different functions as you need. I think the limitation is that it would be very difficult to callback into a class method in VO.
HTH
Nick
At the WPF end you need something like this (sending an int back to VO as a paramter)
Code: Select all
private delegate void VOFunctionDelegate([MarshalAs(UnmanagedType.I4)] Int32 param1);
private VOFunctionDelegate VOFunction;
public void Set_VOFunction_Callback(Int32 handle)
{
VOFunction = (VOFunctionDelegate)Marshal.GetDelegateForFunctionPointer((IntPtr)handle, typeof(VOFunctionDelegate));
}
Code: Select all
....
VOFunction(5);
....
Code: Select all
oWPF:Set_VOFunction_Callback(dword(_cast,@MyVOFunction()))
FUNCTION MyVOFunction(liParam AS LONGINT) AS VOID PASCAL
.....
RETURN
HTH
Nick
VO and .net WPF interoperabiliy
Hi Nick,
thank you very, very much!
Wolfgang
thank you very, very much!
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it