Prikazi cijelu temu 27.03.2012 17:01
roko Van mreze
Clan
Registrovan od:02.02.2009
Lokacija:Rijeka


Predmet:Re: Windows7 zaštita(Stara Nova Tema)
' A user-defined type to store the window dimensions.
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

' Test which version of VBA you are using.
#If VBA7 Then
' API function to locate a window.
Declare PtrSafe Function FindWindow Lib "user32" _
Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As LongPtr

' API function to retrieve a window's dimensions.
Declare PtrSafe Function GetWindowRect Lib "user32" ( _
ByVal hwnd As LongPtr, _
lpRect As RECT) As Long

#Else
' API function to locate a window.
Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

' API function to retrieve a window's dimensions.
Declare Function GetWindowRect Lib "user32" ( _
ByVal hwnd As Long, _
lpRect As RECT) As Long
#End If

Sub DisplayExcelWindowSize()
Dim hwnd As Long, uRect As RECT

' Get the handle identifier of the main Excel window.
hwnd = FindWindow("XLMAIN", Application.Caption)

' Get the window's dimensions into the RECT UDT.
GetWindowRect hwnd, uRect

' Display the result.
MsgBox "The Excel window has these dimensions:" & _
vbCrLf & " Left: " & uRect.Left & _
vbCrLf & " Right: " & uRect.Right & _
vbCrLf & " Top: " & uRect.Top & _
vbCrLf & " Bottom: " & uRect.Bottom & _
vbCrLf & " Width: " & (uRect.Right - uRect.Left) & _
vbCrLf & " Height: " & (uRect.Bottom - uRect.Top)

End Sub