您如何使用Winrt创建经典的Win32应用程序窗口
How do you create a classic win32 application window with WinRT?
c winrt等同于Win32 API中的内容是什么,将注册窗口类,创建窗口,然后通过消息泵循环保持窗口?
我目前正在查看Winrt的文档,因为我想学习如何做我过去在Win32中做的所有事情。
到目前为止,我的经历还很糟糕,我只是直接承认我没有得到它。
我尝试了此操作,但是由于我没有在容器中运行,因此似乎尚未创建线程的CoreWindow。
int WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int)
{
winrt::init_apartment(winrt::apartment_type::single_threaded);
winrt::Windows::UI::Core::CoreWindow window = winrt::Windows::UI::Core::CoreWindow::GetForCurrentThread();
window.Activate();
auto dispatcher = window.Dispatcher();
using DispatcherOptions = winrt::Windows::UI::Core::CoreProcessEventsOption;
const DispatcherOptions options = DispatcherOptions::ProcessUntilQuit;
dispatcher.ProcessEvents(options);
}
c /winrt是使用Windows Runtime(又称Winrt(API的现代C 方法。这些API源自IInspectable
,该API本身源自IUnknown
。除了COM对象的winrt::com_ptr
外,它并没有为Classic Win32 API提供太多。
您当然可以使用C /WinRT来消费Win32 Classic应用程序中的Windows运行时API,但是对于Win32 Classic程序,没有" CoreWindow"之类的东西。所有Windows::UI::CoreWindow
与通用Windows平台(UWP(应用有关。
请参阅Microsoft Docs
c /winrt旨在支持使用Windows运行时类型系统编写的投影API。其中包括windows.ui.xaml和winodws.ui.com posiot apis。这些API是为UWP风格的应用而设计的,并且与Classic Win32 API交互的能力非常有限。
您可能会发现Wil标题库有用。它没有C /Winrt获得的C 的完整现代包装器,但是您会发现库有许多Win32结构的智能包装器和各种便利助手。您可以在这里找到文档。
相关文章:
- WM_CTLCOLORSTATIC从未在WIN32应用程序中触发
- 如何从 Win32 C++ 应用程序输出到父控制台窗口?
- SWIG和Mingw-64与Python一起使用...不是有效的 Win32 应用程序
- 在 Win32 应用程序中承载 GTK+3 上下文
- 开发如何解决错误193:%1不是Dev C 中的Win32应用程序
- 您如何使用Winrt创建经典的Win32应用程序窗口
- 链接错误时,使用CLION/CMAKE/MSVC 2015编译WIN32应用程序
- 如何在VS 2017 C++Win32应用程序中打印出gethostname结果
- 我如何将Win32应用程序迁移到X64
- 如何制作一个不依赖msvc dll的win32应用程序
- 空的Win32 C++应用程序内存消耗过多
- 是否可以在 Visual Studio 中的 Win32 C++应用程序中的控制台中进行调试
- 从头开始创建C 背景Win32应用程序
- 托管C#Win32应用程序的非托管DLL.与课堂入口
- Exe不是有效的win32应用程序,但在64位上运行
- 具有控制台输出且没有新窗口的 Win32 应用程序
- 使用 C++11 编写 Win32 应用程序
- 使用类设置 win32 应用程序的更好方法
- 用于 Win32 应用程序的 WriteFile() 函数
- 调用 C 代码的 Win32 应用程序