|
-
Jul 9th, 2007, 08:25 PM
#1
Thread Starter
Lively Member
Changing the size of an opened window
Can anyone give me a clue on how to adjust the size of an active window?
-
Jul 9th, 2007, 10:22 PM
#2
Re: Changing the size of an opened 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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 9th, 2007, 10:35 PM
#3
Re: Changing the size of an opened window
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
-
Jul 9th, 2007, 10:37 PM
#4
Re: Changing the size of an opened window
That won't work for other windows from other applications.
-
Jul 9th, 2007, 10:40 PM
#5
Re: Changing the size of an opened window
I think maybe he was replying to that other thread or had it on his mind 
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 9th, 2007, 10:50 PM
#6
Re: Changing the size of an opened window
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.
-
Jul 9th, 2007, 10:53 PM
#7
Re: Changing the size of an opened window
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).
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 9th, 2007, 11:00 PM
#8
Thread Starter
Lively Member
^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....
-
Jul 9th, 2007, 11:04 PM
#9
Re: Changing the size of an opened window
Yes, you will have to use the APIs I posted in #2 then.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 10th, 2007, 12:47 AM
#10
Thread Starter
Lively Member
Re: Changing the size of an opened window
I'll look into that.. thanks for the help...
-
Jul 10th, 2007, 09:15 PM
#11
Thread Starter
Lively Member
Re: Changing the size of an opened window
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...
-
Jul 10th, 2007, 09:57 PM
#12
Thread Starter
Lively Member
Re: Changing the size of an opened window
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?
-
Jul 11th, 2007, 12:25 AM
#13
Re: Changing the size of an opened window
Use MS Spy++. Its a window finder tool that exposes the window heirarchy and class names etc.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 11th, 2007, 07:42 PM
#14
Thread Starter
Lively Member
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?
-
Jul 11th, 2007, 07:50 PM
#15
Re: Changing the size of an opened window
are you able to change the window dimensions in any other fashion, such as dragging the borders?
-
Jul 11th, 2007, 08:24 PM
#16
Thread Starter
Lively Member
^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...
-
Jul 11th, 2007, 10:18 PM
#17
Re: Changing the size of an opened window
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)
-
Jul 12th, 2007, 10:35 PM
#18
Thread Starter
Lively Member
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...
-
Jul 12th, 2007, 10:50 PM
#19
Re: Changing the size of an opened window
Or you could try SetWindowPlacement
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 12th, 2007, 11:26 PM
#20
Re: Changing the size of an opened window
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?
-
Jul 14th, 2007, 09:59 PM
#21
Thread Starter
Lively Member
Re: Changing the size of an opened window
^It's a terminal window much like a command prompt window....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|