Capturing Previous Size Before Maximize Topic is solved

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
miclus
Can't get richer than this
Can't get richer than this
Posts: 747
Joined: Tue Mar 31, 2009 2:11 am

Capturing Previous Size Before Maximize

Post by miclus »

Hi. I'm trying to capture the previous size before my frame is maximized. I tried the EVT_MAXIMIZE, but it maximizes first, then gives me the size. The reason I want this is so when the program starts up and if the window is maximized, I can make the restore position the old size before it was maximized.
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Post by catalin »

You can save the size when EVT_SIZE event occurs and the window is not maximized.

But.. if you restore a maximized window it will automatically get the size it had before being maximized. Are you sure you need to save that size?
miclus
Can't get richer than this
Can't get richer than this
Posts: 747
Joined: Tue Mar 31, 2009 2:11 am

Post by miclus »

Yeah, the problem is that, when I close my app I save the size and stuff. But, let's say the windows is maximized. The saved size will be some big size and when I restart the program, it will be maximized, but the restore simply "slightly" sizes it lower than maximized. But, there may be an easier way to do this...
miclus
Can't get richer than this
Can't get richer than this
Posts: 747
Joined: Tue Mar 31, 2009 2:11 am

Post by miclus »

Hi, dude. The evt size isn't working either. It appears the function is called after the size change takes place. For instance, when my window is 800 x 600 and I maximized, by the time the evt size is called, it's already 1000 x 700 something or so. I need to get the size before it takes effect to the maximized size...
miclus
Can't get richer than this
Can't get richer than this
Posts: 747
Joined: Tue Mar 31, 2009 2:11 am

Post by miclus »

Here is what I'm trying to do. Say you open IE and it's 400 x 300. Then, you maximize. Then, you close it. When you reopen it, it's maximized. But, when you do restore, it's 400 x 300 again. How did it know to restore to 400 x 300 without saving it from the previous instance?
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Post by catalin »

Usually it helps to read the relevant docs when trying to implement something. If you do a search for "size" in wxWindow docs you'll get a bunch of results that I think are very relevant:
DoGetBestSize()
GetEffectiveMinSize()
GetBestSize()
and even SetInitialSize might help.

My advice: read, try, take a while before giving up.
miclus
Can't get richer than this
Can't get richer than this
Posts: 747
Joined: Tue Mar 31, 2009 2:11 am

Post by miclus »

Hi, Catalin. I want the size it was previously, regardless of what the program thinks is good. I read in MFC I need to look into an OnSizing() event as opposed to an OnSize() event. I'm thinking EVT_SIZE is more analogous to OnSize(). So, what is analogous to OnSizing(), the event when it's actually resizing?
ilovasz
Earned a small fee
Earned a small fee
Posts: 21
Joined: Tue Jul 10, 2007 6:56 pm

Post by ilovasz »

Hi.

How about using IsMaximized() to check if the given window is maximized and store it somewhere besides the window dimension? So when you next time launch the application it can check if a given window was maximized before closed and you can use Maximize() on that window...

LI
miclus
Can't get richer than this
Can't get richer than this
Posts: 747
Joined: Tue Mar 31, 2009 2:11 am

Post by miclus »

Right, it will remember being maximized. But, let's say the program starts up maximized. If I click restore, it simply goes to slightly less than maximized, rather than the real size it was before it was maximized in the previous program instance.
ilovasz
Earned a small fee
Earned a small fee
Posts: 21
Joined: Tue Jul 10, 2007 6:56 pm

Post by ilovasz »

Hi,

In the OnSize() event check if the window if Maximized.
If it's true don't store the current size value.

LI
miclus
Can't get richer than this
Can't get richer than this
Posts: 747
Joined: Tue Mar 31, 2009 2:11 am

Post by miclus »

Good idea!
miclus
Can't get richer than this
Can't get richer than this
Posts: 747
Joined: Tue Mar 31, 2009 2:11 am

Post by miclus »

Wait, one small glitch. When it starts up maximized, the status bar isn't at the bottom and is instead like in the middle of the window flickering. Here is the code I use:

Code: Select all

  g_main_frame = new MainFrame;
  g_main_frame->Initialize();
  g_main_frame->SetSize(getField("window", 0), getField("window", 1));
  g_main_frame->SetPosition(wxPoint(getField("window", 2), getField("window", 3)));
  g_main_frame->splitter->SetSashPosition(getField("window", 4));

  if (g_configuration->windowMaximized)
    g_main_frame->Maximize(true);
miclus
Can't get richer than this
Can't get richer than this
Posts: 747
Joined: Tue Mar 31, 2009 2:11 am

Post by miclus »

I have to do a restore for it to fix it, then the next maximize moves the status bar too...I tried doing an Update and Refresh, but no luck.
miclus
Can't get richer than this
Can't get richer than this
Posts: 747
Joined: Tue Mar 31, 2009 2:11 am

Post by miclus »

Hmmm. Well to fix it, I made it show the frame first, then maximize.
Post Reply