Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: is ActiveX Control support possible/planned for WinUI 3 ? #4670

Closed
smourier opened this issue Mar 27, 2021 · 16 comments
Closed

Question: is ActiveX Control support possible/planned for WinUI 3 ? #4670

smourier opened this issue Mar 27, 2021 · 16 comments

Comments

@smourier
Copy link

Hi,

I may be mistaken, but I've not seen any information on that.

We have it with WPF: https://docs.microsoft.com/en-us/dotnet/desktop/wpf/advanced/walkthrough-hosting-an-activex-control-in-wpf, we have it with Winforms: https://docs.microsoft.com/en-us/dotnet/desktop/winforms/controls/how-to-add-activex-controls-to-windows-forms

So will we have it with WinUI 3? Otherwise is there a way to write a custom control maybe? any guidance? will it be technically possible (no airspace-like issue)?

Thanks

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Mar 27, 2021
@StephenLPeters
Copy link
Contributor

@ryandemopoulos fyi

@StephenLPeters StephenLPeters removed the needs-triage Issue needs to be triaged by the area owners label Mar 29, 2021
@smourier
Copy link
Author

Hi, any new about this?

@codendone
Copy link
Contributor

There aren't plans in the near future to add ActiveX control hosting in WinUI 3. The easiest option would be to host the ActiveX control via a child HWND (using the HWND from the WinUI window as the parent), but that will have airspace issues. It would be far more complicated to try to host without the airspace limitation.

@smourier
Copy link
Author

smourier commented Apr 30, 2021

Thanks for this answer.

It's sad there's no plan as there are lots of legacy (possibly huge) win32 apps that could be migrated more smoothly if there was a way to integrate parts of them in a WinUI3 host. I understand the reverse is possible (~Xaml islands) but seems to make less sense to me for a migration phase.

Anyway, is it possible to use a SwapChainPanel with its own HWND? Or is this what you mention in your answer?

@codendone
Copy link
Contributor

is it possible to use a SwapChainPanel with its own HWND?

I'm not sure what you mean. You can have the ActiveX hosted on top of all WinUI3 content by hosting it as a child HWND, but SwapChainPanel isn't needed/helpful for this. You could try to not have a visible child HWND by instead implementing windowless ActiveX hosting, which would involve having the ActiveX control render into a bitmap which you could copy into a surface for a SwapChainPanel or SurfaceImageSource, plus implementing mouse and keyboard forwarding and hooking up Accessibility (UIA). The windowless hosting model is clearly much more complicated, and usually has lots of edge cases which need to be handled to get a good experience (for example: ensuring you can smoothly tab in/out of the hosted control).

@mastry
Copy link

mastry commented Jul 8, 2022

I would also like to see ActiveX control hosting in WinUI 3. My specific use case revolves around the ActiveX RDP client.

A (really) nice alternative would be a native WinUI 3 RDP Control.

@castorix
Copy link

castorix commented Jul 8, 2022

I would also like to see ActiveX control hosting in WinUI 3. My specific use case revolves around the ActiveX RDP client.

As codendone said, you can host any ActiveX with a child window... but it needs a Win32 region, in particular since 1.1.0 (because of the background they added)
It is simple with ATL ("AtlAxWin" class), like for WMP player for example ({6BF52A52-394A-11d3-B153-00C04F79FAA6})

@mastry
Copy link

mastry commented Jul 13, 2022

@castorix thanks for the pointer to AtlAxWin but its been decades since I have written any ATL code. I'll poke around for a solution that uses C#. Are there any existing C# examples that you know of?

@castorix
Copy link

@castorix thanks for the pointer to AtlAxWin but its been decades since I have written any ATL code. I'll poke around for a solution that uses C#. Are there any existing C# examples that you know of?

I made some samples in C# wth various ActiveX controls, but I just tested (in C++ first) with MS RDP ActiveX (from "C:\Windows\System32\MsTscAx.dll" ), but I could not make it work (I tested with rdp_test_page, while it works if I test with mstsc.exe)

@mastry
Copy link

mastry commented Jul 13, 2022

Thanks for giving it a try - really appreciate that. I guess I'll have to consider falling back to WPF and .NET Core 3.1 for this project.

@castorix
Copy link

castorix commented Jul 14, 2022

The problem is that MS RDP ActiveX worked before in any language
Old projects like Remote Desktop using C#.NET (.NET Framework of this sample must be changed to 4.8 for example) don't work anymore on my OS (Windows 10 21H1), like my old C++ codes which worked on XP

@castorix
Copy link

After many tests, I could make it work in C++, although it asks me the password even if I set it in code
I will try to convert it into WinUI 3 / C#...

image

@castorix
Copy link

I made a basic sample (Server/User/Password and a few parameters) in C#/Windows App SDK 1.1.0 with MSRDP ActiveX
WinUI3_ActiveX_MSRDP
I met a few problems, that I fixed with workarounds, mainly TerminateProcess() on closing, otherwise the process is never terminated (it is ugly, but I did not find the origin; it happens with this particular ActiveX in C++ too...)

@smourier
Copy link
Author

@castorix - clearly not for the faint of heart 😃 even if complexity may be due do this particular RDP control, that's why I do think there should be "some level" of builtin support for Active X Controls in WinUI3, at least some guidance and/or tutorials.

@mastry
Copy link

mastry commented Jul 21, 2022

@castorix - thanks for working through this. The complexity is unfortunate but at least it gives me a place to start. I need to manage multiple RDP connections in a complex UI so this will be challenging.

@smourier - I fully agree that there should be some stronger guidance and tooling for using ActiveX controls with WinUI 3.

@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants