Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002293 [JEDI VCL] 00 JVCL Components minor always 2004-11-05 06:17 2005-01-19 14:25
Reporter anonymous View Status public  
Assigned To remkobonte
Priority normal Resolution fixed  
Status resolved   Product Version 3.00 BETA 2
Summary 0002293: JvEdit and PasswordChar
Description Hi,

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
Additional Information
Tags No tags attached.
Attached Files zip file icon sample.zip [^] (3,617 bytes) 2005-01-18 03:45

- Relationships

-  Notes
(0005577)
remkobonte (developer)
2004-11-05 16:32

Why do you want to change PasswordChar?

Use ThemedPassword to toggle between password-mode and non password-mode.
(0005587)
anonymous (viewer)
2004-11-08 02:22

@Remko,

Using e.g. JvEdit1.ThemedPassword := not JvEdit1.ThemedPassword;
to toggle the password visibility does nothing indeed. The input box get's cleared!
(0005588)
roaster (reporter)
2004-11-08 02:25

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;
  const
    FavouredFonts: array[0..2] of String = ('Tahoma', 'Arial', 'MS Sans
Serif');
  var
    Cnt: Integer;
  begin
    Cnt := Low(FavouredFonts);
    while (Cnt <= High(FavouredFonts)) and
(Screen.Fonts.IndexOf(FavouredFonts[Cnt]) < 0) do
      Inc(Cnt);
    if Cnt <= High(FavouredFonts) then
        FSecretFont.Name := FavouredFonts[Cnt];
  end;

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

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

CreateParams looks like this (similar to JvEdit):
procedure TTWPWEdit.CreateParams(var Params: TCreateParams);
  begin
    inherited;
    Params.Style := Params.Style or ES_PASSWORD;
  end;
(0006171)
rikbarker (developer)
2005-01-17 03:58

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;

interface
uses Classes, Controls, StdCtrls;

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

implementation
uses Windows;

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

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

procedure TPassEdit.SetHidePassword(const Value: Boolean);
begin
  if FHidePassword <> Value then
  begin
    FHidePassword:=Value;
    RecreateWnd;
  end;
end;
(0006180)
roaster (reporter)
2005-01-17 09:21

@rikbarker,

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.

cu,
Michael
(0006184)
remkobonte (developer)
2005-01-17 11:57

@roaster:

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).
(0006203)
roaster (reporter)
2005-01-18 03:46

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 $

Thanks,
Michael
(0006217)
remkobonte (developer)
2005-01-18 14:00
edited on: 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

(0006225)
roaster (reporter)
2005-01-19 00:41

Hi Remko,

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

Michael
(0006233)
remkobonte (developer)
2005-01-19 14:25

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-08 02:25 roaster Issue Monitored: roaster
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: sample.zip
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


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker