![]() HHook = SetWindowsHookEx(WH_CBT, AddressOf CBTProc, App.hInstance, 0) Public Function vbInputBox(Prompt As String, Optional Title As String, Optional Default As String, Optional Xpos As Single, Optional YPos As Single, Optional Helpfile As String, Optional Context As Long) As String 'Optional Buttons As VbMsgBoxStyle = vbOKOnly, Optional Title As String, Optional HelpFile As String, Optional Context As Long) As Long ' Wrapper for the normal InputBox function Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long 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 Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) 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 ' Working variables that require global scope in hooking module RE: InputBox as password character(*)? krinid (Programmer) 21 Apr 04 01:54 If you comment or remove the SetTimer function call, all of the above actions are inhibited thus leaving the password textbox intact. Kills the timer to prevent further executions of the callback function (KillTimer). Changes the password character (SendMessage).Ĥ. Finds the handle of the Edit field inside the InputBox (FindWindowEx).ģ. Finds the handle of the InputBox dialog (FindWindow).Ģ. When the TimerProc function executes for the first time, it does the following.ġ. The AddressOf TimerProc argument passes the address of the TimerProc callback function to the SetTimer function so that the timer executes this code after each timeout interval. The timeout interval of the timer is set to 1 millisecond causing it to fire immediately after the input box is shown. The purpose of this timer is to change the password character of the InputBox edit field after the dialog is displayed. ![]() Thus a timer is setup before calling the InputBox function. You cannot change the password character using regular code because when the InputBox function is called, the execution of the code is suspended until the user dismiss the dialog box. The timer is required to set the password character after the input box is displayed. RE: InputBox as password character(*)? CCLINT (Programmer) 26 Sep 03 11:15 'instead of using Screen here, you could find and use the actual work area If you need some help with the positioning of the controls, etc, then place this also in the code window (you only need to add a form, two command buttons, a label and a text box, leaving the default names as they are): ReturnValue = frmpassword.GetPassword("HI","XYZ") If Not IsMissing(YPos) Then Me.Top = YPos If Not IsMissing(XPos) Then Me.Left = XPos Public Function GetPassword(Optional Prompt As String, Optional Title As String, Optional XPos As Variant, Optional YPos As Variant) As String ![]() If you add a small form to your project with a text box, a lable and two command buttons on it, and name it frmpassword, you can do what you want in two minutes by pasting the below into the new form's code window: I really don't understand why you would want to use an InputBox for this, and not just use a text box on a modal form. PasswordInputbox = InputBox(Prompt, WindowTitle, Default, XPos, YPos, String, Optional Default As String, Optional XPos As Long, Optional YPosĪs Long, Optional HelpFile As Long, Optional Context As Long) As String Public Function PasswordInputbox(Prompt As String, Optional Title As Public Sub TimerProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEventĮditHwnd = FindWindowEx(FindWindow('#32770', WindowTitle),Ĭall SendMessage(EditHwnd, EM_SETPASSWORDCHAR, Asc('*'), 0) Public Const NV_INPUTBOX As Long = &H5000& 'SendMessageA' (ByVal hwnd As Long, ByVal wMsg As Long, ByVal Private Declare Function SendMessage Lib 'user32' Alias Private Declare Function KillTimer& Lib 'user32' (ByVal hwnd&, Public Declare Function SetTimer& Lib 'user32' (ByVal hwnd&,īyVal nIDEvent&, ByVal uElapse&, ByVal lpTimerFunc&) Lpsz1 As String, ByVal lpsz2 As String) As Long 'FindWindowExA' (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal Private Declare Function FindWindowEx Lib 'user32' Alias 'FindWindowA' (ByVal lpClassName As String, ByVal lpWindowName Private Declare Function FindWindow Lib 'user32' Alias
0 Comments
Leave a Reply. |