Place des fenêtres ds VB

mushu60 Messages postés 18 Date d'inscription mardi 11 octobre 2005 Statut Membre Dernière intervention 18 juin 2006 - 24 févr. 2006 à 13:39
mushu60 Messages postés 18 Date d'inscription mardi 11 octobre 2005 Statut Membre Dernière intervention 18 juin 2006 - 24 févr. 2006 à 13:59
Bonjour, c'est peut etre une peu futile, mais on ma demandé a ce que l'utilisateur puisse placer la fenetre ou il veut et que elle se retrouve a la meme place lorsqu'il relancera l'appli

est-ce possilbe ? merci d'avance

2 réponses

fohaf Messages postés 60 Date d'inscription vendredi 14 novembre 2003 Statut Membre Dernière intervention 6 septembre 2012 2
24 févr. 2006 à 13:56
C'est peut-être un peu lourd comme méthode mais tu peeut enregistrer sa position dans un fichier ini par exemple et la rappeler au démarrage.
Par exemple:

Private Declare Function WritePrivateProfileString Lib "kernel32" _
Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long


Private Declare Function GetPrivateProfileString Lib "kernel32" _
Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString _
As String, ByVal nSize As Long, ByVal lpFileName As String) As Long



Public Sub EcrireIni(stSection As String, stKey As String, stValeur As String, stFichier As String)
WritePrivateProfileString stSection, stKey, stValeur, stFichier
End Sub



Public Function LireIni(stSection As String, stKey As String, stFichier As String) As String
Dim stBuf As String, lgBuf As Long, lgRep As Long
stBuf = Space$(255)
lgBuf = 255
lgRep = GetPrivateProfileString(stSection, stKey, "", stBuf, lgBuf, stFichier)
LireIni = Left$(stBuf, lgRep)
End Function


Private Sub Form_Load()
Me.Width = LireIni("Form", "largeur", App.Path & "\position.ini")
Me.Height = LireIni("Form", "hauteur", App.Path & "\position.ini")
Me.Left = LireIni("Form", "posX", App.Path & "\position.ini")
Me.Top = LireIni("Form", "posY", App.Path & "\position.ini")
End Sub


Private Sub Form_Unload(Cancel As Integer)
Call EcrireIni("Form", "largeur", CStr(Me.Width), App.Path & "\position.ini")
Call EcrireIni("Form", "hauteur", CStr(Me.Height), App.Path & "\position.ini")
Call EcrireIni("Form", "posX", CStr(Me.Left), App.Path & "\position.ini")
Call EcrireIni("Form", "posy", CStr(Me.Top), App.Path & "\position.ini")
End Sub
0
mushu60 Messages postés 18 Date d'inscription mardi 11 octobre 2005 Statut Membre Dernière intervention 18 juin 2006
24 févr. 2006 à 13:59
ah...euh oui .... c'est sur c'est un peu lourd ... wouha
bah ecoute si c'est le seul moyen hein...je vais y passer si personne connait un autre moyen

Merci en tout cas ^^
0
Rejoignez-nous