Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

*** mask password in inputbox

Status
Not open for further replies.

Kvracing

Programmer
Nov 14, 2014
4
NO
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:

Code:
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:

Code:
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:

Code:
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? :)
 
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
 
To start with I'd look long and hard at these function declarations, but mostly the first one:

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&)

It may help to be aware that return type must be declared explicitly in a 64-bit VBA applicatiosn. And that in Microsoft's Hungarian notation lp means 'Long Pointer'. And that, frankly, I'd avoid postfix variable typing if I could.
 
Why not just set up a form with text inputs and the password input mask set on appropriate fields? Its a lot simpler than these API calls.

John
 
The OP acknowledges that would normally be easier, but is not apparently applicable in this case (seems to prefer loads of code to having an additional form)
 
Also cross-posted at:
Please provide links between all forums on which you've posted about this issue. It's all very well for you to say you'll update all sites once you have a solution, but it's also important that you don't waste peoples' time having them discuss the same/similar issues related to developing a solution that have already been discussed elsewhere.

Cheers
Paul Edstein
[MS MVP - Word]
 
Comments from OP in a couple of those other forums:

>trust me I am following closly
That doesn't appear to be true. No feedback to my response yesterday ...

>the minuite we find a solution its out on every forum
Really?

>In fact I hope to mabe make a youtube video
I really don't think it'll be worth it
 
I haven't gone through the code, nor wasted time cross checking other forums but FWIW, a Type mismatch error on a Long when converting to 64 bit has an obvious fix and blitzing the web, rather than just trying the obvious, indicates such a lack of understanding that I don't see a successful outcome.

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Well, they haven't actually logged in since Friday, so guess they've given up ...
 
If they can't even be bothered logging in the check replies, it casts serious doubt on everything said in post #3 (the OP's 2nd post).

Cheers
Paul Edstein
[MS MVP - Word]
 

Good god.


> had no time to work sadly..

So "the minuite we find a solution its out on every forum" is not entirely accurate then, is it?

> But some good answers aswell :)

Really? Where? I couldn't spot any. The repeated answer seemed to me to be the one you specifically stated that you didn't want.

This really isn't that hard, BTW. Your assumption that "I don't think it's an easy fix" is inaccurate. As I directly try to hint (and TonyJollans specifically says), the error message is exactly right. There's nothing clever or difficult here.
 
Ty for answers, but this took to much time. So I converted to 32 bit. Solved the whole problem :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top