Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Multi-monitor dialog positioning bug [patch]

<< < (8/9) > >>

tiwag:
src/main.cpp:1418

--- Code: ---void MainFrame::OnFileOpen(wxCommandEvent& event)
{
    wxFileDialog* dlg = new wxFileDialog(this,
                            _("Open file"),
                            wxEmptyString,
                            wxEmptyString,
                            SOURCE_FILES_DIALOG_FILTER,
                            wxOPEN | wxMULTIPLE);
    dlg->SetFilterIndex(SOURCE_FILES_FILTER_INDEX);

    //PositionUserDialog(dlg);   <-- CRASHES ON  "dlg->CenterOnScreen();"  IF ENABLED

    if (dlg->ShowModal() == wxID_OK)
    {
        wxArrayString files;
        dlg->GetPaths(files);
        OnDropFiles(0,0,files);
    }

    delete dlg;
}
--- End code ---

it seems as are some windows-system dialogs not allowed to be CenterOnScreen'ed  8)

tiwag:
@280z
any comments ?

280Z28:
I had given up on this since there wasn't much interest expressed in patching this. I'll take a look again.

280Z28:
It's clearly a bug in wxWidgets, and it's even more clear that what I stated is the truth. A child dialog should open over the parent, end of story.

Every dialog in wxWidgets calls this when it is created:


--- Code: ---CentreOnParent();
--- End code ---

The centering bug lies in that code.

My code worked around that by calling:


--- Code: ---CentreOnScreen();
--- End code ---

which apparently works.

Note the following declarations from wxWidgets-2.6.2\include\wx\window.h:344


--- Code: ---        // the generic centre function - centers the window on parent by`
        // default or on screen if it doesn't have parent or
        // wxCENTER_ON_SCREEN flag is given
    void Centre( int direction = wxBOTH );
    void Center( int direction = wxBOTH ) { Centre(direction); }

        // centre on screen (only works for top level windows)
    void CentreOnScreen(int dir = wxBOTH) { Centre(dir | wxCENTER_ON_SCREEN); }
    void CenterOnScreen(int dir = wxBOTH) { CentreOnScreen(dir); }

        // centre with respect to the the parent window
    void CentreOnParent(int dir = wxBOTH) { Centre(dir | wxCENTER_FRAME); }
    void CenterOnParent(int dir = wxBOTH) { CentreOnParent(dir); }

--- End code ---

The code for Centre() that handles all of the above functionality is in wxWidgets-2.6.2\src\common\wincmn.cpp:394

I'll do a diff later of the file from the one in the wxWidgets trunk and see if any changes have been made to that code. Now I'm going bowling. :)

killerbot:
Very off topic : I went bowling yesterday.  :P

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version