wxProgressDialog SetPosition Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Ollow_AM
Knows some wx things
Knows some wx things
Posts: 38
Joined: Fri Feb 26, 2010 10:22 am

wxProgressDialog SetPosition

Post by Ollow_AM »

Hallo Community,

is there any way to change the Position of a wxProgressDialog on Screen?

I try it with the funktion "wxProgressDialog->SetPosition()", but the Dialog is always showed at the same Position. :(
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxProgressDialog SetPosition

Post by PB »

You did not mention the platform or wxWidgets version.

I cannot confirm the issue on Windows using the current(ish) master, with both generic and native implementations: SetPosition() works as expected.

However, the native version displays centered upon showing for a very short time, before it gets moved to the requested position.

Code: Select all

#include <wx/wx.h>
#include <wx/progdlg.h>

class MyApp : public wxApp
{
public:
    bool OnInit() override
    {
        const size_t iterationCount = 25;
        wxGenericProgressDialog* dlg;
            
        if ( wxMessageBox("Use native wxProgressDialog?", "Native or Generic", wxYES_NO | wxYES_DEFAULT, nullptr) == wxYES )
            dlg = new wxProgressDialog("Iterating", " ", iterationCount, nullptr, wxPD_CAN_ABORT | wxPD_AUTO_HIDE);
        else
            dlg = new wxGenericProgressDialog("Iterating", " ", iterationCount, nullptr, wxPD_CAN_ABORT | wxPD_AUTO_HIDE);

        dlg->SetPosition(wxPoint(10, 10));

        for ( size_t i = 1; i <= iterationCount; ++i )
        {
            wxMilliSleep(500);
            if ( !dlg->Update(i, wxString::Format("Iteration %zu", i)) )
                break;
        }
        
        dlg->Destroy();
        return false;
    }
}; wxIMPLEMENT_APP(MyApp);
Ollow_AM
Knows some wx things
Knows some wx things
Posts: 38
Joined: Fri Feb 26, 2010 10:22 am

Re: wxProgressDialog SetPosition

Post by Ollow_AM »

Hello PB,

I have tried your postet code in smal projekt. It doesn't work on my System, the ProgressDialog is allwas showed in the middle of my Main-Window. Maybe it's the version 3.0.4

Sorry, forgot to write:
Plattform-Information:
wxWidgets : 3.0.4.
System: Windows 10 - 64 bit
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxProgressDialog SetPosition

Post by doublemax »

It might be possible that the native wxProgressDialog ignores the position (under Windows). With wxGenericProgressDialog it's expected to work. Haven't tested it though.

You can just change wxProgressDialog to wxGenericProgressDialog in your code to test it.
Use the source, Luke!
Ollow_AM
Knows some wx things
Knows some wx things
Posts: 38
Joined: Fri Feb 26, 2010 10:22 am

Re: wxProgressDialog SetPosition

Post by Ollow_AM »

Hello doublemax,
Hello PB,

okay, the wxGenericProgressDialog works fine, the positon of the ProgressDialog is changeed.
I think I'll rebuild my classes on these here

Thanks :D
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxProgressDialog SetPosition

Post by PB »

Ollow_AM wrote: Wed May 18, 2022 11:01 am Maybe it's the version 3.0.4
Yes, it is. SetPosition() for Windows native dialog was implemented in v3.1.1: https://github.com/wxWidgets/wxWidgets/ ... 4ba9372b0f
Post Reply