Visual Basic, .NET, ASP, VBA, VBScript
 
  Библиотека кодов  
  Работа с формой  
     
  Использование InputBox для ввода секретной информации  
  Хотите использовать стандартный InputBox для ввода информации, скрытой звездочками? Нет проблем, сказал один из программистов, и создал для вас этот пример. В этом примере вам понадобится дополнительный модуль
'КОД ФОРМЫ

Private Sub Command1_Click()
Dim ret As String
ret = InputBoxEx("Наберите пароль:", "Программа...")
Label1 = ret
End Sub

'КОД МОДУЛЯ

Option Explicit
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
 
     
  VBNet online (всего: 52050)  
 

Логин:

Пароль:

Регистрация, забыли пароль?


В чате сейчас человек
 
     
  VBNet рекомендует  
   
     
  Лучшие материалы  
 
ActiveX контролы (112)
Hitman74_Library (36119)
WindowsXPControls (20739)
FlexGridPlus (19374)
DSMAniGifControl (18295)
FreeButton (15157)
Примеры кода (546)
Parol (18027)
Passworder (9299)
Screen saver (7654)
Kerish AI (5817)
Folder_L (5768)
Статьи по VB (136)
Мое второе впечатление... (11236)
VB .NET: дорога в будущее (11161)
Основы SQL (9225)
Сообщения Windows в Vi... (8788)
Классовая теория прогр... (8619)
 
     
Техническая поддержка MTW-хостинг | © Copyright 2002-2011 VBNet.RU | Пишите нам