Results 1 to 3 of 3

Thread: Change window status

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    16

    Unhappy Change window status

    Hello,
    Let say I have a window (IE for instance) and I know its handle (hwnd). How can I do to change the status window:
    - active window
    - full screen window
    - miunimized window
    etc...

    I know I can do it using the shell command, but my program is already running, so I can't start it with shell...
    Is there some functions like setMinimized(hwnd) ????
    Thx for replying

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Change window status

    you would use the setwindowplacement api


    VB Code:
    1. Private Const SW_MINIMIZE = 6
    2. Private Type POINTAPI
    3.         x As Long
    4.         y As Long
    5. End Type
    6. Private Type RECT
    7.         Left As Long
    8.         Top As Long
    9.         Right As Long
    10.         Bottom As Long
    11. End Type
    12. Private Type WINDOWPLACEMENT
    13.         Length As Long
    14.         flags As Long
    15.         showCmd As Long
    16.         ptMinPosition As POINTAPI
    17.         ptMaxPosition As POINTAPI
    18.         rcNormalPosition As RECT
    19. End Type
    20. Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
    21. Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
    22. Private Declare Function SetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
    23. Dim Rectan As RECT
    24. Private Sub Form_Load()
    25.     'Tip submitted by pyp99 ([email protected])
    26.     Dim WinEst As WINDOWPLACEMENT
    27.     Dim rtn As Long
    28.     WinEst.Length = Len(WinEst)
    29.     'get the current window placement
    30.     rtn = GetWindowPlacement(Me.hwnd, WinEst)
    31.     Rectan = WinEst.rcNormalPosition
    32. End Sub
    33. Private Sub Command1_Click()
    34.     Dim WinEst As WINDOWPLACEMENT
    35.     Dim Punto As POINTAPI
    36.     Dim rtn As Long
    37.     'set the new min/max positions
    38.     Punto.x = 100
    39.     Punto.y = 100
    40.     'initialize the structure
    41.     WinEst.Length = Len(WinEst)
    42.     WinEst.showCmd = SW_MINIMIZE
    43.     WinEst.ptMinPosition = Punto
    44.     WinEst.ptMaxPosition = Punto
    45.     WinEst.rcNormalPosition = Rectan
    46.     'set the new window placement (minimized)
    47.     rtn = SetWindowPlacement(Me.hwnd, WinEst)
    48. End Sub


    from allapi

    rgds pete

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    16

    Re: Change window status

    Thx a lot for replying so fast, it works fine!!!!!!!!

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