avoid minimize window double click title bar

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
ui-dev
In need of some credit
In need of some credit
Posts: 3
Joined: Tue May 28, 2013 12:30 pm

avoid minimize window double click title bar

Post by ui-dev »

Hi everyone !

I'm quite new here, it's my first post :wink:

My english isn't perfect so i'll be quick : there's a behavior of my window, I wish to avoid , I have noticed that when one makes a double click on the title bar, the window is resized ( not iconized ), and I'd like to avoid this , I really don't see which is the best way to do this, if there's a clean way. I want my window to stay "maximized", or iconized, but not resizeable .

Thanks in advance !

Peter
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: avoid minimize window double click title bar

Post by doublemax »

Which platform?

Under Windows, doubleclicking the title bar does the same as clicking the "maximize" icon. You can avoid this by not passing the wxMAXIMIZE_BOX style flag when creating the frame.

The wxMAXIMIZE_BOX style flag is included in wxDEFAULT_FRAME_STYLE, so you could use
wxDEFAULT_FRAME_STYLE & ~wxMAXIMIZE_BOX instead.
Use the source, Luke!
ui-dev
In need of some credit
In need of some credit
Posts: 3
Joined: Tue May 28, 2013 12:30 pm

Re: avoid minimize window double click title bar

Post by ui-dev »

doublemax wrote:Which platform?
MS Windows XP Professional SP3
doublemax wrote:The wxMAXIMIZE_BOX style flag is included in wxDEFAULT_FRAME_STYLE, so you could usewxDEFAULT_FRAME_STYLE & ~wxMAXIMIZE_BOX instead

Code: Select all

// Here is the flags I use
wxCAPTION | wxMINIMIZE_BOX | wxCLOSE_BOX | wxSYSTEM_MENU

Code: Select all

// Here is the code I use at the application start
bool MyApp::OnInit( void )
{
    if( wxApp::OnInit() )
    {
        MainWindow * main_window = new MainWindow( _T("MyApp") ) ;

        main_window->Maximize() ;

        main_window->Show() ;

        return true ;
    }
    
    // ---- else ----

    return false ;
}
Thank you for your help, anyway !
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: avoid minimize window double click title bar

Post by doublemax »

This seems to be the "normal" behavior under Windows.

The only idea i have would be to disable the double click on the title bar at a low Windows level.

Override wxFrame::MSWWindowProc and put this code there:

Code: Select all

WXLRESULT MyFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
  if(nMsg==WM_NCLBUTTONDBLCLK) {
    return 0;
  }

  return wxFrame::MSWWindowProc(nMsg, wParam, lParam);
}
I didn't test that very much, so it could have some unwanted side effects. Use at your own risk ;)
Use the source, Luke!
ui-dev
In need of some credit
In need of some credit
Posts: 3
Joined: Tue May 28, 2013 12:30 pm

Re: avoid minimize window double click title bar

Post by ui-dev »

It works ! Thank you very much indeed :)
Post Reply