passwords

Started by
4 comments, last by Ranthalion 20 years, 9 months ago
Does MSVC++ have a library or built in function for using a password box? Is there a control or anything that would display the asterisks or something instead of the actual key being pressed?
Advertisement
EM_SETPASSWORDCHAR
The EM_SETPASSWORDCHAR message sets or removes the password character for an edit control. When a password character is set, that character is displayed in place of the characters typed by the user. You can send this message to either an edit control or a rich edit control.

To send this message, call the SendMessage function with the following parameters.

SendMessage(
(HWND) hWnd, // handle to destination window
EM_SETPASSWORDCHAR, // message to send
(WPARAM) wParam, // character
(LPARAM) lParam // not used; must be zero
);
Parameters
wParam
Specifies the character to be displayed in place of the characters typed by the user. If this parameter is zero, the control removes the current password character and displays the characters typed by the user.
lParam
This parameter is not used.
Return Values
This message does not return a value.

Awesome! I''ll give that a try. Thanks so much Zern! ^_^
I''m just having one problem with that. How do I know what the handle is? I''m popping up a dialog box that is supposed to request the password.

Just a simple program.
winMain(blahblah...)
{
DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)MainDialogProc, 0);
SendMessage((How do I get this?),EM_SETPASSWORDCHAR, (WPARAM)"**",0);
return 0;
}

Is this completely wrong? How do I get the Handle to the dialog box, or do I want the handle to the edit box? Also, do I want to send this message before calling the dialog box?
When you design the dialog form, you can set the edit control as a password edit control, in the edit control''s properties.
.
Oh my Gosh! Thanks for pointing that out. I don''t know why I missed that. Makes the whole thing alot easier. ^_^

This topic is closed to new replies.

Advertisement