Can anyone give me a clue on how to adjust the size of an active window?
Printable View
Can anyone give me a clue on how to adjust the size of an active window?
If it in your app then its just changing the width and height properties but if its not your app then you need to use APIs. FindWindow to get the main window handle to that apps window to be resized. Then SetWindowLong or SetWindowPlacement or even SetWindowPos.
Search the forums as I have code examples.
If you put code in your resize event, you can force a minimum size by checking the size inside the event. If less than your set minimum (if me.width < 400 then me.width = 400) it resizes it.
There is a much more complex way involving subclassing the windows message handler that actually prevents the window from becoming smaller than the set size, but it is beyond the scope of my answer ;)
That won't work for other windows from other applications.
I think maybe he was replying to that other thread or had it on his mind :D
The ods are that its a third party app window in question which is why I posted both scenerios. The APIs are probablygoing to be the solution here.
never claimed it would... The question doesn't specify, so i chose one possible scenario and answered for it.
Robdog888, what other thread? If there are 2, merge them.
It was another recent thread on resizing a window but it was hell lord that was in it and not you. My mistake. Dont pay any attention to me tonight lol. (Except my quality posts).
^Yep, its a window opened by a VB app. To be more specific and to give you more light on my question, I have a code that opens a PuTTY window using 'WScript.shell'. I am successful in opening the window but what I want is for that window to have a specific size already instead of having to resize it manually everytime I open a new PuTTY window...
Thank you in advance.... :)
Yes, you will have to use the APIs I posted in #2 then.
I'll look into that.. thanks for the help... :)
I have yet to try them out but it looks like the appropriate APIs to use for my problems are the 'FindWindow' and 'SetWindowPos' API...
Is the 'GetActiveWindow' API a good alternative for 'FindWindow'?
BTW, FindWindow requires a class name, how should I know the class name of for example, a PuTTY window?
Use MS Spy++. Its a window finder tool that exposes the window heirarchy and class names etc.
I also found an API which is 'GetForegroundWindow' and tried that one... it worked somehow since it was able to change the puTTY window's position using 'SetWindowPos' API but the only problem is I still can't change its dimensions...why is that? Is the Putty window the one that has the problem? :confused:
are you able to change the window dimensions in any other fashion, such as dragging the borders?
^Yes, I can... that was the manual resizing I mentioned earlier... I want the window to already have a custom size so I don't have to adjust it everytime I open it... :)
here's another api to try:
[code]
Declare Function MoveWindow& Lib "user32" (ByVal hwnd As Long, ByVal x As Long, _
ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As _
Long)
Thanks, I tried it out but produces the same results as the 'SetWindowPos' API, it was only able to change the puTTY window's position... jeez, I'm really beginning to think the puTTY window is the problem... I'll try it with the command prompt and compare its results... :(
Or you could try SetWindowPlacement
I might be able to help if i had a little more info? For example: i am not familiar with the putty window. Is it a graphics program?
^It's a terminal window much like a command prompt window....