Archive: What is the default font in NsDialogs?


What is the default font in NsDialogs?
  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:

http://nsis.sourceforge.net/NsDialog...ssword_control

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?


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.


Originally posted by Animaether
Note that you would only use 'EM_SETPASSWORDCHAR' if you want to set a -custom- character.
I understand, but currently this is the only way I know to toggle hide/show password.

Originally posted by Animaether
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.
Is there an EM_GETPASSWORDCHAR message? If so, how do I use it in the context of nsDialogs?

It's the ES_PASSWORD style you want.

Stu


Originally posted by Afrow UK
It's the ES_PASSWORD style you want.
True, but I've already got that by merely using ${NSD_CreatePassword}.

It's not that critical, I am simply curious to know why is that character so illusive.

Originally posted by nsnb
I understand, but currently this is the only way I know to toggle hide/show password.
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
Is there an EM_GETPASSWORDCHAR message? If so, how do I use it in the context of nsDialogs?
Yes.. you can use it with the same SendMessage format, adding an additional variable at the end that contains the result.

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?

Originally posted by Animaether
Edit: and the answer may lay in Unicode... SendMessageA vs SendMessageW?
Yup...
System::Call "user32::SendMessageW(i $hwnd, i ${EM_SETPASSWORDCHAR}, i 9679, i 0)" 
Quick and very dirty sample script:

"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
>