[译]窗口大小
By robot-v1.0
本文链接 https://www.kyfws.com/applications/window-sizer-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 4 分钟阅读 - 1788 个词 阅读量 0[译]窗口大小
原文地址:https://www.codeproject.com/Articles/2719/Window-Sizer
原文作者:Nish Nishant
译文由本站 robot-v1.0 翻译
前言
A hot-key based program that lets you resize your current window to any size. Useful for web designers and GUI developers as it helps avoid frequent screen-resolution changes.
基于热键的程序,可让您将当前窗口调整为任意大小.对于Web设计人员和GUI开发人员很有用,因为它有助于避免频繁的屏幕分辨率更改.
- 下载安装程序-149 Kb(Download installer - 149 Kb)
- 下载二进制文件-110 Kb(Download binary - 110 Kb)
- 下载源-12 Kb(Download source - 12 Kb)
总览(Overview)
Window Sizer是一个小程序,我在测试网页或GUI应用程序时必须经常更改屏幕分辨率以确保它们在默认分辨率以外的其他分辨率下都能正常工作时编写的.通常,我们还收到客户的要求,这些要求具有怪异的规格,例如最大窗口尺寸为600 x 600或同样奇怪的东西.然后,我发现在编辑CP文章时,我必须切换到800 x 600以确保文章在该分辨率下也能正常显示.所有这些最终都出现在您看到的这个小应用程序中.(Window Sizer is a little program that I wrote when I was having to frequently change screen resolutions when testing web pages or GUI applications to make sure that they worked alright in other resolutions than my default one. Often we also had requests from clients with weird specifications like a maximum window size of 600 x 600 or something equally bizarre. Then I found that when I was editing CP articles I had to switch to 800 x 600 to make sure that the article looked fine in that resolution too. All this culminated in this little app that you see.)
用法(Usage)
只需在Windows启动时运行一次该应用程序即可.只需将快捷方式拖到"开始"菜单的"启动"文件夹中即可.您会在系统托盘上看到一个绿树图标.这是为了让您知道Window Sizer已处于活动状态.现在,只需单击它即可激活窗口,然后按CTRL-ALT-F12,这是弹出Window Sizer的键盘快捷键.现在,您可以从列表框中选择一种分辨率,或使用自定义分辨率,然后单击"调整大小"以将窗口调整为该大小.如果关闭Window Sizer窗口,程序将不会退出,而是会自动隐藏.列表框中的分辨率列表将永远不会超出您的屏幕分辨率.因此,如果您使用的是800 x 600,则不要期望在列表框中看到720 x 720.但是,您可以在"自定义尺寸"文本框中输入自己的想法,后果自负.您可以通过右键单击任务栏并选择"退出"来退出程序.(Just run the app once, probably at windows startup. Just drag a short cut to the Start-Menu’s Startup-folder. You’ll see a green tree icon on your system tray. That’s to let you know that Window Sizer is active. Now just make your window active by clicking on it and press CTRL-ALT-F12 which is the keyboard shortcut that brings up Window Sizer. Now you can choose one of the resolutions from the list box or use a custom resolution, and then click on Resize to resize the window to that size. If you close the Window Sizer window the program won’t exit, it simply hides itself. The resolution list in the list box will never exceed your screen resolution. Thus if you are on 800 x 600, don’t expect to see 720 x 720 in the list box. But you can type what you feel like into the Custom size text boxes at your own risk of course. You can exit the program by right clicking on the task tray and choosing Exit.)
技术细节(Technical details)
基本上我们使用(Basically we use) GetForegroundWindow()
获取当前窗口.这通常比(to get the current window. This usually works better than) GetActiveWindow()
在XP和2K上使用,因为它们提供了一些有趣的选项,设置这些选项时会阻止Windows接管焦点.这意味着我们最终会遇到疯狂的情况,即前景窗口可能不是活动窗口,反之亦然.现在我们使用(on XP and 2K because they have some kind of funny option that when set prevents windows from taking over the focus. This means we end up with crazy situations where the foreground window may not be the active window and vice versa. Now we use) MoveWindow()
调整窗口大小.如果调整大小使窗口脱离屏幕,则将窗口置于屏幕中央.我们还删除了(to resize the window. If the resizing gets the window out of screen, we center the window on the screen. We also remove the) WS_MAXIMIZE
如果已设置,则因为否则操作系统将不知道该窗口尚未最大化.最初,我忽略了这种意外情况,并遇到了一些怪异的副作用.(if it is set because otherwise the OS will not know that the window has been un-maximized. Initially I had over-looked such a contingency and had experienced some weird side effects.)
结论(Conclusion)
我要感谢(I’d like to thank) 大卫沃尔夫(*David Wulff*)](http://www.codeproject.com/script/profile/whos_who.asp?id=1363) 和(*and*) [罗杰
赖特(Roger Wright) 为我做一些快速测试.当我一个人使用它的时候还可以,但是当我想到CP-ing时,我想要一些外部测试,而这两位先生通过测试应用程序为我提供了帮助.当然,据我所知可能还有一些错误.但我希望能像往常一样获得一些质量反馈和建议.(for doing some quick testing for me. It was okay when I alone was using it, but when I thought of CP-ing it, I wanted some external testing and these two gentlemen helped me by testing out the application. Of course there might be a few bugs left for all I know. But I am hoping on getting some quality feedback and suggestions as usual.)
更新(Updates)
- 2002年8月8日-添加了MSI安装程序(Aug 08 2002 - Added an MSI Installer)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C++ VC7.0 WinXP Windows Win2K MFC Visual-Studio Dev 新闻 翻译