Consulting

Results 1 to 9 of 9

Thread: *** mask password in inputbox

  1. #1
    VBAX Newbie
    Joined
    Nov 2014
    Posts
    4
    Location

    *** mask password in inputbox

    Hello!

    I am trying to get this code to work.
    It's for making **** in the field of an inputbox, so the password cant be seen.

    I's originally a code for a 32 bit system, so the real challenge here is converting it to 64 bit.



    The code are:



    Public sPwd As String
    Public gMsgTitle As String
    Public gMsgType As String
    Public gMsgText As String
    Public gStatusText As String
    
    "FindWindowA" (ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long
    
    Private Declare PtrSafe Function FindWindowEx Lib "user32" Alias _
    "FindWindowExA" (ByVal hWnd1 As LongPtr, ByVal hWnd2 As LongPtr, _
    ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPtr
    
    Public Declare PtrSafe Function SetTimer& Lib "user32" _
    (ByVal hwnd&, ByVal nIDEvent&, ByVal uElapse&, ByVal _
    lpTimerFunc&)
    
    Public Declare PtrSafe Function KillTimer& Lib "user32" _
    (ByVal hwnd&, ByVal nIDEvent&)
    
    Private Declare PtrSafe Function SendMessage Lib "user32" Alias _
    "SendMessageA" (ByVal hwnd As LongPtr, ByVal wMsg As LongPtr, _
    ByVal wParam As LongPtr, lParam As Any) As LongPtr
    
    Const EM_SETPASSWORDCHAR = &HCC
    Public Const NV_INPUTBOX As Long = &H5000&
    And Function:

    Public Function TimerProc(ByVal lHwnd&, ByVal uMsg&, _
    ByVal lIDEvent&, ByVal lDWTime&) As LongPtr
    
    Dim lTemp As Long
    Dim lEditHwnd As Long
    lTemp = FindWindowEx(FindWindow("#32770", "gMsgText"), 0, "Edit", "")
    lEditHwnd = FindWindowEx(FindWindow("#32770", "gMsgTitle"), 0, "Edit", "")
    
    Call SendMessage(lEditHwnd, EM_SETPASSWORDCHAR, Asc("*"), 0)
    
    KillTimer lHwnd, lIDEvent
    End Function
    Input box:

    Private Sub OpnAdm_Click()
    
    gMsgTitle = "Begrenset Omrde"
    gMsgType = vbOKOnly + vbInformation
    gMsgText = "Tast inn passord"
      
    
    lTemp = SetTimer(Me.hwnd, NV_INPUTBOX, 1, AddressOf TimerProc)
    sPwd = InputBox(gMsgText, gMsgTitle)
    
    
    If strPasswd = "" Or strPasswd = Empty Then
    Exit Sub
    End If
    
    If strPasswd = "yslg53481" Then
    DoCmd.OpenForm "frmBatchReg"
    Else
    MsgBox "Beklager, du har ikke tilgang til denne delen av programmet", vbOKOnly, "Sikkerhetssjekk"
    Exit Sub
    End If
    
    
    End Sub
    Missing anything? The error I get is type missmatch on AddressOf TimerProc. But I know its also needs converting to 64 bit. Don't know how tough.



    I know its 1000 times easyer to just make an new form and pwd mask the inputmask, but this is not the case here. I rather have more code and less forms, and it get's on my nerves that I cant find it out, so just need see this through, especially when so many other 32 bit users got it to work


    Anyone know what to do here?

  2. #2
    VBAX Newbie
    Joined
    Nov 2014
    Posts
    4
    Location
    Posted this on other forums; Just for information (got some angry moderators breathing down my neck:
    I have posted this issue on several forums, simply because I don't think it's an easy fix, and most likley It's just a few people who can solve this. Where they are is hard to know, so I have multiplyed the chances of finding them by going wide on the internett Do not worry on dobbeltsolving this problem, the minuite we find a solution its out on every forum. I don not want others to use as much time on this as I have. In fact I hope to mabe make a youtube video But first the problem needs solving So thx anyway for reading, I am quite on my deapth here now, so ain't getting further here without anyone with a little more experience

    Regards
    -Kv

  3. #3
    VBAX Expert
    Joined
    Oct 2012
    Posts
    726
    Location
    Why not create your own form? Use keydown to trap each character in a variable but show asterisks in a label.

  4. #4

  5. #5
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    ... Utter apologies, posted thinking I was in the Excel forum. Not sure about 'forms' in Access.
    Last edited by GTO; 11-16-2014 at 03:28 AM.

  6. #6
    VBAX Expert
    Joined
    Oct 2012
    Posts
    726
    Location
    I must have missed the last part of the post.
    anyway a quick search turned this up which seems to work ok.

    http://stackoverflow.com/questions/2...ancel-function

  7. #7
    VBAX Newbie
    Joined
    Nov 2014
    Posts
    4
    Location
    Quote Originally Posted by jonh View Post
    I must have missed the last part of the post.
    anyway a quick search turned this up which seems to work ok.

    Yes I know, that's the code I have based my code on, the challenge is as I pointed out in the bottom, that I have a 64 bit system.

  8. #8
    VBAX Expert
    Joined
    Oct 2012
    Posts
    726
    Location
    Oh. Ok. Your code looks nothing like that code. My mistake.

  9. #9
    VBAX Newbie
    Joined
    Nov 2014
    Posts
    4
    Location
    Ty for answers, but this took to much time. So I converted to 32 bit. Solved the whole problem

Posting Permissions

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