Вот такая интересная штука.
- Код: Выделить всё
Private Declare Function GetWindowText _
Lib "user32" Alias "GetWindowTextA" _
(ByVal hWnd As Long, ByVal lpString As String, _
ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength _
Lib "user32" Alias "GetWindowTextLengthA" _
(ByVal hWnd As Long) As Long
Private Declare Function GetNextWindow _
Lib "user32" Alias "GetWindow" (ByVal hWnd As Long, _
ByVal wFlag As Long) As Long
Private Const SW_MINIMIZE = 3
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type WINDOWPLACEMENT
Length As Long
flags As Long
showCmd As Long
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
Private Declare Function ClientToScreen Lib "user32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hWnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Private Declare Function SetWindowPlacement Lib "user32" (ByVal hWnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Dim Rectan As RECT
Private Sub Form_Load()
'Tip submitted by pyp99 (pyp99@hotmail.com)
Dim WinEst As WINDOWPLACEMENT
Dim rtn As Long
WinEst.Length = Len(WinEst)
'get the current window placement
rtn = GetWindowPlacement(Me.hWnd, WinEst)
Rectan = WinEst.rcNormalPosition
End Sub
Private Sub Command1_Click()
Dim WinEst As WINDOWPLACEMENT
Dim Punto As POINTAPI
Dim rtn As Long
'set the new min/max positions
Punto.x = Screen.Height
Punto.y = 100
'initialize the structure
WinEst.Length = Len(WinEst)
WinEst.showCmd = SW_MINIMIZE
WinEst.ptMinPosition = Punto
WinEst.ptMaxPosition = Punto
WinEst.rcNormalPosition = Rectan
'set the new window placement (minimized)
d = DLHFindWin(Me, "система ДубльГис", False)
rtn = SetWindowPlacement(d, WinEst)
End Sub
Private Function GetCaption(lhWnd As Long) As String
Dim sA As String, lLen As Long
lLen = GetWindowTextLength(lhWnd)
sA = String(lLen, 0)
GetWindowText lhWnd, sA, lLen + 1
GetCaption = sA
End Function
Private Function DLHFindWin(frm As Form, _
WinTitle As String, _
CaseSensitive As Boolean) As Long
Dim lhWnd As Long, sA As String
lhWnd = frm.hWnd
Do
DoEvents
If lhWnd = 0 Then Exit Do
If CaseSensitive = False Then
sA = LCase(GetCaption(lhWnd))
WinTitle = LCase(WinTitle)
Else
sA = GetCaption(lhWnd)
End If
If InStr(sA, WinTitle) Then
DLHFindWin = lhWnd
Exit Do
Else
DLHFindWin = 0
End If
lhWnd = GetNextWindow(lhWnd, 2)
Loop
End Function
Вот этой штукой я разварачиваю окно ДубльГИСА. Все замечательно. Но есть одно маленькое но... После двух разварачиваний оно, окно 2Гиса, перестаёт сварачиваться. Пробовал с другими программами - всё замечательно.
Подскажите где ошибка? или в чём тогда загвоздка?