Results 1 to 5 of 5

Thread: Asterix in inputbox?

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    8

    Cool

    Is it possible to get an asterix (*) in an inputbox instaid of the letters you type, when you want to use an inputbox to get a password?

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Unhappy Nope

    Sorry. Can't do it.

    Workaroud is to Make your own inputbox.
    Use a form and set the textbox passchar.

    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Hey, you're in damn luck today, I was just actually *writing* the code for it while I saw your post.

    so it IS possible whoheee!!!

    I'm writing a function to modify InputBoxes and stuff
    I was just busy with the second option, only allow numbers.

    Here's the code I've wrote 'till now, you might want to modify/add things, it may not work 100%, I'll post any updates I make if you need

    the following in a module:
    Code:
    Option Explicit
    'MODULE BY JOP
    'USE AT OWN RISK, PLEASE LEAVE THIS HEADER INTACT
    'YOU'RE NOT ALLOWED TO DISTRIBUTE THIS MODULE WITHOUT
    'PERMISSION OF THE AUTHOR, THANKS
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    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 PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    
    Const WM_CLOSE = &H10
    Const EM_SETPASSWORDCHAR = &HCC
    Const GWL_STYLE = (-16)
    Const ES_NUMBER = &H2000&
    
    Declare Function CreateThread Lib "kernel32" (lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadID As Long) As Long
    Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    
    Public Type InputBoxInfo
            PassWordChar As String
            OnlyAllowNumbers As Boolean
            Title As String
    End Type
    Public iBi As InputBoxInfo
    
    Public Sub ModifyInputBox()
    Dim BoxH&, EditH&, Style&
    If iBi.Title = "" Then Exit Sub
    BoxH = FindWindow(vbNullString, iBi.Title)
    EditH = FindWindowEx(BoxH, ByVal 0&, "Edit", "")
    If iBi.PassWordChar <> "" Then SendMessage EditH, EM_SETPASSWORDCHAR, Asc(iBi.PassWordChar), 0&
    Style = GetWindowLong(EditH, GWL_STYLE)
    If iBi.OnlyAllowNumbers Then
    Style = Style Or ES_NUMBER
    Else
    Style = Style And (Not ES_NUMBER)
    End If
    SetWindowLong EditH, GWL_STYLE, Style
    End Sub
    Add this into your form

    Code:
    Private Sub Command1_Click()
    'iBi is the Type I made for adding extended properties to the InputBox, here we only use the PassWordChar property and the title
    iBi.PassWordChar = "*" 'set the passwordchar to *
    iBi.Title = "Title Of EditBox" 'this one if REQUIRED!
        hThread = CreateThread(ByVal 0&, ByVal 0&, AddressOf ModifyInputBox, ByVal 0&, ByVal 0&, hThreadID) 'create a new thread
    InputBox "hey", iBi.Title 'the title is REQUIRED!
        CloseHandle hThread 'close the thread after the InputBox has been close
    End Sub
    Use the iBi properties for the InputBox, be sure to ALWAYS specify the Title or it won't work (ofcourse you must set the title in
    InputBox "MYTEXT", iBi.Title

    Hope that helped ya a bit
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    '---bas module code-- 
    Option Explicit 
    
    Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 
    
    Public 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 
    
    Public Declare Function SetTimer& Lib "user32" (ByVal hwnd&, ByVal nIDEvent&, ByVal uElapse&, ByVal lpTimerFunc&) 
    
    Public Declare Function KillTimer& Lib "user32" (ByVal hwnd&, ByVal nIDEvent&) 
    Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long 
    Public Const NV_INPUTBOX As Long = &H5000& 
    Public Const EM_SETPASSWORDCHAR = &HCC 
    Public Sub TimerProc(ByVal hwnd&, ByVal uMsg&, ByVal idEvent&, ByVal dwTime&) 
        Dim myHwnd As Long 
    'Change here App.Title (defoult InputBox Caption) into your caption 
        myHwnd = FindWindowEx(FindWindow("#32770", App.Title), 0, "Edit", "") 
         Call SendMessage(myHwnd, EM_SETPASSWORDCHAR, 42, 0) 
        KillTimer hwnd, idEvent 
    End Sub 
    
    '--Using - form code: 
    Private Sub Command1_Click() 
    Dim sPass As String 
    SetTimer hwnd, NV_INPUTBOX, 10, AddressOf TimerProc 
    sPass = InputBox("Set Password") 
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Unhappy ......

    Well who feels like a schmuck now.....








    i'll just go sit in the corner.



    .



    (btw... COOL!)
    Copy & pasting right now!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width