Hi
Is there a way to change the "old" asterisk password style in dialog editor to the more "modern" dot style (Microsoft style)?
Thanks
Erez
Do you mean something like the following?
#DefineFunction PwExamProc(PwExam_Handle,PwExam_Event,PwExam_Name,PwExam_EventInfo,PwExam_ChangeInfo)
switch PwExam_Event ; Switch based on Dialog Message type
case @deInit ; Standard Initialization message
; Change the password character.
EM_SETPASSWORDCHAR = 204 ;0xCC
cwDot = 8226 ; Unicode bullet code point.
hWndEdit = DialogControlGet(PwExam_Handle, 'EditBox_1', @dchWnd, 0)
DllCall('user32.dll', long:'SendMessageW', long:hWndEdit, long:EM_SETPASSWORDCHAR, long:cwDot, long:0)
; DialogProcOptions(PwExam_Handle,@deTimer,1000)
; DialogProcOptions(PwExam_Handle,@dePbPush,@TRUE)
; DialogProcOptions(PwExam_Handle,@deEdText,@TRUE)
return(@retDefault)
; case @dePbPush
; if PwExam_Name == "PushButton_OK" ; OK
; return(@retDefault)
; elseif PwExam_Name == "PushButton_Cancel" ; Cancel
; return(@retDefault)
; endif ; PwExam_Name
; return(@retDefault)
; case @deEdText ; ID "EditBox_1" ebVariable1
; return(@retDefault)
; case @deClose ; System menu close event
; return(@retDefault)
endswitch ; PwExam_Event
return(@retDefault)
#EndFunction ; End of Dialog Callback PwExamCallbackProc
PwExamFormat=`WWWDLGED,6.2`
PwExamCaption=`Pasword Example`
PwExamX=180
PwExamY=144
PwExamWidth=302
PwExamHeight=270
PwExamNumControls=004
PwExamProcedure=`PwExamProc`
PwExamFont=`DEFAULT`
PwExamTextColor=`DEFAULT`
PwExamBackground=`DEFAULT,DEFAULT`
PwExamConfig=0
PwExamDPI=`192,10,20`
PwExam001=`034,212,050,016,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
PwExam002=`188,212,056,016,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
PwExam003=`017,017,238,022,STATICTEXT,"StaticText_1",DEFAULT,"Enter a password:",DEFAULT,30,@csCenter,"Microsoft Sans Serif|15155|40|34",DEFAULT,DEFAULT`
PwExam004=`041,050,187,034,EDITBOX,"EditBox_1",ebVariable1,DEFAULT,DEFAULT,40,@csPassword,"Microsoft Sans Serif|17613|40|34","0|0|255",DEFAULT`
ButtonPushed=Dialog("PwExam")
After posting the above I realized I hadn't taken the DPI of my system into account so I added a DPI attribute to the dialog's template.
Awesome thanks!
I got a another small question in the same issue, can we also create a peek icon so user can press and see a glimpse of the real password?
I noticed I can do it with: DialogControlState(PwExam_Handle,"EditBox_1",@dcsREMStyle,@csPassword )
The issue is to create a button that I can press on it and it will show me the actual password as long as I keep pressing. If I release the button it get back to dots.
Thanks!
You would have to hack something using multiple controls. I don't know if IE ever supported the password input type so hosting a browser control in a dialog's COMCONTROL window may not fly very far either.
Here is a very crude hack that kinda does what you want.
#DefineFunction PwExamProc(PwExam_Handle,PwExam_Event,PwExam_Name,PwExam_EventInfo,PwExam_ChangeInfo)
switch PwExam_Event ; Switch based on Dialog Message type
case @deInit ; Standard Initialization message
; Change the password character.
EM_SETPASSWORDCHAR = 204 ;0xCC
cwDot = 8226 ; Unicode bullet character.
hWndEdit = DialogControlGet(PwExam_Handle, 'EditBox_1', @dchWnd, 0)
DllCall('user32.dll', long:'SendMessageW', long:hWndEdit, long:EM_SETPASSWORDCHAR, long:cwDot, long:0)
; DialogProcOptions(PwExam_Handle,@deTimer,1000)
DialogProcOptions(PwExam_Handle,@dePbPush,@TRUE)
; DialogProcOptions(PwExam_Handle,@deEdText,@TRUE)
PtrPersistent(bPwHidden, 1)
return(@retDefault)
case @dePbPush
if PwExam_Name == "Eye"
EM_SETPASSWORDCHAR = 204 ;0xCC
pbPwHidden = PtrPersistent(bPwHidden, 0)
if *pbPwHidden then cwDot = 0
else cwDot = 8226 ; Unicode bullet character.
hWndEdit = DialogControlGet(PwExam_Handle, 'EditBox_1', @dchWnd, 0)
DllCall('user32.dll', long:'SendMessageW', long:hWndEdit, long:EM_SETPASSWORDCHAR, long:cwDot, long:0)
*pbPwHidden = !*pbPwHidden
DialogControlState(PwExam_Handle, 'EditBox_1',@dcsSetFocus ,0)
return(@retNoExit)
endif
; if PwExam_Name == "PushButton_OK" ; OK
; return(@retDefault)
; elseif PwExam_Name == "PushButton_Cancel" ; Cancel
; return(@retDefault)
; endif ; PwExam_Name
; return(@retDefault)
; case @deEdText ; ID "EditBox_1" ebVariable1
; return(@retDefault)
; case @deClose ; System menu close event
; return(@retDefault)
endswitch ; PwExam_Event
return(@retDefault)
#EndFunction ; End of Dialog Callback PwExamCallbackProc
PwExamFormat=`WWWDLGED,6.2`
PwExamCaption=`Pasword Example`
PwExamX=180
PwExamY=144
PwExamWidth=302
PwExamHeight=270
PwExamNumControls=005
PwExamProcedure=`PwExamProc`
PwExamFont=`DEFAULT`
PwExamTextColor=`DEFAULT`
PwExamBackground=`DEFAULT,DEFAULT`
PwExamConfig=0
PwExamDPI=`192,10,20`
PwExam001=`034,212,050,016,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
PwExam002=`188,212,056,016,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
PwExam003=`017,017,238,022,STATICTEXT,"StaticText_1",DEFAULT,"Enter a password:",DEFAULT,30,@csCenter,"Microsoft Sans Serif|15155|40|34",DEFAULT,DEFAULT`
PwExam004=`022,050,186,035,EDITBOX,"EditBox_1",ebVariable1,DEFAULT,DEFAULT,40,@csPassword,"Microsoft Sans Serif|17613|40|34","0|0|255",DEFAULT`
PwExam005=`209,050,036,035,PICTUREBUTTON,"Eye",DEFAULT,"Pict button 1",2,50,@csFlat,DEFAULT,DEFAULT,"eye.bmp"`
ButtonPushed=Dialog("PwExam")
exit
What about something like this? Mostly Tony's work but changes automatically if you move mouse off eye button.
Jim
#DefineFunction PwExamProc(PwExam_Handle,PwExam_Event,PwExam_Name,PwExam_EventInfo,PwExam_ChangeInfo)
switch PwExam_Event ; Switch based on Dialog Message type
case @deInit ; Standard Initialization message
; Change the password character.
EM_SETPASSWORDCHAR = 204 ;0xCC
cwDot = 8226 ; Unicode bullet character.
hWndEdit = DialogControlGet(PwExam_Handle, 'EditBox_1', @dchWnd, 0)
DllCall('user32.dll', long:'SendMessageW', long:hWndEdit, long:EM_SETPASSWORDCHAR, long:cwDot, long:0)
; DialogProcOptions(PwExam_Handle,@deTimer,1000)
DialogProcOptions(PwExam_Handle,@dePbPush,@TRUE)
; DialogProcOptions(PwExam_Handle,@deEdText,@TRUE)
return(@retDefault)
case @dePbPush
if PwExam_Name == "Eye"
EM_SETPASSWORDCHAR = 204 ;0xCC
cwDot = 0
hWndEdit = DialogControlGet(PwExam_Handle, 'EditBox_1', @dchWnd, 0)
DllCall('user32.dll', long:'SendMessageW', long:hWndEdit, long:EM_SETPASSWORDCHAR, long:cwDot, long:0)
DialogControlState(PwExam_Handle, 'EditBox_1',@dcsSetFocus ,0)
While MouseInfo(0) == "Eye"
TimeDelay(.1)
EndWhile
cwDot = 8226
DllCall('user32.dll', long:'SendMessageW', long:hWndEdit, long:EM_SETPASSWORDCHAR, long:cwDot, long:0)
DialogControlState(PwExam_Handle, 'Eye',@dcsSetFocus ,0)
return(@retNoExit)
endif
; if PwExam_Name == "PushButton_OK" ; OK
; return(@retDefault)
; elseif PwExam_Name == "PushButton_Cancel" ; Cancel
; return(@retDefault)
; endif ; PwExam_Name
; return(@retDefault)
; case @deEdText ; ID "EditBox_1" ebVariable1
; return(@retDefault)
; case @deClose ; System menu close event
; return(@retDefault)
endswitch ; PwExam_Event
return(@retDefault)
#EndFunction ; End of Dialog Callback PwExamCallbackProc
PwExamFormat=`WWWDLGED,6.2`
PwExamCaption=`Pasword Example`
PwExamX=180
PwExamY=144
PwExamWidth=302
PwExamHeight=270
PwExamNumControls=005
PwExamProcedure=`PwExamProc`
PwExamFont=`DEFAULT`
PwExamTextColor=`DEFAULT`
PwExamBackground=`DEFAULT,DEFAULT`
PwExamConfig=0
PwExamDPI=`192,10,20`
PwExam001=`034,212,050,016,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
PwExam002=`188,212,056,016,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
PwExam003=`017,017,238,022,STATICTEXT,"StaticText_1",DEFAULT,"Enter a password:",DEFAULT,30,@csCenter,"Microsoft Sans Serif|15155|40|34",DEFAULT,DEFAULT`
PwExam004=`022,050,186,035,EDITBOX,"EditBox_1",ebVariable1,DEFAULT,DEFAULT,40,@csPassword,"Microsoft Sans Serif|17613|40|34","0|0|255",DEFAULT`
PwExam005=`209,050,036,035,PICTUREBUTTON,"Eye",DEFAULT,"Eye",2,50,@csFlat,DEFAULT,DEFAULT,"eye.bmp"`
ButtonPushed=Dialog("PwExam")
exit
I thought about using MouseInfo in a dialog timer to detect when the mouse was over the eye and change the hidden state as needed. I was to lazy to write and test it.
I went the combo route to avoid any accidental display of the password.
Jim
The OP seemed to indicate he wanted a hover to display the password. But often, password input controls with "the eye" work by displaying plain text when the mouse button is pushed down over the eye but go back to hidden when the mouse button is either released or the cursor move outside the border of the eye. Since WIL doesn't distinguish between the mouse button down and mouse button up messages your solution is a good compromise for implementing the latter UI effect.
That work great, thanks!
A slightly modified take based on the original hack that hides the password whenever the mouse moves outside the edit or "eye" controls.
#DefineFunction PwExamProc(PwExam_Handle,PwExam_Event,PwExam_Name,PwExam_EventInfo,PwExam_ChangeInfo)
switch PwExam_Event ; Switch based on Dialog Message type
case @deInit ; Standard Initialization message
; Change the password character.
EM_SETPASSWORDCHAR = 204 ;0xCC
cwDot = 8226 ; Unicode bullet character.
hWndEdit = DialogControlGet(PwExam_Handle, 'EditBox_1', @dchWnd, 0)
DllCall('user32.dll', long:'SendMessageW', long:hWndEdit, long:EM_SETPASSWORDCHAR, long:cwDot, long:0)
DialogProcOptions(PwExam_Handle,@deTimer,200)
DialogProcOptions(PwExam_Handle,@dePbPush,@TRUE)
PtrPersistent(bPwHidden, 1)
return(@retDefault)
case @dePbPush
if PwExam_Name == "Eye"
EM_SETPASSWORDCHAR = 204 ;0xCC
pbPwHidden = PtrPersistent(bPwHidden, 0)
if *pbPwHidden then cwDot = 0
else cwDot = 8226 ; Unicode bullet character.
hWndEdit = DialogControlGet(PwExam_Handle, 'EditBox_1', @dchWnd, 0)
SendMessageW( hWndEdit, EM_SETPASSWORDCHAR, cwDot, '')
*pbPwHidden = !*pbPwHidden
DllCall('user32.dll', long:'InvalidateRect', long:hWndEdit, long:0, long:1)
DllCall('user32.dll', long:'UpdateWindow', long:hWndEdit)
return(@retNoExit)
endif
break
case @deTimer
; Revert to password character when mouse pointer is outside the two controls.
pbPwHidden = PtrPersistent(bPwHidden, 0)
if !*pbPwHidden
strWnd = MouseInfo(0)
strPwd = DialogControlGet(PwExam_Handle, 'EditBox_1', @dcText, 0)
if strWnd != "Pict button 1" && strWnd != strPwd
EM_SETPASSWORDCHAR = 204 ;0xCC
hWndEdit = DialogControlGet(PwExam_Handle, 'EditBox_1', @dchWnd, 0)
SendMessageW( hWndEdit, EM_SETPASSWORDCHAR, 8226, '')
DllCall('user32.dll', long:'InvalidateRect', long:hWndEdit, long:0, long:1)
DllCall('user32.dll', long:'UpdateWindow', long:hWndEdit)
*pbPwHidden = !*pbPwHidden
endif
endif
break;
; if PwExam_Name == "PushButton_OK" ; OK
; return(@retDefault)
; elseif PwExam_Name == "PushButton_Cancel" ; Cancel
; return(@retDefault)
; endif ; PwExam_Name
; return(@retDefault)
; case @deEdText ; ID "EditBox_1" ebVariable1
; return(@retDefault)
; case @deClose ; System menu close event
; return(@retDefault)
endswitch ; PwExam_Event
return(@retDefault)
#EndFunction ; End of Dialog Callback PwExamCallbackProc
PwExamFormat=`WWWDLGED,6.2`
PwExamCaption=`Pasword Example`
PwExamX=180
PwExamY=144
PwExamWidth=302
PwExamHeight=270
PwExamNumControls=005
PwExamProcedure=`PwExamProc`
PwExamFont=`DEFAULT`
PwExamTextColor=`DEFAULT`
PwExamBackground=`DEFAULT,DEFAULT`
PwExamConfig=0
PwExamDPI=`192,10,20`
PwExam001=`034,212,050,016,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
PwExam002=`188,212,056,016,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
PwExam003=`017,017,238,022,STATICTEXT,"StaticText_1",DEFAULT,"Enter a password:",DEFAULT,30,@csCenter,"Microsoft Sans Serif|15155|40|34",DEFAULT,DEFAULT`
PwExam004=`022,050,186,035,EDITBOX,"EditBox_1",ebVariable1,DEFAULT,DEFAULT,40,@csPassword,"Microsoft Sans Serif|17613|40|34","0|0|255",DEFAULT`
PwExam005=`209,050,036,035,PICTUREBUTTON,"Eye",DEFAULT,"Pict button 1",2,50,@csFlat,DEFAULT,DEFAULT,"eye.bmp"`
ButtonPushed=Dialog("PwExam")
exit