I am trying to let a user check whether he want the password shown or hidden, but when that checkbox is unchecked, the "hidden password" character does NOT return to the original "fat dot" per:
Yes, ASCII 149 is a fat dot, but not fat enough. 🙂
What is the default font in NsDialogs and what is that "truly fat" dot that appears by default before sending the EM_SETPASSWORDCHAR message?
What is the default font in NsDialogs?
8 posts
Why not create two fields, and hide/show them depending on the checkbox? Create a regular textfield and a password field, and you won't need to worry about the font.
Note that you would only use 'EM_SETPASSWORDCHAR' if you want to set a -custom- character.
The fat dots you're thinking about are the replacement for the asterisk (*) you'll get when using "XPStyle on" in your installer script. I'll update that wiki to note this.
The fat dots you're thinking about are the replacement for the asterisk (*) you'll get when using "XPStyle on" in your installer script. I'll update that wiki to note this.
I understand, but currently this is the only way I know to toggle hide/show password.Originally Posted by Animaether View PostNote that you would only use 'EM_SETPASSWORDCHAR' if you want to set a -custom- character.
Is there an EM_GETPASSWORDCHAR message? If so, how do I use it in the context of nsDialogs?Originally Posted by Animaether View PostThe fat dots you're thinking about are the replacement for the asterisk (*) you'll get when using "XPStyle on" in your installer script. I'll update that wiki to note this.
It's the ES_PASSWORD style you want.
Stu
Stu
True, but I've already got that by merely using ${NSD_CreatePassword}.Originally Posted by Afrow UK View PostIt's the ES_PASSWORD style you want.
It's not that critical, I am simply curious to know why is that character so illusive.
That wouldn't toggle it, though. You can toggle it -off- by using the character value 0 (zero).. make sure you refresh the control for it to update.Originally Posted by nsnb View PostI understand, but currently this is the only way I know to toggle hide/show password.
Yes.. you can use it with the same SendMessage format, adding an additional variable at the end that contains the result.Originally Posted by nsnb View PostIs there an EM_GETPASSWORDCHAR message? If so, how do I use it in the context of nsDialogs?
That result, by the way, is char 9679 for the original fat dot. And that's where a problem comes in.. EM_SETPASSWORDCHAR doesn't accept values outside of 0..255 , so you can't re-set the original fat dot that way, it seems.
Some coder changed the font (to Marlett) and used the letter 'n', which I guess would be a fat dot in that font.
I suspect there -is- an appropriate method, as I've seen this sort of toggle you speak of, but for all I know they're just doing what MSG suggested.. hide/unhide controls as applicable 🙂
Edit: and the answer may lay in Unicode... SendMessageA vs SendMessageW?
Yup...Originally Posted by Animaether View PostEdit: and the answer may lay in Unicode... SendMessageA vs SendMessageW?
System::Call "user32::SendMessageW(i $hwnd, i ${EM_SETPASSWORDCHAR}, i 9679, i 0)" Quick and very dirty sample script:!include "nsDialogs.nsh"
!include "winmessages.nsh"
!include "logiclib.nsh"
OutFile "test.exe"
Page Custom pre
var dialog
var hwnd
XPStyle on
Function pre
nsDialogs::Create 1018
Pop $dialog
${NSD_CreatePassword} 0 0 50% 8% "This is a password field"
Pop $hwnd
${NSD_CreateButton} 0 10% 33% 10% "Remove password style"
Pop $0
${NSD_OnClick} $0 remove
${NSD_CreateButton} 33% 10% 34% 10% "Get char && msg"
Pop $1
${NSD_OnClick} $1 get
${NSD_CreateButton} 67% 10% 33% 10% "Set char / restore"
Pop $2
${NSD_OnClick} $2 set
nsDialogs::Show
FunctionEnd
Function remove
Pop $0
SendMessage $hwnd ${EM_SETPASSWORDCHAR} 0 0 # wparam = 0 -> remove password style
${NSD_GetText} $hwnd $0 # dirty redraw
${NSD_SetText} $hwnd "$0" # dirty redraw
FunctionEnd
Function get
Pop $1
SendMessage $hwnd ${EM_GETPASSWORDCHAR} 0 0 $5
MessageBox MB_OK "Char: $5"
FunctionEnd
Function set
Pop $2
/* Must use unicode call */
System::Call "user32::SendMessageW(i $hwnd, i ${EM_SETPASSWORDCHAR}, i 9679, i 0)"
${NSD_GetText} $hwnd $0 # dirty redraw
${NSD_SetText} $hwnd "$0" # dirty redraw
FunctionEnd
Section ""
SectionEnd