Are native Windows Controls still used in .NET GUIs?

主宰稳场 提交于 2019-12-10 17:54:17

问题


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?

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

And yes, this is purely out of interest.


回答1:


User HighCore commented:

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.

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:

MFC/native:

  • 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)

Windows Forms:

  • The app window has the Window Class WindowsForms10.Window.8.app.0.2bf8098_r20_ad1 (oh my)
    • The Button is a separate Window (Class: WindowsForms10.BUTTON.app.0.2bf8098_r20_ad1)

WPF

  • 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]

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.

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.




回答2:


Windows Forms uses native controls for some UI elements. WPF draws everything on its own.



来源:https://stackoverflow.com/questions/16251670/are-native-windows-controls-still-used-in-net-guis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!