View Issue Details

IDProjectCategoryView StatusLast Update
0002293JEDI VCL00 JVCL Componentspublic2005-01-19 14:25
ReporteranonymousAssigned Toremkobonte 
Status resolvedResolutionfixed 
Product Version3.00 BETA 2 
Target VersionFixed in Version3.00 
Summary0002293: JvEdit and PasswordChar

when setting the PasswordChar property of JvEdit to '*' and ThemedPassword
to True and adding a XPManifest to a form, I get pretty bullets in this
edit control.

However when I toggle between PasswordChar := '*' and PasswordChar := #0
and vice versa then these bullets are changed into some asterisk instead of bullets again
TagsNo tags attached.



2004-11-05 16:32

developer   ~0005577

Why do you want to change PasswordChar?

Use ThemedPassword to toggle between password-mode and non password-mode.


2004-11-08 02:22

viewer   ~0005587


Using e.g. JvEdit1.ThemedPassword := not JvEdit1.ThemedPassword;
to toggle the password visibility does nothing indeed. The input box get's cleared!


2004-11-08 02:25

reporter   ~0005588

As Peter suggested I'm adding a possible solution/code I've successfully used inside another control.

[..from NG posting..]

I'm restoring one of the fonts below when the PasswordChar property get
filled. First I determine one existing font and store the Font.Name into
FSecretFont. This procedure is called from the constructor.

procedure TTWPWEdit.SetEditBoxFont;
    FavouredFonts: array[0..2] of String = ('Tahoma', 'Arial', 'MS Sans
    Cnt: Integer;
    Cnt := Low(FavouredFonts);
    while (Cnt <= High(FavouredFonts)) and
(Screen.Fonts.IndexOf(FavouredFonts[Cnt]) < 0) do
    if Cnt <= High(FavouredFonts) then
        FSecretFont.Name := FavouredFonts[Cnt];

When the edit should display bullets I'm using a similar coding as of
JvEdit - I simply reset the font back.

    FInternalGetText := True;
          if HandleAllocated then
              SendMessage(WindowHandle, EM_SETPASSWORDCHAR, Ord(FSecretChar), 0);
            RecreateWnd; // Recreate to force a call to CreateParams
    Perform(WM_SETFONT, FSecretFont.Handle, 0);
          FInternalGetText := False;

CreateParams looks like this (similar to JvEdit):
procedure TTWPWEdit.CreateParams(var Params: TCreateParams);
    Params.Style := Params.Style or ES_PASSWORD;


2005-01-17 03:58

developer   ~0006171

Altering EM_SETPASSWORDCHAR will break theming.
Windows will correctly theme an edit box if the style ES_PASSWORD is set.

Explicitly setting a password character to use will always cause Windows to ignore theming and start using the character you specify, so don't specify one and let Windows handle it all.

This themes correctly - and can have the password exposed by setting HidePassword to false:

unit PassEdit;

uses Classes, Controls, StdCtrls;

  TPassEdit = class(TCustomEdit)
    FDummy: byte;
    FHidePassword: Boolean;
    procedure SetHidePassword(const Value: Boolean);
    procedure CreateParams(var Params: TCreateParams); override;
    constructor Create(AOwner: TComponent); override;
      //Snipped re-publishing of properties - don't publish PasswordChar
    property HidePassword: Boolean read FHidePassword write SetHidePassword;

uses Windows;

constructor TPassEdit.Create(AOwner: TComponent);
  inherited ParentFont:=False;
  inherited Font.Name:= 'MS Shell Dlg';

procedure TPassEdit.CreateParams(var Params: TCreateParams);
  if FHidePassword then
    Params.Style:=Params.Style or ES_PASSWORD;

procedure TPassEdit.SetHidePassword(const Value: Boolean);
  if FHidePassword <> Value then


2005-01-17 09:21

reporter   ~0006180


thanks for your comment! If this works, untested so far, but I had a similar component/coding before, it's now up to the Jedi team to implement this into TJvEdit IMO.



2005-01-17 11:57

developer   ~0006184


I do not understand why JvEdit1.ThemedPassword := not JvEdit1.ThemedPassword; does not work for you.

Could you create a simple project with your code, maybe I'm overlooking a simple property setting.

You can upload the project to this report. Please also specify which Delphi version you use & what version of JvEdit.pas (you can find the version in the line that starts with

// $Id: JvEdit.pas

just above the unit heading).

2005-01-18 03:45 (3,617 bytes)


2005-01-18 03:46

reporter   ~0006203

Hi Remko,

I've attached a sample project - and you were right: you just missed a simple but effective property: ProtectPassword.

Using D7, JvEdit: // $Id: JvEdit.pas,v 1.58 2004/12/18 07:40:43 marquardt Exp $



2005-01-18 14:00

developer   ~0006217

Last edited: 2005-01-18 14:00

Okay, problem was that toggling ThemedPassword recreates the edit window (RecreateWnd call). Because the window handle and all its data will be lost, TWinControl.DestroyWnd sends WM_GETTEXTLENGTH & WM_GETTEXT messages to save the edit text in the FText field, but that will fail if ProtectPassword is set to True.

Thus I have overridden DestroyWnd, to temporarely set ProtectPassword to False.

Also now when ThemedPassword is set to true, the font will be set to the Default GUI Font (probably MS Shell Dlg).

This is all fixed in Rev. 1.61


2005-01-19 00:41

reporter   ~0006225

Hi Remko,

works perfectly! And fixed perfectly as usual :-)
Do you close this ticket, 'cause it seems I cannot do this?



2005-01-19 14:25

developer   ~0006233

Okay :) thanks for the feedback.

Issue History

Date Modified Username Field Change
2004-11-05 06:17 anonymous New Issue
2004-11-05 16:32 remkobonte Note Added: 0005577
2004-11-05 16:32 remkobonte Status new => feedback
2004-11-08 02:22 anonymous Note Added: 0005587
2004-11-08 02:25 roaster Note Added: 0005588
2004-11-09 15:27 remkobonte Status feedback => assigned
2004-11-09 15:27 remkobonte Assigned To => remkobonte
2005-01-17 03:58 rikbarker Note Added: 0006171
2005-01-17 09:21 roaster Note Added: 0006180
2005-01-17 11:57 remkobonte Note Added: 0006184
2005-01-18 03:45 roaster File Added:
2005-01-18 03:46 roaster Note Added: 0006203
2005-01-18 14:00 remkobonte Note Added: 0006217
2005-01-18 14:00 remkobonte Note Edited: 0006217
2005-01-19 00:41 roaster Note Added: 0006225
2005-01-19 14:25 remkobonte Status assigned => resolved
2005-01-19 14:25 remkobonte Fixed in Version => 3.00
2005-01-19 14:25 remkobonte Resolution open => fixed
2005-01-19 14:25 remkobonte Note Added: 0006233