Prob dans le listage des fentres actives

Résolu
CCJ Messages postés 565 Date d'inscription mercredi 19 mai 2004 Statut Membre Dernière intervention 30 avril 2008 - 12 févr. 2005 à 19:14
cs_CanisLupus Messages postés 3757 Date d'inscription mardi 23 septembre 2003 Statut Membre Dernière intervention 13 mars 2006 - 16 févr. 2005 à 20:47
Voila le code :
Private Declare Function GetWindowTextLength Lib "USER32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetForegroundWindow Lib "USER32" () As Long
Private Declare Function BringWindowToTop Lib "USER32" (ByVal hwnd As Long) As Long
Private Declare Function SetWindowText Lib "USER32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Declare Function GetWindowText Lib "USER32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowLong Lib "USER32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "USER32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Declare Function SetLayeredWindowAttributes Lib "USER32" _
(ByVal hwnd As Long, ByVal crKey As Long, _
ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2
Private hwnd1 As Long


Public Sub MakeWindowTransparent(ByVal hwnd As Long, ByVal alphaAmount As Byte)
Dim lStyle As Long
lStyle = GetWindowLong(hwnd, GWL_EXSTYLE)
lStyle = lStyle Or WS_EX_LAYERED
SetWindowLong hwnd, GWL_EXSTYLE, lStyle
SetLayeredWindowAttributes hwnd, 0, alphaAmount, LWA_ALPHA
End Sub


Private Sub Fenetre_Timer()
Dim PP As Long
Dim Deja As Boolean
Dim Text As String
Dim Length As Long
Deja = False
PP = GetForegroundWindow
For i = 1 To Fenetres.ListCount - 1
If Fenetres.List(i) = PP Then
Deja = True
End If
Next i
If Deja = False Then
Fenetres.AddItem PP
Length = GetWindowTextLength(PP)
List1.AddItem GetWindowText(PP, Text, Length + 1)
End If
End Sub


Private Sub Form_Load()
Open App.Path & "" & "Parametre.zvx" For Input As #2
Input #2, i
Close #2
Call VirusManModifications.MakeWindowTransparent(Me.hwnd, i)
End Sub


Private Sub Invisible_Click()
If Transparance.Text <> "" Then
Call MakeWindowTransparent(Fenetres.Text, Transparance.Text)
Else
MsgBox "Erreur texte vide !", vbCritical, "Erreur"
End If
End Sub


Private Sub Premier_Plan_Click()
If Premier_Plan.Caption = "Garder au premier plan" Then
If Frequence.Text <> "" Then
Premier_Plan.Caption = "Arreter"
hwnd1 = Fenetres.Text
PremierPlan.Interval = Frequence.Text
PremierPlan.Enabled = True
Else
MsgBox "Erreur texte vide !", vbCritical, "Erreur"
End If
Else
Premier_Plan.Caption = "Garder au premier plan"
PremierPlan.Enabled = False
End If
End Sub


Private Sub PremierPlan_Timer()
BringWindowToTop hwnd1
End Sub


Private Sub Renommer_Click()
If Nom.Text <> "" Then
SetWindowText Fenetres.Text, Nom.Text
Else
MsgBox "Erreur textet vide !", vbCritical, "Erreur"
End If
End Sub

dans ma liste de nom , y a que des zero (0) comme nom
help!
VirusMan
une idée est un chose ,la dire en est une autre

5 réponses

cs_CanisLupus Messages postés 3757 Date d'inscription mardi 23 septembre 2003 Statut Membre Dernière intervention 13 mars 2006 20
16 févr. 2005 à 20:47
Alors essaie :

Text = String(GetWindowTextLength(PP) + 1, Chr$(0))
GetWindowText PP, Text, Len(Text)
List1.AddItem Text

J'ai testé, ça marche chez moi.

Loup Gris
3
cs_Jack Messages postés 14006 Date d'inscription samedi 29 décembre 2001 Statut Modérateur Dernière intervention 28 août 2015 79
12 févr. 2005 à 20:27
Salut
La prochaine fois, évite de tout copier coller, ça sert à rien. D'autant que ta question n'est pas assez précise.
Je pense que c'est ta fonction GetWindowText qui ne te renvoie rien ?
As-tu débuggé pour le savoir ?
Repose ta question en ciblant les quelques lignes qui posent problème, parce que là, tu fais peur à tout le monde (personne n'a vraiment le temps d'analyser toutes tes lignes)

Vala
Jack
NB : Je ne répondrai pas aux messages privés

Le savoir est la seule matière qui s'accroit quand on la partage. (Socrate)
0
CCJ Messages postés 565 Date d'inscription mercredi 19 mai 2004 Statut Membre Dernière intervention 30 avril 2008 1
13 févr. 2005 à 00:32
Non y a pas de message d'erreur sauf que au lieu de metre le nom dela fenetres dans le liste ba il met 0

VirusMan
une idée est un chose ,la dire en est une autre
0
cs_CanisLupus Messages postés 3757 Date d'inscription mardi 23 septembre 2003 Statut Membre Dernière intervention 13 mars 2006 20
13 févr. 2005 à 12:49
Salut,

Suis un peu OK avec jack, mais bon, à la lecture rapide de ton code j'ai remarqué un prob avec ton api GetWindowText.
En codant :
List1.AddItem GetWindowText(PP, Text, Length + 1)
tu ne fais qu'ajouter dans ta liste le numéro d'erreur de la fonction.
Essaie plutôt ça :

GetWindowText PP, Text, Length + 1
List1.AddItem Split(Text, Chr$(0))(0)

Cordialement, CanisLupus
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
CCJ Messages postés 565 Date d'inscription mercredi 19 mai 2004 Statut Membre Dernière intervention 30 avril 2008 1
16 févr. 2005 à 10:42
dsl mé ca marche pas , ya pu rien d'ecrit dans ma list , au lieu d'ajouter 0 ca ajoute rien

VirusMan
une idée est un chose ,la dire en est une autre
0
Rejoignez-nous