VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Want to use the standard inputbox as a login box? This code well show you how to hook the standard

by Ayman Elbasha (1 Submission)
Category: Windows API Call/Explanation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 21st October 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Want to use the standard inputbox as a login box? This code well show you how to hook the standard input box by using some API function to

API Declarations


Option Explicit
' IMPORTANT NOTE:
' Demo project showing how to use the Secured InputBox
' by Ayman Elbasha
' this demo is released "as is" without warranty or guaranty of any kind.
' In other words, use at your own risk.

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 SetTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long) As Long
Private Declare Function GetCurrentThreadId Lib "kernel32" () 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
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 Const WH_CBT = 5
Private Const HCBT_ACTIVATE = 5
Private m_lMsgHandle As Long
Private m_lhHook As Long
Private Const ES_CENTER = &H1&

Private Function GetMessageBoxHandle(ByVal lMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If lMsg = HCBT_ACTIVATE Then
m_lMsgHandle = wParam
UnhookWindowsHookEx m_lhHook
m_lhHook = 0
End If
GetMessageBoxHandle = False
End Function

Private Sub InputBoxTimerUpdateEvent(hWnd As Long, uiMsg As Long, idEvent As Long, dwTime As Long)
Dim res As Long

If m_lMsgHandle = 0 Then Exit Sub
res = FindWindowEx(m_lMsgHandle, 0, "Edit", "")
SendMessage res, 1052, 42, ByVal 0&
SendMessage res, &H441, ES_CENTER, ByVal 0&
End Sub




Public Function InputBoxEx(sMsgText As String, Optional sTitle As String = "Secured InputBox") As String
Dim lTimerUpdate As Long

m_lhHook = SetWindowsHookEx(WH_CBT, AddressOf GetMessageBoxHandle, App.hInstance, GetCurrentThreadId())
lTimerUpdate = SetTimer(0, 0, 0, AddressOf InputBoxTimerUpdateEvent)
InputBoxEx = InputBox(sMsgText, sTitle)
KillTimer 0, lTimerUpdate
End Function


Rate Want to use the standard inputbox as a login box? This code well show you how to hook the standard



Option Explicit
' IMPORTANT NOTE:
' This demo project showing how to use the Secured InputBox
' by Ayman Elbasha
' this demo is released "as is" without warranty or guaranty of any kind.
' In other words, use at your own risk.

'in a form named "frmSecureInputBox" creat a button named "cmdShowInputBox",
'label named "lblInfo" and button named "cmdExit"
'

Private Sub cmdExit_Click()
    End
End Sub

Private Sub cmdShowInputBox_Click()
Dim ret As String

ret = InputBoxEx("Please Inter Password:", "myApplication")
lblInfo = ret
End Sub




Download this snippet    Add to My Saved Code

Want to use the standard inputbox as a login box? This code well show you how to hook the standard Comments

No comments have been posted about Want to use the standard inputbox as a login box? This code well show you how to hook the standard . Why not be the first to post a comment about Want to use the standard inputbox as a login box? This code well show you how to hook the standard .

Post your comment

Subject:
Message:
0/1000 characters