Greetings,
I need to make wxDialog resistible by user but without border (thus, not using wxRESIZE_BORDER style). This ugly border doesn't fit in my dialog's appearance.
So I need to combine wxRESIZE_BORDER style with wxNO_BORDER.
Are there variants to solve the problem using features provided by wxWidgets or should I do resize by myself?
Allow user to resize wxDialog without border Topic is solved
-
- Earned some good credits
- Posts: 107
- Joined: Tue Aug 28, 2018 1:02 pm
- Location: Belarus
Re: Allow user to resize wxDialog without border
You can't get the OS's resize behavior without the wxRESIZE_BORDER flag. You'll have to implement that yourself.
This is not difficult in principle, but will require more code than you might expect. And on top of that, the default resize border is a clear indicator to the user that he can resize the window, which is important IMHO. So i'm not sure it's worth the effort.
This is not difficult in principle, but will require more code than you might expect. And on top of that, the default resize border is a clear indicator to the user that he can resize the window, which is important IMHO. So i'm not sure it's worth the effort.
Use the source, Luke!
-
- Earned some good credits
- Posts: 107
- Joined: Tue Aug 28, 2018 1:02 pm
- Location: Belarus
Re: Allow user to resize wxDialog without border
Could you please describe common algorithm how to implement it by myself?
Re: Allow user to resize wxDialog without border
In words:
Capture mouse move events. If mouse pointer is near the edge of the frame, change mouse cursor accordingly.
If the user clicks while near the edge, capture the mouse until the mouse is released.
While the mouse it captured, on mouse move, resize and move the window, depending on where the user grabbed the window (possibilities: 4 edges and 4 corners).
The "shaped" sample that comes with wxWidgets implements its own code to move the window. The approach is similar and could serve as a starting point.
Capture mouse move events. If mouse pointer is near the edge of the frame, change mouse cursor accordingly.
If the user clicks while near the edge, capture the mouse until the mouse is released.
While the mouse it captured, on mouse move, resize and move the window, depending on where the user grabbed the window (possibilities: 4 edges and 4 corners).
The "shaped" sample that comes with wxWidgets implements its own code to move the window. The approach is similar and could serve as a starting point.
Use the source, Luke!
-
- Earned some good credits
- Posts: 107
- Joined: Tue Aug 28, 2018 1:02 pm
- Location: Belarus
Re: Allow user to resize wxDialog without border
Tried to implement this solution:
This code works fine when I increase dialog's size (height), however when I try to decrease height (moving mouse up with left button pressed) dialog's height almost doesn't changed - it is decreased by 5-6 pixels and then size isn't changed.
Code: Select all
void wxRTSharesManagerDialog::OnLeftDown(wxMouseEvent& event)
{
CaptureMouse();
}
void wxRTSharesManagerDialog::OnLeftUp(wxMouseEvent& event)
{
if (HasCapture())
{
ReleaseMouse();
}
}
void wxRTSharesManagerDialog::OnMouseMove(wxMouseEvent& event)
{
wxPoint pt = event.GetPosition();
wxRect windowRect = this->GetRect();
if (windowRect.GetHeight() - pt.y < 5)
{
SetCursor(wxCURSOR_SIZENS);
if (event.Dragging() && event.LeftIsDown())
{
wxPoint pos = ClientToScreen(pt);
wxSize sz = GetSize();
sz.y += pos.y - windowRect.GetBottom();
SetSize(sz);
}
}
else
{
SetCursor(wxCURSOR_DEFAULT);
}
}
Re: Allow user to resize wxDialog without border
Code: Select all
if (windowRect.GetHeight() - pt.y < 5)
Use the source, Luke!