An open API service indexing awesome lists of open source software.

https://github.com/windowsnt/uwplib

A library to use UWP controls as plain Win32 controls
https://github.com/windowsnt/uwplib

cpplusplus uwp win32

Last synced: 21 days ago
JSON representation

A library to use UWP controls as plain Win32 controls

Awesome Lists containing this project

README

        

# A simple UWP Wrapper for Win32

CodeProject article: https://www.codeproject.com/Articles/1279856/UwpAX-A-small-library-for-including-Xaml-controls

# UWPLib

It's a library that allows you to use an UWP control as a HWND.

1. Create an app with the attached manifest
2. Call winrt::init_apartment(apartment_type::single_threaded);
3. Call WindowsXamlManager::InitializeForCurrentThread();
4. Call Register()
5. Create windows with UWP_Custom class and use WM_SETTEXT to set the Xaml.
6. The control returns an UWPCONTROL pointer which you can use to manipulate the IInspectable

```C++

struct UWPCONTROL
{
DesktopWindowXamlSource xs;
HWND hParent = 0;
HWND hwnd = 0;
HWND hwndDetailXamlIsland = 0;
winrt::Windows::Foundation::IInspectable ins;
};

auto pv = LR"(
























)";

SetWindowText(GetDlgItem(hh, 901), pv);
UWPLIB::UWPCONTROL* u = (UWPLIB::UWPCONTROL*)SendDlgItemMessage(hh, 901, UWPM_GET_CONTROL, 0, 0);
auto pivot = u->ins.as();
...
```

An example of a DLL that can be called from an ordinary Win32 app is also there in UWP directory. This dll exports a function that can transform a HMENU to an UWP menu and the Win32 can display it.

![T1](https://www.codeproject.com/KB/miscctrl/1279856/u1-r-700.jpg)
![T2](https://www.codeproject.com/KB/miscctrl/1279856/u2.jpg)
![T3](https://www.codeproject.com/KB/miscctrl/1279856/u3.jpg)
![T4](https://www.codeproject.com/KB/miscctrl/1279856/u4.jpg)
![T5](https://www.codeproject.com/KB/miscctrl/1279856/u5.jpg)
![T6](https://www.codeproject.com/KB/miscctrl/1279856/u6.jpg)
![T7](https://www.codeproject.com/KB/miscctrl/1279856/u7.jpg)
![T8](https://www.codeproject.com/KB/miscctrl/1279856/u8.jpg)
![T9](https://www.codeproject.com/KB/miscctrl/1279856/u9.jpg)