Modifica della "Style=> Password" di una SingleLineEdit

We encourage new members to introduce themselves here. Get to know one another and share your interests.
veliero
Posts: 22
Joined: Sun Feb 25, 2018 11:28 pm

Modifica della "Style=> Password" di una SingleLineEdit

Post by veliero »

Salve a tutti,
utilizzo X# in ambiente XIDE ed ho un quesito da porre:
ho una DialogWindow con una SingleLineEdit (quella cerchiata in rosso)
1Cattura.JPG
1Cattura.JPG (42.86 KiB) Viewed 1474 times
a cui ho assegnato TRUE al campo "PASSWORD" nelle proprietà della DialogWindow
2Cattura.JPG
2Cattura.JPG (30.48 KiB) Viewed 1474 times
in modo da non far visulizzare i caratteri digitati.
Volevo ora attivare il controllo per cambiare al volo nella mia applicazione la possibilità di visualizzare i caratteri digitati tramite il Metodo ButtonClick grazie al checkBox "Mostra i caratteri" (cerchiato in blu nella prima immagine) ma non so poi come rimuovere lo style "PASSWORD" dalla mia SingleLineEdit (nell'HELP in linea non ho trovato supporto).
Qualcuno sa aiutarmi?

Grazie anticipatamente
Francesco
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Modifica della "Style=> Password" di una SingleLineEdit

Post by ic2 »

Hello Francesco,

What I have understood is that you can't change that. I actually never tried that in VO forms but I did try it in a WPF window where I put the little eye icon in front to let the user see what was typed, expecting WPF to somehow support that by default.

But no.

I had to put two controls on top of each other. When I keep the eye button pressed it displays the 'normal' one with the full password visible and otherwise the one with the password style on showing bullets.

I think you have to do the same; show and hide one of each with different styles depending on your checkbox.

Dick
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Modifica della "Style=> Password" di una SingleLineEdit

Post by Chris »

Hi Francesco,

Dick is right in that many styles cannot be modified at rutnime, but fortunately this one can actually be changed. Please try the following, it should do the trick:

Code: Select all

SendMessage( SELF:oDCcVecchia:Handle() , EM_SETPASSWORDCHAR , 0 , 0)
SELF:oDCcVecchia:RePaint()
.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Modifica della "Style=> Password" di una SingleLineEdit

Post by ic2 »

Hello Chris,

Ah, so the VO forms support run time change. It looks like this is possible in Winforms too (with TextBox.PasswordChar set to select a character and TextBox.TextMode:= TextBoxMode.Password) and you implemented that too, maybe because as VO forms are based on Winforms?

Only WPF doesn't seem to support that. But more than once WPF looked to me like a half finished product. Promising, but never finished.

Dick
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Modifica della "Style=> Password" di una SingleLineEdit

Post by Chris »

Hi Dick,

That's one of the few styles that apparently are supported in standard windows to be changed. In WinForms, you can actually change more or less all of them, they are using a trick as far as I know, they basically automatically re-create a new control with the new style, and they place it in the position of the old one, and then the old one gets destroyed.

Never got familiar enough with WPF to tell what happens there...

.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
veliero
Posts: 22
Joined: Sun Feb 25, 2018 11:28 pm

Modifica della "Style=> Password" di una SingleLineEdit

Post by veliero »

FANTASTICO Chris grazie, ho usato il tuo suggerimento ed in effetti funziona!:
3Cattura.JPG
3Cattura.JPG (38.79 KiB) Viewed 1474 times
Quando flaggo "Mostra caratteri" riesco a disabilitare lo style=>Password delle mie SingleLineEdit dove richiedo l'immissione della PASSWORD.
Ora volevo sapere, che parametri utilizzo nel SendMessage per ripristinare lo styile=>Password sulle mie SingleLineEdit?
Dimenticavo, grazie anche a Dick, ho capito cosa mi suggerisce ma nel mio caso è più semplice usare il trucco proposto da Chris.

Saluti
Francesco
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Modifica della "Style=> Password" di una SingleLineEdit

Post by Chris »

You're welcome Francesco!

In order to restore the password style, you need to use this:

Code: Select all

SendMessage( SELF:oDCSingleLineEdit1:Handle() , EM_SETPASSWORDCHAR , Asc("*") , 0)
SELF:oDCSingleLineEdit1:RePaint()
So actually you can use any character you want to hide the real characters. But of course "*" is the standard one.

.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
veliero
Posts: 22
Joined: Sun Feb 25, 2018 11:28 pm

Modifica della "Style=> Password" di una SingleLineEdit

Post by veliero »

Ciao Chris,
in effetti avevo già pensato di utilizzare questa tua soluzione nel mio codice:
4Cattura.JPG
4Cattura.JPG (95.64 KiB) Viewed 1474 times
tuttavia l'effetto che si ottiene utilizzando il carattere "*" è il seguente:
5Cattura.JPG
5Cattura.JPG (34.8 KiB) Viewed 1474 times
che differisce dalla situazione originale:
6Cattura.JPG
6Cattura.JPG (39.3 KiB) Viewed 1474 times
Premetto che nelle proprietà della SingleLineEdit ho impostato come Font: Microsoft San Serif 12
ma non so se questo può essere la causa della differente visualizzazione.

Saluti
Francesco
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Modifica della "Style=> Password" di una SingleLineEdit

Post by Chris »

Hi Francesco,

Hmm, I see that, too, after enabling visual styles in the app. Tried that:

SELF:Caption := AsString( SendMessage( SELF:oDCSingleLineEdit1:Handle() , EM_GETPASSWORDCHAR , 0 , 0) )

to get the actual character used, and this returns 9679, but when trying to set it back with

SendMessage( SELF:oDCSingleLineEdit1:Handle() , EM_SETPASSWORDCHAR , 9679 , 0)

then unfortunately it does not work properly, I assume it's because the VOGUI classes are ansi (not unicode) based and the last post here seems to confirm this: https://forums.wxwidgets.org/viewtopic.php?t=15093

Sorry, I don't know of another way to do this, but maybe someone else has some idea...

.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
User avatar
ArneOrtlinghaus
Posts: 384
Joined: Tue Nov 10, 2015 7:48 am
Location: Italy

Modifica della "Style=> Password" di una SingleLineEdit

Post by ArneOrtlinghaus »

I have my doubts with the possibilities of modifying this property "on the fly". I remember only that we had some problems many years ago. Perhaps it is better to add hidden single line edits without the password property and to switch to them.
But possibly something has also changed in the behavior how Microsoft is handling this mode.

Arne
Post Reply