Click here to Skip to main content
Click here to Skip to main content

Window Sizer

By , 7 Aug 2002
 

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Nish Sivakumar
United States United States
Member
Nish is a real nice guy who has been writing code since 1990 when he first got his hands on an 8088 with 640 KB RAM. Originally from sunny Trivandrum in India, he has been living in various places over the past few years and often thinks it’s time he settled down somewhere.
 
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.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionNo download link pops up!!memberMember 955539629 Oct '12 - 8:30 
AnswerRe: No download link pops up!!mvpNish Sivakumar29 Oct '12 - 8:38 
QuestionWindow Sizermemberwwmjava18 Oct '12 - 14:49 
QuestionNot working in windows 7memberDeepak.Prahlad15 Aug '11 - 20:10 
GeneralNeed to set a size for the windows contents, excluding the window bordermemberAdam Reece16 May '11 - 6:20 
GeneralMy vote of 4memberPatrick Kalkman23 Jan '11 - 5:00 
GeneralGreat ArticlememberGaurav Dudeja India19 Apr '10 - 0:47 
Questionis there a newer or similar free version out now?memberjuly churches10 Oct '08 - 8:15 
GeneralCtrl+Alt+F12 Does Not WorkmemberKirill Osipov9 Oct '07 - 20:05 
GeneralRe: Ctrl+Alt+F12 Does Not WorkmemberDeepak.Prahlad15 Aug '11 - 20:12 
GeneralVery Cool NishmemberJeffrey Walton15 Dec '06 - 12:53 
Generalactive windowmemberkrishnachandran18 Dec '05 - 18:25 
GeneralProblem related to COM Wrappermemberparesh_vs15 Nov '04 - 3:02 
QuestionCan not resize Yahoo Messenger 6.0 windowmemberJList9 Oct '04 - 7:16 
GeneralWindow SizersussWayland Moncrief5 Dec '03 - 8:53 
GeneralBitmap stretchingmembercollincode15 Sep '03 - 19:49 
GeneralRe: Bitmap stretchingeditorNishant S15 Sep '03 - 21:18 
GeneralResizing IEsitebuilderUwe Keim19 Jul '03 - 21:41 
GeneralGreat work!memberRyan Binns26 Mar '03 - 18:44 
GeneralWindow Sizer Predefined sizesmemberPaul Farry13 Mar '03 - 17:15 
GeneralRe: Window Sizer Predefined sizeseditorNishant S13 Mar '03 - 19:46 
GeneralThis is what I was looking formemberWillemM3 Mar '03 - 20:39 
GeneralRe: This is what I was looking foreditorNishant S8 Mar '03 - 5:15 
GeneralStandard Window SizesmemberIanL19 Feb '03 - 22:58 
GeneralRe: Standard Window SizeseditorNishant S8 Mar '03 - 5:16 
GeneralExcellent NishmemberJörgen Sigvardsson22 Nov '02 - 2:34 
GeneralRe: Excellent NisheditorNishant S23 Dec '02 - 10:58 
GeneralRe: Excellent Nishmembercollincode15 Sep '03 - 20:41 
GeneralRe: Excellent NisheditorNishant S15 Sep '03 - 21:20 
General1.5 problemsmemberAndreas Saurwein29 Aug '02 - 4:31 
GeneralRe: 1.5 problemseditorNishant S23 Dec '02 - 10:58 
GeneralRe: 1.5 problemsmemberusxue22 May '03 - 23:59 
GeneralDamn this is usefulmemberDavid Wulff29 Aug '02 - 4:17 
GeneralRe: Damn this is usefuleditorNishant S23 Dec '02 - 10:57 
GeneralwindowsizermemberPraetorian19 Aug '02 - 14:43 
GeneralRe: windowsizereditorNishant S25 Aug '02 - 23:43 
Generalwindowsizersussphilip kruger19 Aug '02 - 14:37 
GeneralWonderful ProgrammemberJosykatz18 Aug '02 - 0:22 
GeneralRe: Wonderful ProgrameditorNishant S18 Aug '02 - 15:51 
Generaldream-shotmemberchristoph braendle8 Aug '02 - 7:56 
GeneralRe: dream-shoteditorNishant S8 Aug '02 - 14:37 
GeneralRe: Use this app if you want to break your monitoreditorNishant S8 Aug '02 - 0:54 
GeneralRe: Use this app if you want to break your monitoreditorNishant S8 Aug '02 - 16:00 
GeneralRe: Use this app if you want to break your monitoreditorJames T. Johnson8 Aug '02 - 0:01 
GeneralRe: Use this app if you want to break your monitoreditorNishant S8 Aug '02 - 0:07 
GeneralWonderful!memberShog97 Aug '02 - 19:16 
GeneralRe: Wonderful!memberColin^Davies7 Aug '02 - 19:22 
GeneralRe: Wonderful!editorNishant S7 Aug '02 - 20:22 
GeneralRe: Wonderful!editorNishant S7 Aug '02 - 20:20 
GeneralRe: Wonderful!memberObliterator18 Dec '02 - 7:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 8 Aug 2002
Article Copyright 2002 by Nish Sivakumar
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid