.NET GUI 中是否仍使用本机 Windows 控件? [英] Are native Windows Controls still used in .NET GUIs?

查看:34
本文介绍了.NET GUI 中是否仍使用本机 Windows 控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 WinForms 或 WPF 创建 GUI 时显示的内容是否仍然基于诸如 通用控件 或任何系统提供的窗口类 或者显示的所有内容都是由框架自定义"绘制的?

Is the stuff that is displayed when you create a GUI with WinForms or WPF still based on the native controls like Common Controls or any of the system provided Window Classes or is everything that is displayed "custom" drawn by the framework?

注意:我说的不是文件对话框之类的东西,而是实际使用 WinForms 或 WPF 实现的 GUI.

Note: I'm not talking about stuff like a file dialog, but GUI that was actually implemented with WinForms or WPF.

是的,这纯粹是出于兴趣.

推荐答案

用户 HighCore 评论:

User HighCore commented:

WPF 对 Window 对象使用HWND",但对所有其他对象使用HWND"Window里面的(控件)是与Win32中不相关的WPF对象无论如何,因为 AFAIK,winforms 为每个 UI 使用单独的 HWND元素.

WPF Uses an "HWND" for the Window objects, but then all other objects (Controls) inside the Window are WPF objects not related to Win32 in any way, wheareas AFAIK, winforms uses a separate HWND for each UI element.

事实上,使用 Spy++,当我们创建一个带有简单对话框/窗口和按钮的测试应用程序时,我们可以观察到以下内容:

And indeed, using Spy++, we can observe the following when we create a test app with a simple dialog/window and a button on it:

  • 应用程序窗口是具有 #32770 (Dialog) 窗口类的窗口 (HWND)(我使用了基于对话框的"应用程序.)
    • 按钮是一个单独的窗口(类:Button)
    • The app window is a Window (HWND) with the Window Class of #32770 (Dialog) (I used a "Dialog based" app.)
      • The Button is a separate Window (Class: Button)
      • 应用程序窗口具有窗口类 WindowsForms10.Window.8.app.0.2bf8098_r20_ad1(天啊)
        • 按钮是一个单独的窗口(类:WindowsForms10.BUTTON.app.0.2bf8098_r20_ad1)
        • 只有一个顶级窗口,不过为了更好地衡量,我在 UI 设计器中向该窗口添加了一个组合框、一个列表框和一个菜单.
        • 唯一窗口的类是:HwndWrapper[WpfApplication1.exe;;9b1aec0f-1b88-419c-8730-858906314cd9]
        • There's only one top level Window, although for good measure I added a ComboBox, a ListBox, and a Menu to this window in the UI designer.
        • The Class of the only Window is: HwndWrapper[WpfApplication1.exe;;9b1aec0f-1b88-419c-8730-858906314cd9]

        Window Class 名称实际上非常有趣:使用 MFC/native 名称,您可以获得多年来已知的类并记录在 MSDN 上.对于 Windows 窗体,它似乎总是使用相同的类名.对于 WPF,窗口类的名称似乎也包含可执行文件/进程名称.

        The Window Class names are actually quite interesting: With the MFC/native one you get the classes known for years and documented on MSDN. With Windows Forms, it does appear that it always uses the same class names. And with WPF it seems the name of a Class of a Window also incorporates the executable/process name.

        显然,MS 认为不再需要每个窗口使用一个以上的窗口.我想我需要为此提出第二个问题.

        So apparently MS thinks that using more than one Window per window isn't necessary anymore. I think I need to open a second question for that.

        这篇关于.NET GUI 中是否仍使用本机 Windows 控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