I have been studying a coding example in a magazine and believe I understand all that the code does. However, I can't figure out how the coder got the value for a constant. I copied the following code example from this forum because it was shorter than what I was looking at and had an identical purpose (though different method). My specific question is: How does one know that it is necessary to set the EM_SETPASSWORDCHAR constant to &HCC in order to specify the edit control on an InputBox? I'd really appreciate it if someone could give me a "generic" answer so I'd know how to get such values for any control.
CODE EXAMPLE
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
' Constants for API set A
Const EM_SETPASSWORDCHAR = &HCC
Public Const NV_INPUTBOX As Long = &H5000&
Public Function TimerProc(ByVal lHwnd&, ByVal uMsg&, _
ByVal lIDEvent&, ByVal lDWTime&) As Long
' This function allows for a mask character on an inputbox
Dim lEditHwnd As Long
' Find a handle to the InputBox window, then to the textbox
' the user types in (Known as "Edit")
'
' **This part is VERY important, here is how the FindWindowEx call should look:
' **Only change the parameters that are enclosed in [ ] in the following example
'
' [variable] = FindWindowEx(FindWindow("#32770", "[caption of your InputBox]"), 0, "Edit", "")
'
lEditHwnd = FindWindowEx(FindWindow("#32770", "Security Dialogue"), 0, "Edit", "")
' Send the mask character to the target InputBox when the user types
' The mask character in this sample is the Asc("*") - the "*" can be changed
' to whatever you like.
Call SendMessage(lEditHwnd, EM_SETPASSWORDCHAR, Asc("*"), 0)
CODE EXAMPLE
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
' Constants for API set A
Const EM_SETPASSWORDCHAR = &HCC
Public Const NV_INPUTBOX As Long = &H5000&
Public Function TimerProc(ByVal lHwnd&, ByVal uMsg&, _
ByVal lIDEvent&, ByVal lDWTime&) As Long
' This function allows for a mask character on an inputbox
Dim lEditHwnd As Long
' Find a handle to the InputBox window, then to the textbox
' the user types in (Known as "Edit")
'
' **This part is VERY important, here is how the FindWindowEx call should look:
' **Only change the parameters that are enclosed in [ ] in the following example
'
' [variable] = FindWindowEx(FindWindow("#32770", "[caption of your InputBox]"), 0, "Edit", "")
'
lEditHwnd = FindWindowEx(FindWindow("#32770", "Security Dialogue"), 0, "Edit", "")
' Send the mask character to the target InputBox when the user types
' The mask character in this sample is the Asc("*") - the "*" can be changed
' to whatever you like.
Call SendMessage(lEditHwnd, EM_SETPASSWORDCHAR, Asc("*"), 0)