为什么SetWindowLong没有使窗口最小化。下面是代码
Option Explicit
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const WS_MINIMIZE = &H20000000 '′°?ú×?D??ˉ
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lwnd As Long
lwnd = GetWindowLong(Me.hwnd, GWL_STYLE)
lwnd = lwnd Or WS_MINIMIZE
Call SetWindowLong(Me.hwnd, -16, lwnd)
End Sub
[解决办法]
http://baike.baidu.com/view/1080272.htm
......
指定的窗口数据是在缓存中保存的,因此在调用SetWindowLong之后再调用SetWindowPos函数才能使SetWindowLong函数所作的改变生效。
......
[解决办法]
GetWindowLong改变窗口样式,例如有没有最大化按钮,是否在任务栏显示按钮等.
[解决办法]
我记得在哪....看见过说,setwindowlong实现不了窗口最大最小化恢复等窗口操作
还是用 showwindow 吧
setwindowlong 修改窗口属性后一般需要刷新
[解决办法]
Option Explicit
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
Private Const WM_SYSCOMMAND As Long = &H112&
Private Const SC_MINIMIZE As Long = &HF020&
'最小化窗口
Private Sub Command1_Click()
Call SendMessage(Me.hwnd, WM_SYSCOMMAND, SC_MINIMIZE, ByVal 0&)
End Sub