Windows窗体在Powershell和Powershell ISE中看起来有所不同.为什么? [英] Windows Forms look different in Powershell and Powershell ISE. Why?

查看:145
本文介绍了Windows窗体在Powershell和Powershell ISE中看起来有所不同.为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个脚本,该脚本基本上是Outlook的小型所见即所得签名生成器.我们希望我们的签名使用公司颜色,并且是半标准化的,因此是必须的.

我在Powershell ISE中进行了开发工作,并且看起来都不错.但是,当我仅使用powershell运行脚本时(如用户所愿),它看起来就完全不同了:

Powershell与Powershell ISE http://www.freeimagehosting.net/uploads/1d6e6c5c6f.png

最上面的一个是在ISE中生成的,看起来像我想要的.最底层的是直接从powershell运行的,看起来在视觉上已经退缩了五年!

如何使脚本在Powershell中看起来像在Powershell ISE中一样时髦?

谢谢

解决方案

在显示表单之前,在脚本中添加以下行:

[System.Windows.Forms.Application]::EnableVisualStyles();

I have written a script which is basically a small wysiwyg signature generator for Outlook. We want our signatures to be in corporate colours, and semi-standardised - hence the requirement for this.

I did the development work in Powershell ISE and all looked good. However, when I run the script just using powershell (as the users will) it looks totally different:

Powershell vs Powershell ISE http://www.freeimagehosting.net/uploads/1d6e6c5c6f.png

The top one was generated in ISE, and looks as I want it. The bottom one was run from powershell directly and seems to have visually regressed five years!

How can I get the script to look as snazzy in Powershell as it does in Powershell ISE?

Thanks,

Ben

解决方案

Add the following line in your script before you show the form:

[System.Windows.Forms.Application]::EnableVisualStyles();

这篇关于Windows窗体在Powershell和Powershell ISE中看起来有所不同.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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