Page 1 of 1

wxFrame-border & -title-bar paint

Posted: Tue Feb 05, 2019 11:32 pm
by art-ganseforth

i work on a program, using some wxFrame-windows (wx 3.1.2). The application has a dark skin. So i want to get rid of the white Win10-window-borders and elements. But there are some problems with three things:
- There stays a small white top-border if the wxFrame is drawn without title-bar.
- If they have no title-bar and are created hidden, they stay white after showing them until they are resized manually.
- The same frames are not redrawn at all, after hiding them and showing them again. Resizing leads to artefacts.

Especially concerning the first point I wonder, if there is a solution for it (for the others i've workarounds).

Thank you,

Re: wxFrame-border & -title-bar paint

Posted: Wed Feb 06, 2019 4:32 pm
Did you try to use wxNO_BORDER style?

Here are the default frame borders. Maybe you should get rid of wxRESIZE_BORDER?

Thank you.

Re: wxFrame-border & -title-bar paint

Posted: Wed Feb 06, 2019 6:29 pm
by art-ganseforth
I need resizing. Currently i try to use the draw-event, to draw on wxScrennDC (having some problems with coorinates at the moment). If it works, i'll post it here. I think this is interesting not only for me...

Concerning the other points:
- Resizing the frame after showing it, shows its content at the first Show()-call
- The other problem was (missing content and artefacts) was something in my code

Re: wxFrame-border & -title-bar paint

Posted: Wed Feb 06, 2019 6:49 pm
by art-ganseforth
wxScreenDC won't work if the titlebar is covered by other windows. So i stop this...

Re: wxFrame-border & -title-bar paint

Posted: Wed Feb 06, 2019 8:27 pm
by doublemax
I need resizing.
So i guess that means that you have wxRESIZE_BORDER set?

In that case get rid of wxRESIZE_BORDER and handle the resizing yourself. You can't have the OS's resize behavior without the visible resize border.

Re: wxFrame-border & -title-bar paint

Posted: Wed Feb 06, 2019 8:42 pm
by art-ganseforth

Here is a raw programmed fix for this white top-border. It's a wxFrame covering it. It has to be created calling

Code: Select all

new clsBorderHelper(this);

Code: Select all

class clsBorderHelper : public wxFrame  {    wxWindow *Parent ;
        virtual void         OnParentRepos (wxEvent &event)  {     event.Skip();
            wxSize diff(Parent->GetSize()-Parent->GetClientSize()); //unfortunately GetWindowBorderSize() returns 0...
            this->SetPosition   (Parent->GetPosition()+wxPoint(diff.GetWidth()/2, 1));
            this->SetSize(wxSize(Parent->GetSize().GetWidth() - diff.GetWidth(), diff.GetHeight() / 2 ));
        clsBorderHelper(wxWindow *parent) : wxFrame (parent, -1, "", wxPoint(0,0), wxSize(0,0), 
             Parent = parent;
             Parent->Connect (wxEVT_MOVE, wxEventHandler(clsBorderHelper::OnParentRepos), NULL, this);
             Parent->Connect (wxEVT_SIZE, wxEventHandler(clsBorderHelper::OnParentRepos), NULL, this);
             SetBackgroundColour (wxColour("#330066")); //SetBackgroundColour(wxColour(Parent->GetBackgroundColour());
        ~clsBorderHelper() {             // might be better to use Destroy() or smth..          
              Parent->Disconnect (wxEVT_MOVE, wxEventHandler(clsBorderHelper::OnParentRepos), NULL, this);
              Parent->Disconnect (wxEVT_SIZE, wxEventHandler(clsBorderHelper::OnParentRepos), NULL, this);
} ;
It leaves one pixel on top for resizing, but it also might be easy, to connect some mouse-events, so that it's a full resize-border (but not transparent, as the others). Also it might be used as window-move-bar...


Re: wxFrame-border & -title-bar paint

Posted: Wed Feb 06, 2019 9:09 pm
by art-ganseforth

Calling Update() in OnParentRepos (wxEvent &event) after this->SetSize(...); reduces the delay of the covering frame...

Re: wxFrame-border & -title-bar paint

Posted: Wed Feb 06, 2019 9:53 pm
by art-ganseforth
And one more...

... working as resize-border (note the the destruchtor is probably not valid)...

Code: Select all

class clsBorderHelper : public wxFrame  {
    wxWindow *Parent ;
    wxPoint mp;
        void OnMouseMove   (wxMouseEvent &event) {
            wxPoint delta = event.GetPosition() - mp;
            Parent->SetPosition (Parent->GetPosition() + wxPoint (0, delta.y));
            Parent->SetSize     (Parent->GetSize    () - wxSize  (0, delta.y * 1.0));            
        void OnLeftDown    (wxMouseEvent &event) {      CaptureMouse(); 
            Connect        (wxEVT_MOTION, wxMouseEventHandler(clsBorderHelper::OnMouseMove), NULL, this);
            mp = event.GetPosition();
        void OnLeftUp      (wxMouseEvent &event) {      ReleaseMouse(); 
            Disconnect     (wxEVT_MOTION, wxMouseEventHandler(clsBorderHelper::OnMouseMove), NULL, this);
            Parent          ->SetFocus();
        void OnParentRepos (wxEvent &event) {   event.Skip();
            wxSize diff    (Parent->GetSize    () - Parent->GetClientSize());
            SetPosition    (Parent->GetPosition() + wxPoint(diff.GetWidth() / 2, 1));
            SetSize (wxSize(Parent->GetSize    ().GetWidth() - diff.GetWidth(), diff.GetHeight() / 2 ));
        clsBorderHelper(wxWindow *parent, wxColour c = wxColour("#132652")) : wxFrame(parent, -1, "", wxPoint(0,0), wxSize(0,0),
                                                wxNO_BORDER|wxFRAME_NO_TASKBAR|wxFRAME_FLOAT_ON_PARENT) {
            Parent = parent;
            Parent ->Connect (wxEVT_MOVE, wxEventHandler(clsBorderHelper::OnParentRepos), NULL, this);
            Parent ->Connect (wxEVT_SIZE, wxEventHandler(clsBorderHelper::OnParentRepos), NULL, this);

                     Connect (wxEVT_LEFT_DOWN, wxMouseEventHandler(clsBorderHelper::OnLeftDown), NULL, this);
                     Connect (wxEVT_LEFT_UP,   wxMouseEventHandler(clsBorderHelper::OnLeftUp  ), NULL, this);

            SetBackgroundColour (c);//Parent->GetBackgroundColour());
            this->SetCursor(wxCURSOR_SIZENS );
            Show ();
} ;
I marked this as soved, but for the issue with the not painted content when the wxFrame without title-bar is shown first, i use a workaround.
It's maybe a wxWidgets-problem (version 3.1.2 / win10 / MingW32)...

Source updated: Parent->Update(); in OnMouseMove(wxMouseEvent &event) makes it faster...
One more update: Added "Parent->SetFocus();" in OnLeftUp (wxMouseEvent &event). 1px Border is now perfectly drawn.