Click to See Complete Forum and Search --> : API to WindowStyle
RoundCow
Dec 11th, 1999, 08:28 AM
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?
Frans C
Dec 11th, 1999, 08:44 AM
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.
atomsheep
Dec 11th, 1999, 09:28 AM
.. 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
Serge
Dec 11th, 1999, 10:36 PM
Frans C is on the right track. Here is an example:
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
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.