Reputation: 190
I am using wxWIdgets to show a textbox and using
m_passwordText = new wxTextCtrl(m_panel, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(250, wxDefaultSize.GetHeight()), wxTE_PASSWORD);
I want to make this text visible sometimes and sometimes invisible(black dots). Is there any way that I can achieve this ?
Upvotes: 0
Views: 1247
Reputation: 2300
According to the wxWidgets 3.0 manual, you can do it with wxGTK but not wxMSW (windows).
WIth GTK, to dynamically change a textbox style, you can do something like this:
textbox->SetWindowStyle(wxTE_PASSWORD);
textbox->Refresh();
On Windows, it looks like there is a backdoor way to change it, with this:
bool hidepwd = true;
HWND hwnd = (HWND) textbox->GetHandle();
SendMessage(hwnd, EM_SETPASSWORDCHAR, hidepwd ? 0x25cf: 0, 0); // 0x25cf is ● character
textbox->Refresh();
There's an old discussion of doing this on the wxWidgets forum here: https://forums.wxwidgets.org/viewtopic.php?t=15093
Upvotes: 1