événement rotation d'écran introuvable

dmc

XLDnaute Occasionnel
bonjour à tous les excelliens... et excelliennes bien sur.
J'ai eu beau chercher, je n'ai pas trouvé, à ma grande surprise, de fil relatif à l'interception de l’événement rotation d'écran.
Mon besoin est de savoir, au sein de VBA, que la tablette tactile passe de portrait à paysage ou le contraire, afin de redimensionner les colonnes de la feuille excel.
existe-t-il une solution ?
merci d'avance.
 

dmc

XLDnaute Occasionnel
Re : événement rotation d'écran introuvable

salut tatiak... le crak
tu as répondu en un temps record, moi j'étais parti manger!
mais : je pense que tu m'as envoyé un code vb.net et là moi je suis pas crak, patraque, pas Tatiak, voire patatrac du tout.
serait-ce braque de te demander des explications sans que tu... craques ?
 

dmc

XLDnaute Occasionnel
Re : événement rotation d'écran introuvable

effectivement pour le mp mais 8 ans plus tard il faut juste que je me réorganise !
par ailleurs j ai testé ta proposition :
ma demande consistait à détecter la rotation, même sans action de l'utilisateur, c'est pour cela que je parlais d'événement.
si comme je pense l'événement rotation n'existe pas, peut-être qu'il existe un moyen d'intercepter la variation de valeur d'une variable, laquelle pourrait être celle de la largeur d'écran.
je crois avoir lu quelque chose dans ce sens qu'en penses-tu?
 

dmc

XLDnaute Occasionnel
Re : événement rotation d'écran introuvable

[h=4]j'ai repris tes recherches tatiak et je suis tombé sur le même site microsoft que toi : Ce lien n'existe plus
ci-après les explications qu'ils donnent et dont je ne sais pas quoi faire vu que je ne pratique pas les userform.
si quelqu'un pouvait mettre ça sur un fichier excel cela me dépannerait[/h]To detect screen rotation in applications written in Visual Basic 6.0, you hook the WindowProc function to listen for a Ce lien n'existe plus message. You then use the lParam parameter of the WindowProc function to retrieve the height and width of the full screen, as in the previous Visual Basic 6.0 example. Finally, you unhook, restoring the default WindowProc function. The following Visual Basic 6.0 example illustrates this process.
The form's code:




Private Sub Form_Load() gHW = Me.hwnd HookEnd SubPrivate Sub Form_Terminate() UnhookEnd Sub



The module's code:




Declare Function CallWindowProc Lib "user32" Alias _"CallWindowProcA" (ByVal lpPrevWndFunc As Long, _ByVal hwnd As Long, ByVal Msg As Long, _ByVal wParam As Long, ByVal lParam As Long) As LongDeclare Function SetWindowLong Lib "user32" Alias _"SetWindowLongA" (ByVal hwnd As Long, _ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPublic Const GWL_WNDPROC = -4Public Const WM_DISPLAYCHANGE = 126Global lpPrevWndProc As LongGlobal gHW As LongPublic Sub Hook() lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, _ AddressOf WindowProc)End SubPublic Sub Unhook() Dim temp As Long temp = SetWindowLong(gHW, GWL_WNDPROC, _ lpPrevWndProc)End SubFunction WindowProc(ByVal hw As Long, ByVal uMsg As _Long, ByVal wParam As Long, ByVal lParam As Long) As _Long 'Activated when display changes If uMsg = WM_DISPLAYCHANGE Then 'Separate the width and height and then 'check to see if screen width is greater than screen height If lParam Mod &H10000 > lParam \ &H10000 Then 'Run the application in landscape, for example: MsgBox "Run in landscape." Else 'Run the application in portrait, for example: MsgBox "Run in portrait." End If End If 'Pass windows messages on to the default WindowProc WindowProc = CallWindowProc(lpPrevWndProc, hw, _ uMsg, wParam, lParam)End Function




 

dmc

XLDnaute Occasionnel
Re : événement rotation d'écran introuvable

oups les sauts de lgne ayant disparu, je recommence en plus lisible :
The form's code:
Private Sub Form_Load()
gHW = Me.hwnd
Hook
End Sub

Private Sub Form_Terminate()
Unhook
End Sub

The module's code:
Declare Function CallWindowProc Lib "user32" Alias _
"CallWindowProcA" (ByVal lpPrevWndFunc As Long, _
ByVal hwnd As Long, ByVal Msg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Public Const GWL_WNDPROC = -4
Public Const WM_DISPLAYCHANGE = 126
Global lpPrevWndProc As Long
Global gHW As Long

Public Sub Hook()
lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, _
AddressOf WindowProc)
End Sub

Public Sub Unhook()
Dim temp As Long
temp = SetWindowLong(gHW, GWL_WNDPROC, _
lpPrevWndProc)
End Sub

Function WindowProc(ByVal hw As Long, ByVal uMsg As _
Long, ByVal wParam As Long, ByVal lParam As Long) As _
Long
'Activated when display changes
If uMsg = WM_DISPLAYCHANGE Then
'Separate the width and height and then
'check to see if screen width is greater than screen height
If lParam Mod &H10000 > lParam \ &H10000 Then
'Run the application in landscape, for example:
MsgBox "Run in landscape."
Else
'Run the application in portrait, for example:
MsgBox "Run in portrait."
End If
End If
'Pass windows messages on to the default WindowProc
WindowProc = CallWindowProc(lpPrevWndProc, hw, _
uMsg, wParam, lParam)
End Function

merci pour vos réponses
 

dmc

XLDnaute Occasionnel
Re : événement rotation d'écran introuvable

Bonjour à tous
Visiblement ça ne passionne personne de détecter la rotation de l'écran. Pourtant à l'heure des tablettes tactiles, c'est le genre d'événement que nous serons de plus en plus tenus de maitriser.
Le script que j'ai joint précédemment est censé détecter cet événement, problablement via WM_DISPLAYCHANGE mais je ne sais pas le mettre en oeuvre.
Quelqu'un peut-il m'aider ?
Merci d'avance
 

Statistiques des forums

Discussions
312 305
Messages
2 087 070
Membres
103 454
dernier inscrit
Marion devaux