[wxMSW], [wx3.1.1], How to make a wxPasswordEntryDialog always on top ? Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
tomay3000
Earned some good credits
Earned some good credits
Posts: 116
Joined: Mon Apr 24, 2017 4:23 am

[wxMSW], [wx3.1.1], How to make a wxPasswordEntryDialog always on top ?

Post by tomay3000 » Sat Nov 17, 2018 8:03 pm

Hello,
I wanted to make a wxPasswordEntryDialog always on top, Creating it with a NULL parent and with these two flags

Code: Select all

wxSTAY_ON_TOP | wxDIALOG_NO_PARENT
did not the trick.

I want the user to be presented with an always on top wxPasswordEntryDialog, so the dialog wont hide when he clicks away.

I this possible under Windows ?
How ?

Thank you for your understanding.

User avatar
doublemax
Moderator
Moderator
Posts: 13316
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: [wxMSW], [wx3.1.1], How to make a wxPasswordEntryDialog always on top ?

Post by doublemax » Sat Nov 17, 2018 10:18 pm

Using the application main window as parent and calling ShowModal() to show the dialog should be enough.
Use the source, Luke!

tomay3000
Earned some good credits
Earned some good credits
Posts: 116
Joined: Mon Apr 24, 2017 4:23 am

Re: [wxMSW], [wx3.1.1], How to make a wxPasswordEntryDialog always on top ?

Post by tomay3000 » Sat Nov 17, 2018 11:13 pm

doublemax wrote:Using the application main window as parent and calling ShowModal() to show the dialog should be enough.
At this stage the application main window has not been created yet. I am doing it in the application's OnInit level.

Here is how I did it, but with no luck :(

Code: Select all

bool MyApp::OnInit()
{
    wxString password;
    wxPasswordEntryDialog passwordEntryDialog(NULL,
            wxT("Entrez le mot de passe:"),
            wxT("Vérification du mot de passe"),
            wxEmptyString,
            wxTextEntryDialogStyle | wxSTAY_ON_TOP | wxDIALOG_NO_PARENT);
    int retCode = wxID_CANCEL;

    SetTopWindow(&passwordEntryDialog);

    for (;;)
    {
        if ((retCode = passwordEntryDialog.ShowModal()) == wxID_OK)
            if ((password = passwordEntryDialog.GetValue()) == wxT("admin"))
                break;
            else
                wxMessageBox(wxT("Votre mot de passe n'est pas valide!"),
                             wxT("Erreur"),
                             wxOK | wxICON_ERROR);
        else if (retCode == wxID_CANCEL)
            return false;
    }

    wxInitAllImageHandlers();

    MyFrame* frame = new MyFrame(NULL);
    frame->SetIcon(wxICON(aaaa)); // To Set App Icon
    frame->Show();
    SetTopWindow(frame);

    return true;
}

User avatar
doublemax
Moderator
Moderator
Posts: 13316
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: [wxMSW], [wx3.1.1], How to make a wxPasswordEntryDialog always on top ?

Post by doublemax » Sun Nov 18, 2018 3:11 pm

Apparenty the "style" parameter passed to passwordEntryDialog is not a standard wxWindow style.

This should work:

Code: Select all

wxPasswordEntryDialog passwordEntryDialog(NULL,
              wxT("Entrez le mot de passe:"),
              wxT("Vérification du mot de passe"),
              wxEmptyString,
              wxTextEntryDialogStyle );

passwordEntryDialog.SetWindowStyleFlag( passwordEntryDialog.GetWindowStyleFlag() | wxSTAY_ON_TOP );
Use the source, Luke!

tomay3000
Earned some good credits
Earned some good credits
Posts: 116
Joined: Mon Apr 24, 2017 4:23 am

Re: [wxMSW], [wx3.1.1], How to make a wxPasswordEntryDialog always on top ?

Post by tomay3000 » Sun Nov 18, 2018 5:39 pm

doublemax wrote:Apparenty the "style" parameter passed to passwordEntryDialog is not a standard wxWindow style.
Yes, indeed, your solution worked like a charm ;)

Big thanks to you. =D>

Post Reply