Path: utzoo!dciem!nrcaer!sce!cognos!gords From: gords@cognos.UUCP (Gord Smith) Newsgroups: comp.windows.ms Subject: Re: no-echo input Message-ID: <8449@cognos.UUCP> Date: 6 Jun 90 17:59:37 GMT References: <102@bohra.cpg.oz> <1584@ns-mx.uiowa.edu> <2559@tuminfo1.lan.informatik.tu-muenchen.dbp.de> <1129@cscnj.UUCP> Reply-To: gords@cognos.UUCP (Gord Smith) Organization: Cognos Inc., Ottawa, Canada Lines: 46 In article <1129@cscnj.UUCP> paul@cscnj.UUCP (Paul Moody) writes: > >In article <102@bohra.cpg.oz> ejp@bohra.cpg.oz.au (Esmond Pitt) writes: > >>I asked this a while ago but apparently it didn't get transmitted upstream. > >>Is it possible to accept input without echo (e.g. password fields) under: > >> (1) MS-Windows >In the NORMAL dialog function for the dialog where the password >is requested, add the following entry: This was a great tip (Thanks!), but (pet peeve flame on): WHY, oh why, oh why do programmers (and people who write how-to-program-Windows books) always seem to assume that the background is white and that text is black? These types of programs look really silly if the user has selected different colors in the control panel (e.g. I've got dark blue on light blue). Here's my modified version of the code which takes into account the user's color setup: In the WM_INITDIALOG message, add the line: BkBrush = (WORD)CreateSolidBrush(GetSysColor(COLOR_WINDOW)); Add the following case: case WM_CTLCOLOR: if(HIWORD(lParam) == CTLCOLOR_EDIT && GetDlgItem(hDlg, MYPASSWORDEDIT) == LOWORD(lParam)) { SetBkColor(wParam, GetSysColor(COLOR_WINDOW)); SetTextColor(wParam, GetSysColor(COLOR_WINDOW)); return BkBrush; } break; In the WM_DESTROY message for the dialog box add the line: DeleteObject(BkBrush); We use a global brush that we have around for the background color, so I don't need to create or nuke it everytime the dialog is run. -- D. Gordon Smith Voice: (613) 738-1338 ext 6118 P.O. Box 9707 Cognos Incorporated FAX: (613) 738-0002 3755 Riverside Dr. uucp: gords@cognos.uucp || uunet!mitel!sce!cognos!gords Ottawa, Ontario "Nothing ventured, nothing capital gained!" CANADA K1G 3Z4