Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Jacques93
Bonjour Patrice Henrio Patrice Henrio a écrit :
Est-il possible en vbA sous excel de récupérer la taille de l'écran pour adapter la taille d'une forme à celui-ci ?
Comme sous VBA je n'ai pas vu d'équivalent à Screen.Width et Screen.Height de VB6, on peut utiliser l'API GetSystemMetrics.
Dans le code du UserForm :
Option Explicit Private Declare Function GetSystemMetrics _ Lib "user32" (ByVal nIndex As Long) As Long Private Const SM_CXSCREEN = 0 Private Const SM_CYSCREEN = 1
Private Declare Function GetWindowRect _ Lib "user32" (ByVal hwnd As Long, _ lpRect As RECT) As Long
Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type
Private Declare Function FindWindow _ Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long
Private Declare Function SetWindowPos _ Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _ ByVal x As Long, ByVal Y As Long, _ ByVal Cx As Long, ByVal Cy As Long,_ ByVal wFlags As Long) As Long
' Si on ne veut pas masquer la barre de tâches ' en supposant quelle soit en bas de l'écran lResult = FindWindow("Shell_traywnd", "") If lResult > 0 Then GetWindowRect lResult, rc h = rc.Bottom - rc.Top End If SetWindowPos hwnd, HWND_TOP, 0, 0, Cx, Cy - h, SWP_SHOWWINDOW End Sub
-- Cordialement,
Jacques.
Bonjour Patrice Henrio
Patrice Henrio a écrit :
Est-il possible en vbA sous excel de récupérer la taille de l'écran pour
adapter la taille d'une forme à celui-ci ?
Comme sous VBA je n'ai pas vu d'équivalent à Screen.Width et
Screen.Height de VB6, on peut utiliser l'API GetSystemMetrics.
Dans le code du UserForm :
Option Explicit
Private Declare Function GetSystemMetrics _
Lib "user32" (ByVal nIndex As Long) As Long
Private Const SM_CXSCREEN = 0
Private Const SM_CYSCREEN = 1
Private Declare Function GetWindowRect _
Lib "user32" (ByVal hwnd As Long, _
lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetWindowPos _
Lib "user32" (ByVal hwnd As Long,
ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal Y As Long, _
ByVal Cx As Long, ByVal Cy As Long,_
ByVal wFlags As Long) As Long
' Si on ne veut pas masquer la barre de tâches
' en supposant quelle soit en bas de l'écran
lResult = FindWindow("Shell_traywnd", "")
If lResult > 0 Then
GetWindowRect lResult, rc
h = rc.Bottom - rc.Top
End If
SetWindowPos hwnd, HWND_TOP, 0, 0, Cx, Cy - h, SWP_SHOWWINDOW
End Sub
Est-il possible en vbA sous excel de récupérer la taille de l'écran pour adapter la taille d'une forme à celui-ci ?
Comme sous VBA je n'ai pas vu d'équivalent à Screen.Width et Screen.Height de VB6, on peut utiliser l'API GetSystemMetrics.
Dans le code du UserForm :
Option Explicit Private Declare Function GetSystemMetrics _ Lib "user32" (ByVal nIndex As Long) As Long Private Const SM_CXSCREEN = 0 Private Const SM_CYSCREEN = 1
Private Declare Function GetWindowRect _ Lib "user32" (ByVal hwnd As Long, _ lpRect As RECT) As Long
Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type
Private Declare Function FindWindow _ Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long
Private Declare Function SetWindowPos _ Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _ ByVal x As Long, ByVal Y As Long, _ ByVal Cx As Long, ByVal Cy As Long,_ ByVal wFlags As Long) As Long
' Si on ne veut pas masquer la barre de tâches ' en supposant quelle soit en bas de l'écran lResult = FindWindow("Shell_traywnd", "") If lResult > 0 Then GetWindowRect lResult, rc h = rc.Bottom - rc.Top End If SetWindowPos hwnd, HWND_TOP, 0, 0, Cx, Cy - h, SWP_SHOWWINDOW End Sub
-- Cordialement,
Jacques.
Patrice Henrio
Merci, je désespérais d'une réponse. Je vais tester ça dés que possible.
"Jacques93" a écrit dans le message de news: u%23AF5$
Bonjour Patrice Henrio Patrice Henrio a écrit :
Est-il possible en vbA sous excel de récupérer la taille de l'écran pour adapter la taille d'une forme à celui-ci ?
Comme sous VBA je n'ai pas vu d'équivalent à Screen.Width et Screen.Height de VB6, on peut utiliser l'API GetSystemMetrics.
Dans le code du UserForm :
Option Explicit Private Declare Function GetSystemMetrics _ Lib "user32" (ByVal nIndex As Long) As Long Private Const SM_CXSCREEN = 0 Private Const SM_CYSCREEN = 1
Private Declare Function GetWindowRect _ Lib "user32" (ByVal hwnd As Long, _ lpRect As RECT) As Long
Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type
Private Declare Function FindWindow _ Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long
Private Declare Function SetWindowPos _ Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _ ByVal x As Long, ByVal Y As Long, _ ByVal Cx As Long, ByVal Cy As Long,_ ByVal wFlags As Long) As Long
' Si on ne veut pas masquer la barre de tâches ' en supposant quelle soit en bas de l'écran lResult = FindWindow("Shell_traywnd", "") If lResult > 0 Then GetWindowRect lResult, rc h = rc.Bottom - rc.Top End If SetWindowPos hwnd, HWND_TOP, 0, 0, Cx, Cy - h, SWP_SHOWWINDOW End Sub
-- Cordialement,
Jacques.
Merci, je désespérais d'une réponse.
Je vais tester ça dés que possible.
"Jacques93" <jacques.le-gocNO@PUBwouanadoo.fr> a écrit dans le message de
news: u%23AF5$meFHA.1044@TK2MSFTNGP10.phx.gbl...
Bonjour Patrice Henrio
Patrice Henrio a écrit :
Est-il possible en vbA sous excel de récupérer la taille de l'écran pour
adapter la taille d'une forme à celui-ci ?
Comme sous VBA je n'ai pas vu d'équivalent à Screen.Width et Screen.Height
de VB6, on peut utiliser l'API GetSystemMetrics.
Dans le code du UserForm :
Option Explicit
Private Declare Function GetSystemMetrics _
Lib "user32" (ByVal nIndex As Long) As Long
Private Const SM_CXSCREEN = 0
Private Const SM_CYSCREEN = 1
Private Declare Function GetWindowRect _
Lib "user32" (ByVal hwnd As Long, _
lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetWindowPos _
Lib "user32" (ByVal hwnd As Long,
ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal Y As Long, _
ByVal Cx As Long, ByVal Cy As Long,_
ByVal wFlags As Long) As Long
' Si on ne veut pas masquer la barre de tâches
' en supposant quelle soit en bas de l'écran
lResult = FindWindow("Shell_traywnd", "")
If lResult > 0 Then
GetWindowRect lResult, rc
h = rc.Bottom - rc.Top
End If
SetWindowPos hwnd, HWND_TOP, 0, 0, Cx, Cy - h, SWP_SHOWWINDOW
End Sub
Merci, je désespérais d'une réponse. Je vais tester ça dés que possible.
"Jacques93" a écrit dans le message de news: u%23AF5$
Bonjour Patrice Henrio Patrice Henrio a écrit :
Est-il possible en vbA sous excel de récupérer la taille de l'écran pour adapter la taille d'une forme à celui-ci ?
Comme sous VBA je n'ai pas vu d'équivalent à Screen.Width et Screen.Height de VB6, on peut utiliser l'API GetSystemMetrics.
Dans le code du UserForm :
Option Explicit Private Declare Function GetSystemMetrics _ Lib "user32" (ByVal nIndex As Long) As Long Private Const SM_CXSCREEN = 0 Private Const SM_CYSCREEN = 1
Private Declare Function GetWindowRect _ Lib "user32" (ByVal hwnd As Long, _ lpRect As RECT) As Long
Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type
Private Declare Function FindWindow _ Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long
Private Declare Function SetWindowPos _ Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _ ByVal x As Long, ByVal Y As Long, _ ByVal Cx As Long, ByVal Cy As Long,_ ByVal wFlags As Long) As Long
' Si on ne veut pas masquer la barre de tâches ' en supposant quelle soit en bas de l'écran lResult = FindWindow("Shell_traywnd", "") If lResult > 0 Then GetWindowRect lResult, rc h = rc.Bottom - rc.Top End If SetWindowPos hwnd, HWND_TOP, 0, 0, Cx, Cy - h, SWP_SHOWWINDOW End Sub