- 'Il faut, 4 textbox (Text1, Text2, Text3, Text4) et 2 CommandButton (Command1, Command2)
-
- Option Explicit
- 'déclaration de l'api et de ses constantes
- Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
- Const SPI_GETWORKAREA = 48
- Const SPI_SETWORKAREA = 47
-
- 'déclaration de 2 variables types qui récupereront la taille de la zone de travail
- Private Type RECT
- Left As Long
- Top As Long
- Right As Long
- Bottom As Long
- End Type
- Dim RCold As RECT
- Dim RCnew As RECT
-
- Private Sub Command1_Click()
- 'on récupere la taille de la zone de travail et si l'api bug (<>1), on le signal
- If SystemParametersInfo(SPI_GETWORKAREA, vbNull, RCold, 0) = 1 Then
- With RCold
- Text1.Text = .Left
- Text2.Text = .Top
- Text3.Text = .Right
- Text4.Text = .Bottom
- End With
- Else
- MsgBox "Une erreur est survenue lors de la récupération des données !", vbOKOnly + vbMsgBoxSetForeground + vbCritical, "Erreur"
- End If
- End Sub
-
- Private Sub Command2_Click()
- 'on modifie la taille de la zone de travail apres verifier la requete de l'utilisateur, en cas "d'accident" !!
- If MsgBox("Etes-vous sur de vouloir modifier la zone de travail ??" & vbCrLf & "Une mauvaise manipulation peut entrainer de graves conséquences !!", vbQuestion + vbYesNo + vbMsgBoxSetForeground, "Etes-vous sur ?") = vbYes Then
- With RCnew
- .Left = Text1.Text
- .Top = Text2.Text
- .Right = Text3.Text
- .Bottom = Text4.Text
- End With
- Call SystemParametersInfo(SPI_SETWORKAREA, vbNull, RCnew, 0)
- End If
- End Sub
-
- Private Sub Form_Load()
- Command1_Click
- End Sub
'Il faut, 4 textbox (Text1, Text2, Text3, Text4) et 2 CommandButton (Command1, Command2)
Option Explicit
'déclaration de l'api et de ses constantes
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
Const SPI_GETWORKAREA = 48
Const SPI_SETWORKAREA = 47
'déclaration de 2 variables types qui récupereront la taille de la zone de travail
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Dim RCold As RECT
Dim RCnew As RECT
Private Sub Command1_Click()
'on récupere la taille de la zone de travail et si l'api bug (<>1), on le signal
If SystemParametersInfo(SPI_GETWORKAREA, vbNull, RCold, 0) = 1 Then
With RCold
Text1.Text = .Left
Text2.Text = .Top
Text3.Text = .Right
Text4.Text = .Bottom
End With
Else
MsgBox "Une erreur est survenue lors de la récupération des données !", vbOKOnly + vbMsgBoxSetForeground + vbCritical, "Erreur"
End If
End Sub
Private Sub Command2_Click()
'on modifie la taille de la zone de travail apres verifier la requete de l'utilisateur, en cas "d'accident" !!
If MsgBox("Etes-vous sur de vouloir modifier la zone de travail ??" & vbCrLf & "Une mauvaise manipulation peut entrainer de graves conséquences !!", vbQuestion + vbYesNo + vbMsgBoxSetForeground, "Etes-vous sur ?") = vbYes Then
With RCnew
.Left = Text1.Text
.Top = Text2.Text
.Right = Text3.Text
.Bottom = Text4.Text
End With
Call SystemParametersInfo(SPI_SETWORKAREA, vbNull, RCnew, 0)
End If
End Sub
Private Sub Form_Load()
Command1_Click
End Sub