如何为Windows设计轻量级GUI?

时间:2023-01-27 12:36:14

I am looking to create a very lightweight GUI front end in Windows. It's supposed to do a simple task - when a hot key combination is pressed it opens up a text box. Any text can be pasted in and then saved with a simple text box. I am looking to avoid any menu bar or toolbars at all.

我期待在Windows中创建一个非常轻量级的GUI前端。它应该做一个简单的任务 - 当按下热键组合时,它会打开一个文本框。可以粘贴任何文本,然后使用简单的文本框保存。我希望避免任何菜单栏或工具栏。

What would be the ideal GUI library to create something like this?

什么是理想的GUI库来创建这样的东西?

8 个解决方案

#1


I'd knock something up using WTL - the footprint will be small - probably the next best thing to a raw Win32 app written in C. There won't be much in the way of dependencies to worry about for example, which might be important.

我会用WTL敲门 - 占用空间很小 - 可能是用C编写的原始Win32应用程序的下一个最好的东西。例如,担心的依赖关系不会太多,这可能很重要。

WTL is available from Source Forge:

WTL可从Source Forge获得:

http://sourceforge.net/projects/wtl

There are some excellent articles on Code Project to get you started. The WTL download can install a WTL Application Wizard for Visual Studio that will give you a bare-bones app with a few mouse-clicks.

Code Project上有一些很棒的文章可以帮助您入门。 WTL下载可以为Visual Studio安装WTL应用程序向导,只需点击几下鼠标即可为您提供简单的应用程序。

#2


What exactly do you mean by "light weight"? If the absolute minimum amount of system resources is important, you should code it Petzold style using 'C' and the raw Win32 API. It will take you a couple of days, give or take.

“轻量”究竟是什么意思?如果系统资源的绝对最小量很重要,则应使用“C”和原始Win32 API对其进行Petzold样式编码。这将需要你几天,给予或采取。

If "light weight" means, "I want to do this in an hour and be done with it" (possibly quicker than waiting for an answer at SO), you should code it with a RAD tool like Windows Forms. It will definitely use a lot more resources than the 'C' version. It is however very unlikely that you'd ever notice.

如果“轻量级”意味着“我希望在一小时内完成此操作并完成它”(可能比等待SO的答案更快),您应该使用像Windows Forms这样的RAD工具进行编码。肯定会使用比“C”版本更多的资源。然而,你不太可能注意到它。

#3


Assuming you have Visual Studio, .NET would be the easiest to get this up and running in the shortest time.

假设你有Visual Studio,.NET将是最容易在最短的时间内完成并运行的。

#4


The question is pretty broad, but I'm partial to markup-based UIs. Here's a window with a text box in WPF:

问题非常广泛,但我偏向于基于标记的UI。这是WPF中带有文本框的窗口:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    <Grid>
      <TextBox x:Name="InputBox"/>
    </Grid>
</Window>

Now I won't even try to claim that WPF has the shortest learning curve, but it is the most powerful on Windows and it's pretty easy to pick up with the right tooling. (i.e. Expression Blend). Blend isn't cheap but some folks already have it for free and don't know it (students, MSDN subscribers, some startups). Visual Studio 2010 is much improved in this area too, so Blend may not be needed.

现在我甚至不会声称WPF具有最短的学习曲线,但它在Windows上是最强大的,并且使用正确的工具很容易获得。 (即Expression Blend)。混合并不便宜,但有些人已经免费使用它并且不知道它(学生,MSDN订阅者,一些初创公司)。 Visual Studio 2010在这方面也有很大改进,因此可能不需要Blend。

#5


Lightweight frameworks were the domain of ATL/COM for a long time.

轻量级框架长期以来一直是ATL / COM的领域。

For something this simple with the primary goal of being lightweight, I would say to use no GUI library at all. All the UI elements are available via direct API call. I would recommend picking up a copy of Charles Petzold's Programming Windows, which covers how to do this in detail.

