2016-12-06 5 views
1

Ich verwende einen wxProgressDialog unter Windows. Immer wenn ich den Text im Dialogfeld ändere, wird das Dialogfeld neu formatiert, um den Text bestmöglich anzupassen. Dies führt dazu, dass der Dialog häufig verkleinert wird, was schrecklich aussieht.Wie kann ich die Größenanpassung von wxProgressDialog stoppen?

Ich versuchte SetMinSize und SetSizeHints, aber diese schienen keine Wirkung zu haben. SetSize scheint auch nicht zu funktionieren.

(Für Informationen, ist der Dialog Fortschritt der Dateiübertragung zeigen. Da jede Datei den vollständigen Pfad angezeigt übertragen wird. Diese variieren stark in die kontinuierliche Neudimensionierung führt.)

ist mein Code auf diesem Code basiert von den Proben:

static const int max = 100; 

wxProgressDialog dialog("Progress dialog example", 
         // "Reserve" enough space for the multiline 
         // messages below, we'll change it anyhow 
         // immediately in the loop below 
         wxString(' ', 100) + "\n\n\n\n", 
         max, // range 
         this, // parent 
         wxPD_CAN_ABORT | 
         wxPD_CAN_SKIP | 
         wxPD_APP_MODAL | 
         //wxPD_AUTO_HIDE | // -- try this as well 
         wxPD_ELAPSED_TIME | 
         wxPD_ESTIMATED_TIME | 
         wxPD_REMAINING_TIME | 
         wxPD_SMOOTH // - makes indeterminate mode bar on WinXP very small 
         ); 

bool cont = true; 
for (int i = 0; i <= max; i++) 
{ 
    wxString msg; 

    // test both modes of wxProgressDialog behaviour: start in 
    // indeterminate mode but switch to the determinate one later 
    const bool determinate = i > max/2; 

    if (i == max) 
    { 
     msg = "That's all, folks!\n" 
       "\n" 
       "Nothing to see here any more."; 
    } 
    else if (!determinate) 
    { 
     msg = "Testing indeterminate mode\n" 
       "\n" 
       "This mode allows you to show to the user\n" 
       "that something is going on even if you don't know\n" 
       "when exactly will you finish."; 
    } 
    else if (determinate) 
    { 
     msg = "Now in standard determinate mode\n" 
       "\n" 
       "This is the standard usage mode in which you\n" 
       "update the dialog after performing each new step of work.\n" 
       "It requires knowing the total number of steps in advance."; 
    } 

    // will be set to true if "Skip" button was pressed 
    bool skip = false; 
    if (determinate) 
    { 
     cont = dialog.Update(i, msg, &skip); 
    } 
    else 
    { 
     cont = dialog.Pulse(msg, &skip); 
    } 

    // each skip will move progress about quarter forward 
    if (skip) 
    { 
     i += max/4; 

     if (i >= 100) 
      i = 99; 
    } 

    if (!cont) 
    { 
     if (wxMessageBox(wxT("Do you really want to cancel?"), 
          wxT("Progress dialog question"), // caption 
          wxYES_NO | wxICON_QUESTION) == wxYES) 
      break; 

     cont = true; 
     dialog.Resume(); 
    } 

    wxMilliSleep(200); 
} 

if (!cont) 
{ 
    wxLogStatus(wxT("Progress dialog aborted!")); 
} 
else 
{ 
    wxLogStatus(wxT("Countdown from %d finished"), max); 
} 

}

+0

Ohne Ihren Code zu sehen, funktioniert unsere magische Glaskugel nicht gut. Wo nennst du Fit()? Ich hoffe nur auf wxProgressDialog ctor. – Ripi2

Antwort

1

Wenn Sie eine feste Größe möchten, müssen Sie wxGenericProgressDialog verwenden , scheint es keine Möglichkeit zu geben, den nativen Dialog, der standardmäßig unter den Systemen, die ihn unterstützen (Vista und später), zu verwenden, um seine Größe an seinen Inhalt anzupassen.

Verwandte Themen