Click here to Skip to main content
6,822,123 members and growing! (17,101 online)
Email Password   helpLost your password?
Web Development » Applications & Tools » Tools with source code     Intermediate

Window Sizer

By Nishant Sivakumar

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.
VC7Win2K, WinXP, MFC, Dev
Posted:6 Aug 2002
Updated:7 Aug 2002
Views:142,838
Bookmarked:64 times
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
51 votes for this article.
Popularity: 8.02 Rating: 4.70 out of 5
1 vote, 2.6%
1

2

3
3 votes, 7.7%
4
35 votes, 89.7%
5

Overview

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

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() 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 and Roger Wright 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

  • Aug 08 2002 - Added an MSI Installer

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Nishant Sivakumar


Member
Nish is a real nice guy living in Atlanta, who has been coding since 1990, when he was 13 years old. Originally from sunny Trivandrum in India, he recently moved to Atlanta from Toronto and is a little sad that he won't be able to play in snow anymore.

Nish has been a Microsoft Visual C++ MVP since October, 2002 - awfully nice of Microsoft, he thinks. He maintains an MVP tips and tricks web site - www.voidnish.com where you can find a consolidated list of his articles, writings and ideas on VC++, MFC, .NET and C++/CLI. Oh, and you might want to check out his blog on C++/CLI, MFC, .NET and a lot of other stuff - blog.voidnish.com

Nish loves reading Science Fiction, P G Wodehouse and Agatha Christie, and also fancies himself to be a decent writer of sorts. He has authored a romantic comedy Summer Love and Some more Cricket as well as a programming book – Extending MFC applications with the .NET Framework.

Nish's latest book C++/CLI in Action published by Manning Publications is now available for purchase. You can read more about the book on his blog.

Despite his wife's attempts to get him into cooking, his best effort so far has been a badly done omelette. Some day, he hopes to be a good cook, and to cook a tasty dinner for his wife.
Location: United States United States

Other popular Applications & Tools articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 60 (Total in Forum: 60) (Refresh)FirstPrevNext
Generalis there a newer or similar free version out now? Pinmemberjuly churches9:15 10 Oct '08  
GeneralCtrl+Alt+F12 Does Not Work PinmemberKirill Osipov21:05 9 Oct '07  
GeneralVery Cool Nish PinmemberJeffrey Walton13:53 15 Dec '06  
Generalactive window Pinmemberkrishnachandran19:25 18 Dec '05  
GeneralProblem related to COM Wrapper Pinmemberparesh_vs4:02 15 Nov '04  
GeneralCan not resize Yahoo Messenger 6.0 window PinmemberJList8:16 9 Oct '04  
GeneralWindow Sizer PinsussWayland Moncrief9:53 5 Dec '03  
GeneralBitmap stretching Pinmembercollincode20:49 15 Sep '03  
GeneralRe: Bitmap stretching PineditorNishant S22:18 15 Sep '03  
GeneralResizing IE PinsitebuilderUwe Keim22:41 19 Jul '03  
GeneralGreat work! PinmemberRyan Binns19:44 26 Mar '03  
GeneralWindow Sizer Predefined sizes PinmemberPaul Farry18:15 13 Mar '03  
GeneralRe: Window Sizer Predefined sizes PineditorNishant S20:46 13 Mar '03  
GeneralThis is what I was looking for PinmemberWillemM21:39 3 Mar '03  
GeneralRe: This is what I was looking for PineditorNishant S6:15 8 Mar '03  
GeneralStandard Window Sizes PinmemberIanL23:58 19 Feb '03  
GeneralRe: Standard Window Sizes PineditorNishant S6:16 8 Mar '03  
GeneralExcellent Nish PinmemberJörgen Sigvardsson3:34 22 Nov '02  
GeneralRe: Excellent Nish PineditorNishant S11:58 23 Dec '02  
GeneralRe: Excellent Nish Pinmembercollincode21:41 15 Sep '03  
GeneralRe: Excellent Nish PineditorNishant S22:20 15 Sep '03  
General1.5 problems PinmemberAndreas Saurwein5:31 29 Aug '02  
GeneralRe: 1.5 problems PineditorNishant S11:58 23 Dec '02  
GeneralRe: 1.5 problems Pinmemberusxue0:59 23 May '03  
GeneralDamn this is useful PinmemberDavid Wulff5:17 29 Aug '02  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.

PermaLink | Privacy | Terms of Use
Last Updated: 7 Aug 2002
Editor: Nishant Sivakumar
Copyright 2002 by Nishant Sivakumar
Everything else Copyright © CodeProject, 1999-2010
Web21 | Advertise on the Code Project