You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Question: How should I call WinRT Pointer API in a desktop application? #233
For mouse input be sure to call ::EnableMouseInPointer(TRUE) first - it's the default for UWP apps, but not the default for Win32/HWND.
Sadly I don't have a Samsung device or an S pen to try it out.
Unfortunately, Windows.UI.Input.PointerPoint doesn't have DualApiPartitionAttribute, which means it can't be used in Win32 app.
The attribute is unevenly applied. There's lots of APIs that work fine in desktop apps that are missing the attribute. We're working on more granular attributes for requirements - "must be called on a Dispatcher thread" or "must be called in a process with package identity" or "must be called on a foreground thread" ... something we hope to address in Project Reunion.
Did I mess something up? I only added #include <windows.h> at the beginning but Visual Studio throw an unresolved external symbol error:
1>------ Rebuild All started: Project: WinRT C++ Ink Demo, Configuration: Debug x64 ------
1>WinRT C++ Ink Demo.cpp
1>MSVCRTD.lib(exe_main.obj) : error LNK2019: unresolved external symbol main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
1>C:\Users\Aster\Source\Repos\WinRT C++ Ink Demo\x64\Debug\WinRT C++ Ink Demo.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "WinRT C++ Ink Demo.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
I'm using latest Insider dev Windows SDK (10.0.20231.0). Using an older Windows SDK (Below is using 10.0.18362.0 SDK) would throw more unresolved symbol error:
1>------ Build started: Project: WinRT C++ Ink Demo, Configuration: Debug x64 ------
1>WinRT C++ Ink Demo.obj : error LNK2019: unresolved external symbol WINRT_GetRestrictedErrorInfo referenced in function "public: __cdecl winrt::hresult_error::hresult_error(struct winrt::hresult,struct winrt::hresult_error::from_abi_t)" (??0hresult_error@winrt@@QEAA@Uhresult@1@Ufrom_abi_t@01@@Z)
1>WinRT C++ Ink Demo.obj : error LNK2019: unresolved external symbol WINRT_RoGetActivationFactory referenced in function "__cdecl winrt::get_activation_factory<struct winrt::Windows::UI::Input::IPointerPointStatics>(struct winrt::param::hstring const &)" (??$get_activation_factory@UIPointerPointStatics@Input@UI@Windows@winrt@@@winrt@@YA@AEBUhstring@param@0@@Z)
1>WinRT C++ Ink Demo.obj : error LNK2019: unresolved external symbol WINRT_RoOriginateLanguageException referenced in function "private: void __cdecl winrt::hresult_error::originate(struct winrt::hresult,void *)" (?originate@hresult_error@winrt@@AEAAXUhresult@2@PEAX@Z)
1>WinRT C++ Ink Demo.obj : error LNK2019: unresolved external symbol WINRT_WindowsCreateStringReference referenced in function "public: __cdecl winrt::param::hstring::hstring(class std::basic_string_view<wchar_t,struct std::char_traits<wchar_t> > const &)" (??0hstring@param@winrt@@QEAA@AEBV?$basic_string_view@_WU?$char_traits@_W@std@@@std@@@Z)
1>MSVCRTD.lib(exe_main.obj) : error LNK2019: unresolved external symbol main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
1>C:\Users\Aster\Source\Repos\WinRT C++ Ink Demo\x64\Debug\WinRT C++ Ink Demo.exe : fatal error LNK1120: 5 unresolved externals
1>Done building project "WinRT C++ Ink Demo.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
For the issue on the top, the linker thinks you're writing a CLI app when you're not; you can fix that in Project Properties > Linker. For the bottom issue, try adding windowsapp.lib to your application's linkline.
The current scenario is quite awkward. I'm trying to bring WinRT Ink API to Krita (C++ and Qt). The problem is that it won't build using msvc/Clang, thus I couldn't call WinRT API directly. (mainly because it uses many Linux libraries which isn't quite fit for MSVC/clang and C++ subversion support isn't that new. Documented way to build Krita under Windows is using MinGW-w64).
Personally, I think I could write and build a custom DLL that reads from WinRT Ink API and "exposes" it for Krita to use. But this is making things more complicated. Googling doesn't offer valuable results for calling WinRT API in a normal win32 DLL.
Another question I am curious is that why I couldn't read mouse event through Python/WinRT (microsoft/xlang#711). There is no demo and I am not sure how WinRT API projection works.
Activity
ysc3839 commentedon Oct 8, 2020
Unfortunately, Windows.UI.Input.PointerPoint doesn't have DualApiPartitionAttribute, which means it can't be used in Win32 app.
jonwis commentedon Oct 8, 2020
You can use
PointerPointin a Win32 application! It's missing the attribute. Here's a little sample:For mouse input be sure to call
::EnableMouseInPointer(TRUE)first - it's the default for UWP apps, but not the default for Win32/HWND.Sadly I don't have a Samsung device or an S pen to try it out.
The attribute is unevenly applied. There's lots of APIs that work fine in desktop apps that are missing the attribute. We're working on more granular attributes for requirements - "must be called on a Dispatcher thread" or "must be called in a process with package identity" or "must be called on a foreground thread" ... something we hope to address in Project Reunion.
Aster-the-Med-Stu commentedon Oct 9, 2020
Did I mess something up? I only added
#include <windows.h>at the beginning but Visual Studio throw an unresolved external symbol error:I'm using latest Insider dev Windows SDK (10.0.20231.0). Using an older Windows SDK (Below is using 10.0.18362.0 SDK) would throw more unresolved symbol error:
wjk commentedon Oct 9, 2020
Aster Wang (@Aster-the-Med-Stu)
For the issue on the top, the linker thinks you're writing a CLI app when you're not; you can fix that in Project Properties > Linker. For the bottom issue, try adding
windowsapp.libto your application's linkline.Aster-the-Med-Stu commentedon Oct 30, 2020
The current scenario is quite awkward. I'm trying to bring WinRT Ink API to Krita (C++ and Qt). The problem is that it won't build using msvc/Clang, thus I couldn't call WinRT API directly. (mainly because it uses many Linux libraries which isn't quite fit for MSVC/clang and C++ subversion support isn't that new. Documented way to build Krita under Windows is using MinGW-w64).
Personally, I think I could write and build a custom DLL that reads from WinRT Ink API and "exposes" it for Krita to use. But this is making things more complicated. Googling doesn't offer valuable results for calling WinRT API in a normal win32 DLL.
(If anyone came across here, the guide for using WinRT component in win32 C++ desktop app is at https://blogs.windows.com/windowsdeveloper/2019/04/30/enhancing-non-packaged-desktop-apps-using-windows-runtime-components/)
Another question I am curious is that why I couldn't read mouse event through Python/WinRT (microsoft/xlang#711). There is no demo and I am not sure how WinRT API projection works.