Error wxGrid + Maximize/Minimize

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
tomicolon
In need of some credit
In need of some credit
Posts: 8
Joined: Thu Feb 22, 2018 7:40 pm

Error wxGrid + Maximize/Minimize

Post by tomicolon »

An error occurs when the grid has a lot of data, that is, it has a vertical scroll.
When it is maximized and then minimized, the grid expands, occupying the entire screen and losing half of the graphic interface

edit: I'm using Windows 10

Situation 1 : Maximixe

Start:
Error 1.png
Then Maximixe: Observe how half of the screen disappears showing only the expanded grid
Error 2.png

Situation 2: Minimize

Start:
Error 3.png
Error 3.png (52.5 KiB) Viewed 1506 times
Then Minimize:
Error 2.png

Any suggestions where to start reviewing?

Regards
Last edited by tomicolon on Sat May 19, 2018 2:17 pm, edited 1 time in total.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Error wxGrid + Maximize/Minimize

Post by ONEEYEMAN »

Hi,
Could you please show some code?

How the grid was created and how the sizer layout is done.

Thank you.
tomicolon
In need of some credit
In need of some credit
Posts: 8
Joined: Thu Feb 22, 2018 7:40 pm

Re: Error wxGrid + Maximize/Minimize

Post by tomicolon »

To develop the work I use the wxFormBuilder tool, I'll copy what the program generates
error 5.png

Here is the code for the sizer of the grid located above, if you need more precise information, please let me know

Code: Select all

this->SetSizeHints( wxDefaultSize, wxSize( -1,-1 ) );
this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );

wxBoxSizer* bSizer140;
bSizer140 = new wxBoxSizer( wxVERTICAL );

panel_facturacionCompra = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );



m_panelDetalles = new wxPanel( panel_facturacionCompra, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer1481;
bSizer1481 = new wxBoxSizer( wxVERTICAL );

wxBoxSizer* bSizer183;
bSizer183 = new wxBoxSizer( wxVERTICAL );
	
wxBoxSizer* bSizer112;
bSizer112 = new wxBoxSizer( wxHORIZONTAL );


wxBoxSizer* bSizer115;
bSizer115 = new wxBoxSizer( wxHORIZONTAL );
	
wxBoxSizer* bSizer133;
bSizer133 = new wxBoxSizer( wxVERTICAL );

m_button44 = new wxButton( m_panelDetalles, wxID_ANY, wxT("Agregar\nal detalle\n"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer133->Add( m_button44, 1, wxALL, 5 );
	
	

bSizer115->Add( bSizer133, 0, wxEXPAND, 5 );
	
wxBoxSizer* bSizer194;
bSizer194 = new wxBoxSizer( wxVERTICAL );

grilla_p = new wxGrid( m_panelDetalles, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTRANSPARENT_WINDOW );

grilla_p->CreateGrid( 0, 5 );
grilla_p->EnableEditing( false );
grilla_p->EnableGridLines( true );
grilla_p->EnableDragGridSize( false );
grilla_p->SetMargins( 0, 0 );
	
// Columns
grilla_p->SetColSize( 0, 39 );
grilla_p->SetColSize( 1, 138 );
grilla_p->SetColSize( 2, 223 );
grilla_p->SetColSize( 3, 134 );
grilla_p->SetColSize( 4, 130 );
grilla_p->EnableDragColMove( false );
grilla_p->EnableDragColSize( true );
grilla_p->SetColLabelSize( 30 );
grilla_p->SetColLabelValue( 0, wxT("ID") );
grilla_p->SetColLabelValue( 1, wxT("Codigo de barra") );
grilla_p->SetColLabelValue( 2, wxT("Nombre") );
grilla_p->SetColLabelValue( 3, wxT("Tipo") );
grilla_p->SetColLabelValue( 4, wxT("Marca") );
grilla_p->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
	
// Rows
grilla_p->EnableDragRowSize( true );
grilla_p->SetRowLabelSize( 1 );
grilla_p->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
	
// Label Appearance
grilla_p->SetLabelBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );
grilla_p->SetLabelFont( wxFont( 9, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("Tahoma") ) );
	
// Cell Defaults
grilla_p->SetDefaultCellFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) );
grilla_p->SetDefaultCellAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
bSizer194->Add( grilla_p, 1, wxEXPAND, 5 );
	
	
bSizer115->Add( bSizer194, 1, wxEXPAND, 5 );
	
bSizer183->Add( bSizer115, 1, wxEXPAND, 5 );
User avatar
doublemax
Moderator
Moderator
Posts: 19159
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Error wxGrid + Maximize/Minimize

Post by doublemax »

The (auto generated) sizer code is a little hard to follow.

What happens in you resize the window manually, is the layout correct then?

Try catching the wxMaximizeEvent and wxIconizeEvent, call Layout() inside the event handler and check if it fixes the issue.
Use the source, Luke!
tomicolon
In need of some credit
In need of some credit
Posts: 8
Joined: Thu Feb 22, 2018 7:40 pm

Re: Error wxGrid + Maximize/Minimize

Post by tomicolon »

doublemax wrote:The (auto generated) sizer code is a little hard to follow.

What happens in you resize the window manually, is the layout correct then?

Try catching the wxMaximizeEvent and wxIconizeEvent, call Layout() inside the event handler and check if it fixes the issue.

I do not know if I'm not understanding you, but the only event I can capture by clicking on the maximize box is wxSizeEvent.
I did not say it, but it's a dialog not a frame.

void cVAgregar_FactCompra::OnMaximize( wxSizeEvent& event ) {
Layout();
wxMessageBox("Layout() , On Maximize/Minimize");
}

Even if I do not do the sizer with the EXPAND property, observe how after maximizing and minimizing, it occupies the entire window
Error 6.png
Error 7.png
Error 7.png (52.71 KiB) Viewed 1425 times
Error 8.png
tomicolon
In need of some credit
In need of some credit
Posts: 8
Joined: Thu Feb 22, 2018 7:40 pm

Re: Error wxGrid + Maximize/Minimize

Post by tomicolon »

Another observation, if the top table is filled with fewer items, it shows me only a portion of the second sizer
Error 10.png
Error 10.png (53.37 KiB) Viewed 1425 times
Error 9.png


In this image there is more data loaded in the grid, and you can see that the second grid is not seen, but you can see the sizer of the total amount
Error 11.png
User avatar
doublemax
Moderator
Moderator
Posts: 19159
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Error wxGrid + Maximize/Minimize

Post by doublemax »

I do not know if I'm not understanding you, but the only event I can capture by clicking on the maximize box is wxSizeEvent.
Under Windows you should also get a wxMaximizeEvent and wxIconizeEvent.

http://docs.wxwidgets.org/trunk/classwx ... event.html
http://docs.wxwidgets.org/trunk/classwx ... event.html
Use the source, Luke!
Post Reply