[SOLVED] TEdit Password character is different from Windows UI lazarus / 31-LCL ---------------------------------------------------------------------- SassyPenguin · 2022-01-24 13:56 Hello, TEdit password character set to "*", however why it does not show as rounded dot like Windows 11 does? Didn't notice if it is same as on Windows 10, I already upgraded to Windows 11. Delphi showed as rounded dot. ---------------------------------------------------------------------- AlexTP · 2022-01-24 14:02 Because '*' is the default value of the TEdit.PasswordChar property. It is the misfeature of LCL- we cannot pass there WideChar with value >$ff. ---------------------------------------------------------------------- SassyPenguin · 2022-01-24 14:17 Quote from: Alextp on January 24, 2022, 03:02:28 pmBecause '*' is the default value of the TEdit.PasswordChar property. It is the misfeature of LCL- we cannot pass there WideChar with value >$ff. Thanks for the information, I found that I can use Extended ASCII code (#149 for rounded dot) to substitute.  It looks better now... ---------------------------------------------------------------------- Bart · 2022-01-24 17:48 #149 is not a valid UTF8 string or character (all strings and chars in LCL are supposed to be UTF8), so it's kind of a miracle that this works at all. Bart ---------------------------------------------------------------------- CM630 · 2022-01-27 18:58 On one hand using ascii in the 21st century seems absurd, but on the other hand #149 occurs to be the same bullet character in CP1250...1256, and maybe even further ---------------------------------------------------------------------- SassyPenguin · 2022-01-28 11:46 Quote from: CM630 on January 27, 2022, 07:58:32 pmOn one hand using ascii in the 21st century seems absurd, but on the other hand #149 occurs to be the same bullet character in CP1250...1256, and maybe even further  Yea, that's just a quick solution if we don't want get dirty. Create native EDIT control and sub messaging the control with Windows API calls is another absurd method, which takes more effort. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1; {$mode objfpc}{$H+} uses  Windows,Messages, SysUtils; {$R *.res} const  LPSTR_APP_CLASS = 'native_EditClass';  LPSTR_APP_TITLE = 'Native Edit Control (Windows)';  ID_PASSEDIT = 100; var  hWin: HWND;  function CreatePasswordEdit(Handle: HWND): HWND;var  hEdit: HWND;begin  hEdit := CreateWindowEx(WS_EX_CLIENTEDGE,'EDIT',nil,WS_CHILD or WS_TABSTOP or         WS_CLIPCHILDREN or WS_VISIBLE or ES_PASSWORD,            20,20,270,23,Handle,ID_PASSEDIT,hInstance,nil);   SendMessage(hEdit, WM_SETFONT, GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(1, 0));   Result := hEdit;end; function ApplicationWndProc(Handle: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;begin  case uMsg of    WM_CREATE:      SetFocus(CreatePasswordEdit(Handle));    WM_SYSCOMMAND:      case LOWORD(wParam) of        SC_CLOSE:          DestroyWindow(Handle);      end;    WM_COMMAND:      case LOWORD(wParam) of        IDCANCEL:          SendMessage(Handle,WM_SYSCOMMAND,SC_CLOSE,lParam);      end;    WM_DESTROY:      begin        DestroyWindow(GetDlgItem(Handle,ID_PASSEDIT));        PostQuitMessage(0);      end;  end;  Result := DefWindowProc(Handle,uMsg,wParam,lParam);end;  {Register windows class}function ApplicationRegisterClass(const hInst: HINST; lpWndProc: POINTER): BOOL;var  hwndCls: TWNDCLASS;begin  hwndCls.style := CS_CLASSDC;  hwndCls.lpfnWndProc := WNDPROC(lpWndProc);  hwndCls.cbClsExtra := 0;  hwndCls.cbWndExtra := 0;  hwndCls.hInstance := hInst;  hwndCls.hIcon := LoadIcon(hInst,'MAINICON');  hwndCls.hCursor := LoadCursor(0,IDC_ARROW);  hwndCls.hbrBackground := COLOR_BTNFACE+1;  hwndCls.lpszMenuName := nil; //MAKEINTRESOURCE(RES_MENU_MAIN);  hwndCls.lpszClassName := LPSTR_APP_CLASS;   Result := (RegisterClass(hwndCls)<>0);end; {~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}function ApplicationCreateWindows(const hInst: HINST): BOOL;begin  hWin := CreateWindow(LPSTR_APP_CLASS,LPSTR_APP_TITLE,WS_SYSMENU,                     CW_USEDEFAULT,CW_USEDEFAULT,350,150,                       0,0,hInst,nil);  if (hWin<>0) then    begin      ShowWindow(hWin,SW_SHOWNORMAL);      UpdateWindow(hWin);      Result := TRUE;    end  else    Result := FALSE;end;  {------------------ Main window message loop--------------------}function ApplicationMessageLoop(const hInst: HINST; const hOwner: HWND): WPARAM;var  uMsg: TMSG;begin   while GetMessage(uMsg,0,0,0) do    begin      TranslateMessage(uMsg);      DispatchMessage(uMsg);    end;  Result := uMsg.wParam;end;   {Program main entry}begin  if ApplicationRegisterClass(hInstance,@ApplicationWndProc) then    begin      if ApplicationCreateWindows(hInstance) then          Halt(ApplicationMessageLoop(hInstance,hWin))      else        MessageBox(hInstance,'Cannot create application window, call to CREATEWINDOW failed!','Error Starting Program',MB_ICONSTOP)    end  else    MessageBox(hInstance,'Cannot register application class, call to REGISTERCLASS failed!','Error Starting Program',MB_ICONSTOP); end. ---------------------------------------------------------------------- Remy Lebeau · 2022-01-28 23:50 In Delphi, when TEdit.PasswordChar is set to any value other than #0, the EDIT window is created with the ES_PASSWORD window style, and if Visual Styles are enabled and PasswordChar='*' then an EM_SETPASSWORDCHAR message is NOT ISSUED to the window, thus allowing it to display its native default (and nice looking) asterisk dots. To rephrase - EM_SETPASSWORDCHAR is issued ONLY when Visual Styles are disabled, or the app specifies any character other than '*'. I have not looked at LCL's implementation yet, does it do the same thing?  Or does it force EM_SETPASSWORDCHAR regardless of the environment?