对于这个简单的主要目标是轻量级的东西,我会说根本不使用GUI库。所有UI元素都可通过直接API调用获得。我建议拿起Charles Petzold编程Windows的副本,其中详细介绍了如何做到这一点。

#6


MFC, Win32, WinForms, .NET forms ...

MFC,Win32,WinForms,.NET表单......

For such simple application, you should use what you know best (language and framework).

对于这样简单的应用程序,您应该使用您最熟悉的(语言和框架)。

If you know nothing (it happens, don't worry about it), and you wan to learn, C# could be easier and less of a hassle to setup than to have to install 3rd party toolkits and frameworks (wxPython, tk/tcl, QT, ...)

如果你什么都不知道(它发生了,不要担心它),你想学习,C#可能更容易设置,而不是安装第三方工具包和框架(wxPython,tk / tcl, QT,...)

#7


I haven't done a lot in it, but I'll second using Visual Studio with C# to get your front-end up. The GUI tools for making other GUIs are pretty good, so you can probably be done really quickly.

我没有做过很多,但是我将第二次使用带有C#的Visual Studio来获得你的前端。用于制作其他GUI的GUI工具非常好,因此您可以非常快速地完成。

If you have total control over what you are going to use, I'd actually recommend using Java Swing. It's got a bunch of classes that do most of the stuff that you want that plug really easily into each other. As a benefit, if you ever need to, it ports to other platforms essentially for free. However, you'll certainly want to look at a tutorial because it operates differently from most other libraries, but you'll want to do that for any framework.

如果您完全控制将要使用的内容,我实际上建议使用Java Swing。它有很多类可以完成大部分你想要插入的东西。作为一种好处,如果您需要,它可以免费移植到其他平台。但是,您肯定希望查看一个教程,因为它与大多数其他库的操作方式不同,但您可能希望为任何框架执行此操作。

If you need to be in C++, then you'll probably want to look into using MFC, but there are much better frameworks available for other languages.

如果您需要使用C ++,那么您可能希望研究使用MFC,但是有更好的框架可用于其他语言。

#8


It's probably still workable to do this with a VBS script file, and the standard COM libraries. Probably even easier with PowerShell.

使用VBS脚本文件和标准COM库可能仍然可行。使用PowerShell可能更容易。

#1


I'd knock something up using WTL - the footprint will be small - probably the next best thing to a raw Win32 app written in C. There won't be much in the way of dependencies to worry about for example, which might be important.

我会用WTL敲门 - 占用空间很小 - 可能是用C编写的原始Win32应用程序的下一个最好的东西。例如,担心的依赖关系不会太多,这可能很重要。

WTL is available from Source Forge:

WTL可从Source Forge获得:

http://sourceforge.net/projects/wtl

There are some excellent articles on Code Project to get you started. The WTL download can install a WTL Application Wizard for Visual Studio that will give you a bare-bones app with a few mouse-clicks.

Code Project上有一些很棒的文章可以帮助您入门。 WTL下载可以为Visual Studio安装WTL应用程序向导,只需点击几下鼠标即可为您提供简单的应用程序。

#2


What exactly do you mean by "light weight"? If the absolute minimum amount of system resources is important, you should code it Petzold style using 'C' and the raw Win32 API. It will take you a couple of days, give or take.

“轻量”究竟是什么意思?如果系统资源的绝对最小量很重要,则应使用“C”和原始Win32 API对其进行Petzold样式编码。这将需要你几天,给予或采取。

If "light weight" means, "I want to do this in an hour and be done with it" (possibly quicker than waiting for an answer at SO), you should code it with a RAD tool like Windows Forms. It will definitely use a lot more resources than the 'C' version. It is however very unlikely that you'd ever notice.

如果“轻量级”意味着“我希望在一小时内完成此操作并完成它”(可能比等待SO的答案更快),您应该使用像Windows Forms这样的RAD工具进行编码。肯定会使用比“C”版本更多的资源。然而,你不太可能注意到它。

#3


Assuming you have Visual Studio, .NET would be the easiest to get this up and running in the shortest time.

假设你有Visual Studio,.NET将是最容易在最短的时间内完成并运行的。

#4


The question is pretty broad, but I'm partial to markup-based UIs. Here's a window with a text box in WPF:

问题非常广泛,但我偏向于基于标记的UI。这是WPF中带有文本框的窗口:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    <Grid>
      <TextBox x:Name="InputBox"/>
    </Grid>
</Window>

Now I won't even try to claim that WPF has the shortest learning curve, but it is the most powerful on Windows and it's pretty easy to pick up with the right tooling. (i.e. Expression Blend). Blend isn't cheap but some folks already have it for free and don't know it (students, MSDN subscribers, some startups). Visual Studio 2010 is much improved in this area too, so Blend may not be needed.

现在我甚至不会声称WPF具有最短的学习曲线,但它在Windows上是最强大的,并且使用正确的工具很容易获得。 (即Expression Blend)。混合并不便宜,但有些人已经免费使用它并且不知道它(学生,MSDN订阅者,一些初创公司)。 Visual Studio 2010在这方面也有很大改进,因此可能不需要Blend。

#5


Lightweight frameworks were the domain of ATL/COM for a long time.

轻量级框架长期以来一直是ATL / COM的领域。

For something this simple with the primary goal of being lightweight, I would say to use no GUI library at all. All the UI elements are available via direct API call. I would recommend picking up a copy of Charles Petzold's Programming Windows, which covers how to do this in detail.

对于这个简单的主要目标是轻量级的东西,我会说根本不使用GUI库。所有UI元素都可通过直接API调用获得。我建议拿起Charles Petzold编程Windows的副本,其中详细介绍了如何做到这一点。

#6


MFC, Win32, WinForms, .NET forms ...

MFC,Win32,WinForms,.NET表单......

For such simple application, you should use what you know best (language and framework).

对于这样简单的应用程序,您应该使用您最熟悉的(语言和框架)。

If you know nothing (it happens, don't worry about it), and you wan to learn, C# could be easier and less of a hassle to setup than to have to install 3rd party toolkits and frameworks (wxPython, tk/tcl, QT, ...)

如果你什么都不知道(它发生了,不要担心它),你想学习,C#可能更容易设置,而不是安装第三方工具包和框架(wxPython,tk / tcl, QT,...)

#7


I haven't done a lot in it, but I'll second using Visual Studio with C# to get your front-end up. The GUI tools for making other GUIs are pretty good, so you can probably be done really quickly.

我没有做过很多,但是我将第二次使用带有C#的Visual Studio来获得你的前端。用于制作其他GUI的GUI工具非常好,因此您可以非常快速地完成。

If you have total control over what you are going to use, I'd actually recommend using Java Swing. It's got a bunch of classes that do most of the stuff that you want that plug really easily into each other. As a benefit, if you ever need to, it ports to other platforms essentially for free. However, you'll certainly want to look at a tutorial because it operates differently from most other libraries, but you'll want to do that for any framework.

如果您完全控制将要使用的内容,我实际上建议使用Java Swing。它有很多类可以完成大部分你想要插入的东西。作为一种好处,如果您需要,它可以免费移植到其他平台。但是,您肯定希望查看一个教程,因为它与大多数其他库的操作方式不同,但您可能希望为任何框架执行此操作。

If you need to be in C++, then you'll probably want to look into using MFC, but there are much better frameworks available for other languages.

如果您需要使用C ++,那么您可能希望研究使用MFC,但是有更好的框架可用于其他语言。

#8


It's probably still workable to do this with a VBS script file, and the standard COM libraries. Probably even easier with PowerShell.

使用VBS脚本文件和标准COM库可能仍然可行。使用PowerShell可能更容易。