petiflamand
Messages postés675Date d'inscriptionsamedi 31 mai 2003StatutMembreDernière intervention26 mai 2013
-
16 janv. 2012 à 09:56
Renfield
Messages postés17287Date d'inscriptionmercredi 2 janvier 2002StatutModérateurDernière intervention27 septembre 2021
-
16 janv. 2012 à 12:11
Bonjour à tous ,
J'utilise mon programme pour lire des pdf avec un écran en mode portrait a l'aide de la touche
CTRL & SHIFT & +
Je fait ceci
avec un timer qui vérifie toute les 5 secondes
If ecran_largeur <> Screen.Width And ecran_hauteur <> Screen.Height Then Me.WindowState = vbMaximized
et comme ça quand il détecte que la largeur est différente il fait ceci
If (Me.WindowState = 1) Then Exit Sub
For Each ctl In Me.Controls
If TypeOf ctl Is ComboBox Then
'Les comboboxes ont leur propriété Height en lecture seule
ctl.Move ctl.Left * Me.Width / lng, ctl.Top * Me.Height / lar, ctl.Width * Me.Width / lng
Else
If ExistProperty(ctl, "Width") And ExistProperty(ctl, "Height") Then
ctl.Move ctl.Left * Me.Width / lng, ctl.Top * Me.Height / lar, _
ctl.Width * Me.Width / lng, ctl.Height * Me.Height / lar
End If
End If
Next
lng = Me.Width
lar = Me.Height
y a t-il quelque chose de mieux que d'utilisé un timer toute les 5 secondes.
Private Sub Form_Unload(Cancel As Integer)
'pour remettre mon ecran qui etait au demarage
SetWindowLong hwnd, GWL_WNDPROC, oldWndProc
End Sub
déja j' ai une erreur utilisation incorrecte de l'opérateur pour
adressof
Dans un modul je declare
Public 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 oldWndProc As Long
Private 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
Private Const WM_DISPLAYCHANGE = &H7E
et je place ceci
[code=vb]Public Function WindowProc(ByVal hwnd As Long, ByVal msg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
If msg = WM_DISPLAYCHANGE Then
msgbox"aie petiflamand ça a changé"
End If
WindowProc = CallWindowProc(oldWndProc, hwnd, msg, wParam, lParam)
End Function
Renfield
Messages postés17287Date d'inscriptionmercredi 2 janvier 2002StatutModérateurDernière intervention27 septembre 202174 16 janv. 2012 à 12:11
Ton code semble bon...
je t'invite a passer par le module que je t'ai indiqué, ca simplifie l'emploi du subclassing et évite de faire planter VB betement.
j'ai testé ton WM_DISPLAYCHANGE ce matin, avec mon module, ca fonctionne...
je viens de faire le test à l'instant avec le code que tu m'a transmis, je n'ai pas le moindre problème...
(j'ai viré le MsgBox au profit d'un Debug.Print, moins problématique)