xsharp.eu • Modifica della "Style=> Password" di una SingleLineEdit
Page 1 of 2

Modifica della "Style=> Password" di una SingleLineEdit

Posted: Mon Apr 24, 2023 5:07 pm
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 1908 times
a cui ho assegnato TRUE al campo "PASSWORD" nelle proprietà della DialogWindow
2Cattura.JPG
2Cattura.JPG (30.48 KiB) Viewed 1908 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

Modifica della "Style=> Password" di una SingleLineEdit

Posted: Mon Apr 24, 2023 5:42 pm
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

Modifica della "Style=> Password" di una SingleLineEdit

Posted: Mon Apr 24, 2023 5:46 pm
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()
.

Modifica della "Style=> Password" di una SingleLineEdit

Posted: Mon Apr 24, 2023 8:00 pm
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

Modifica della "Style=> Password" di una SingleLineEdit

Posted: Mon Apr 24, 2023 11:25 pm
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...

.

Modifica della "Style=> Password" di una SingleLineEdit

Posted: Tue Apr 25, 2023 12:00 am
by veliero
FANTASTICO Chris grazie, ho usato il tuo suggerimento ed in effetti funziona!:
3Cattura.JPG
3Cattura.JPG (38.79 KiB) Viewed 1908 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

Modifica della "Style=> Password" di una SingleLineEdit

Posted: Tue Apr 25, 2023 7:01 am
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.

.

Modifica della "Style=> Password" di una SingleLineEdit

Posted: Tue Apr 25, 2023 2:41 pm
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 1908 times
tuttavia l'effetto che si ottiene utilizzando il carattere "*" è il seguente:
5Cattura.JPG
5Cattura.JPG (34.8 KiB) Viewed 1908 times
che differisce dalla situazione originale:
6Cattura.JPG
6Cattura.JPG (39.3 KiB) Viewed 1908 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

Modifica della "Style=> Password" di una SingleLineEdit

Posted: Tue Apr 25, 2023 11:55 pm
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...

.

Modifica della "Style=> Password" di una SingleLineEdit

Posted: Wed Apr 26, 2023 6:38 am
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