Resizing PuTTY

So today in my down time at work, I thought it would be useful to make a ’session manager’ for PuTTY windows.  There are situations where it is necessary to ssh into 15-30 servers, where scripting the task isn’t practical.  Setting up these windows always take A LONG time.  Then if something else happens, you have to close them all out, setup the windows…blah blah.  Anyway, free time is free time.

So, I turn to vba again (i really don’t like the environment, but currently hands are tied).   Sounds easy enough.  Who doesn’t test their window movements and resizing with notepad.  I know I do.  Everything worked fine.  Then I try it with PuTTY.  Movement is fine, resizing is not.  Since I’m forced to write in VBA, you can probably guess that I didn’t have Spy++ at my disposal (which was definitely too bad).  Anyway, I was forced to download the source code and plunge through the main window procedure to find the handled resize events.  Turns out, i had to use WM_ENTERSIZEMOVE and WM_EXITSIZEMOVE to surround my resizing messages.  Notepad, and most other applications don’t require this.  The reason PuTTY requires it is because they resize based on rows and columns (there are other options, but seem ridiculous).  Regardless, these two messages weren’t the first place in their code I jumped to, and it took way to long for me to figure that one out.


Call SendMessage(hwnd,WM_ENTERSIZEMOVE,0,0)
rst = SetWindowPos(hwnd,...)
Call SendMessage(hwnd,WM_EXITSIZEMOVE,0,0)
Just to prove a previous point

Just to prove a previous point

So I’m guessing that I should start wrapping my resizing and movement messages inside these guys.  When you watch it in Spy++, they always get sent.  You never know when an application might actually need them.

Leave a Comment