Results 1 to 11 of 11

Thread: Resize the window of another running program

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474

    Resize the window of another running program

    Is there a way that I can check for existence of a special window outside of my program and if it exists resize it ? you know, I am talking about a window, not a process; in my case the main process may have multiple open windows each having a title, the only property of the window that I know.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    it's VB6 version .I didn't convert it to .NET thought.
    VB Code:
    1. Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    2. Const KEYEVENTF_KEYUP = &H2
    3. Const VK_LWIN = &H5B
    4.  
    5. 'in a form
    6. ' 77 is the character code for the letter 'M'
    7.     Call keybd_event(VK_LWIN, 0, 0, 0)
    8.     Call keybd_event(77, 0, 0, 0)
    9.     Call keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0)
    hope it works !

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Sorry, but i cant understand how to pass the window name and its new size to this API.

  4. #4
    Hyperactive Member RealNickyDude's Avatar
    Join Date
    Nov 2002
    Location
    Watching you through the hidden camera :o
    Posts
    435
    <removed, wrong post!)
    [vbcode]
    On Error GoTo Hell
    [/vbcode]:¬) Nicky : Why not try VBCodebook.NET.

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    just look at this , it might solve your problem.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    I dont want to minimize or maximize the window, i want to resize it for example have it 400x400.

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Lunatic3
    I dont want to minimize or maximize the window, i want to resize it for example have it 400x400.
    Is it working ? I mean mimizing and maxi.??

  8. #8
    New Member
    Join Date
    Oct 2002
    Location
    Manchester, UK
    Posts
    11

    Answer??

    I'm stuck with the same problem!! did you ever figure out how to do it?

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    No, I have not find a way yet, ofcourse I didnt have time to search for it in the past days and havent tried the method presented by Pirate yet, If i find a way i will post it here.

  10. #10
    New Member
    Join Date
    Oct 2002
    Location
    Manchester, UK
    Posts
    11

    Talking

    Sorted it Man!..

    Try this fella.. it works.

    'MODULE CODE
    '***********************************************
    Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

    Public Function SetWP(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
    SetWindowPos hwnd, hWndInsertAfter, x, y, cx, cy, wFlags
    End Function

    'FORM CODE
    '***********************************************
    Public Sub Command1_Click()
    'hwnd you need to find the handle of the application your wanting to resize.

    Module1.SetWP hwnd, 0, txtLeft, txtTop, txtWidthX, txtHeightY, 0
    End Sub

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Thanks man!
    Just you have to replace 'Long' with 'Integer' in your declarations and it works great

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width