Bonjour à tous,

Je m'adresse à vous en espèrent trouver de charmants membres de DVP pour m'aider à comprendre un code.
J'ai eu besoin récemment d'utiliser un InputBox de type mot de passe (donc avec caractères masqués pendant la saisie)
Ne sachant pas vraiment m'y prendre et ne voulant pas réinventer la roue (surtout si c'est pour faire une roue carré avec mes connaissance ) j'ai trouvé un code sur le net http://www.office-loesung.de/ftopic74191_0_0_asc.php

Ce dernier fonctionne très bien mais j'ai un peu de mal à le comprendre.
En cherchant je suis tombé sur ce tuto de Anthony DE DECKER qui m'a déjà beaucoup aider dans ma compréhension du code mais c'est encore un peu flou.

Si un expert de passage peut m'aider encore à avancer dans la compréhension du code j'en serais ravi.

Voila le code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Option Explicit
    '-----------------------------+
    '   API de gestion des Hook   |
    '-----------------------------+
Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
 
Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
 
Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
'--------------------------------------------------------------------------------------------------
 
    '----------------------------------------------+
    '   API Envoie de message avec controles spe   |
    '----------------------------------------------+
Private Declare Function SendDlgItemMessage Lib "user32" Alias "SendDlgItemMessageA" (ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'--------------------------------------------------------------------------------------------------
 
    '----------------------------------------+
    '   API  Donne la classe de la fenêtre   |
    '----------------------------------------+
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
'--------------------------------------------------------------------------------------------------
 
Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
 
Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
 
Private Const EM_SETPASSWORDCHAR = &HCC
Private Const WH_CBT = 5
Private Const HCBT_ACTIVATE = 5
Private Const HC_ACTION = 0
Private hHook As Long
 
Public Function NewProc(ByVal lngCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Dim RetVal
    Dim strClassName$, lngBuffer&
        If lngCode < HC_ACTION Then
            NewProc = CallNextHookEx(hHook, lngCode, wParam, lParam)
            Exit Function
        End If
        strClassName = String$(256, " ")
        lngBuffer = 255
         If lngCode = HCBT_ACTIVATE Then
            RetVal = GetClassName(wParam, strClassName, lngBuffer)
            If Left$(strClassName, RetVal) = "#32770" Then
                SendDlgItemMessage wParam, &H1324, EM_SETPASSWORDCHAR, Asc("*"), &H0
            End If
         End If
    CallNextHookEx hHook, lngCode, wParam, lParam
End Function
 
Public Function InputBoxDK(Prompt, Optional Title, Optional Default, Optional XPos, Optional YPos, Optional HelpFile, Optional Context) As String
    Dim lngModHwnd&, lngThreadID&
        lngThreadID = GetCurrentThreadId
        lngModHwnd = GetModuleHandle(vbNullString)
        hHook = SetWindowsHookEx(WH_CBT, AddressOf NewProc, lngModHwnd, lngThreadID)
            InputBoxDK = InputBox(Prompt, Title, Default, XPos, YPos, HelpFile, Context)
        UnhookWindowsHookEx hHook
End Function
Merci d'avance et bonne journée à tous.

PS : Une source des API disponibles avec Windows ainsi que leurs descriptions me serais aussi utile (j'ai un peu de mal à en trouver)