Results 1 to 4 of 4

Thread: API to WindowStyle

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 1999
    Posts
    24

    Post

    i could never get myself to change the window style... i am just seeing what i can do, its obviosly no this. i tried.

    call sendmessage( awindow&, WS_MINIMIZE, ?, ?)

    what do i put in those ? marks

    was i even close to getting it right?

  2. #2
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Post

    SendMessage should send a WM_.... message, a Windows Message. I suppose the WS_MINIMIZE could be used with the SetWindowLong API, combined with a GWL_STYLE. But I think the easiest way to minimize a window outside your application is to use the CloseWindow API. For an example look at the message I posted a few minutes ago.

  3. #3
    Junior Member
    Join Date
    Apr 1999
    Location
    Sydney, NSW, Australia
    Posts
    22

    Post

    .. or you could try:

    Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    Private Const SW_HIDE = 0
    Private Const SW_MINIMIZE = 6
    Private Const SW_NORMAL = 1
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

    h=findwindow(vbnullstring,"API to windowstyle - vb q and a - microsoft internet explorer")
    showwindow h, SW_MINIMIZE

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Frans C is on the right track. Here is an example:

    Code:
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Const GWL_STYLE = (-16)
    Private Const WS_MINIMIZEBOX = &H20000
    
    Private Sub Command1_Click()
        Static b As Boolean
        
        HideShowMinimize Me.hWnd, b
        b = Not b
    End Sub
    
    Public Sub HideShowMinimize(hWnd, pShow As Boolean)
        Dim lStyle As Long
        
        lStyle = GetWindowLong(Me.hWnd, GWL_STYLE)
        If pShow Then
            lStyle = lStyle Or WS_MINIMIZEBOX
        Else
            lStyle = lStyle Xor WS_MINIMIZEBOX
        End If
        SetWindowLong Me.hWnd, GWL_STYLE, lStyle
    End Sub
    Every time you click the button it will either remove or add a Minimize Button.

    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


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