|
-
Feb 25th, 2006, 05:43 AM
#1
Thread Starter
Hyperactive Member
change another window's size
Can I change another window's width and height from my VB application If I know the caption on that window?
Thanks
DOK OCK : "The power of .net in the palm of my hand, nothing will stand in my way. Nothing." 
-
Feb 25th, 2006, 06:08 AM
#2
Frenzied Member
Re: change another window's size
Yes you can
VB Code:
' Code on Form1
Form2.Show
Form2.Width = Form2.Width - 500
Form2.Height = Form2.Height - 500
oh1mie/Vic

-
Feb 25th, 2006, 06:14 AM
#3
Frenzied Member
Re: change another window's size
With caption name
VB Code:
' Code on Form1
Dim strCaption As String
Dim MyObject As Form
Form2.Show
strCaption = "Form2"
For Each MyObject In Forms
If MyObject.Name = strCaption Then
MyObject.Width = MyObject.Width - 500
MyObject.Height = MyObject.Height - 500
Exit For
End If
Next
oh1mie/Vic

-
Feb 25th, 2006, 08:03 AM
#4
Re: change another window's size
If you want to change the size of a external applications window then:
If you only know the caption (not the class) then you'll have to enumerate through the windows using EnumWindows, and check the window caption using GetWindowText, until you find the right one.
If you know the window class as well as the caption then you can use FindWindow to get the handle.
Once you've got the handle of the window you can use SetWindowPlacement or MoveWindow (and there are probably others) to change the windows position and size.
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
|