Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Button on the status bar. Collapse All
Subject Author Date
Jonas Gauffin Feb 22, 2006 - 3:50 AM

I have a button on the status bar that only should be visible at certain occations.
My problem is that it get’s visible when I resize the form, and It’s not me that makes it visible.

In CMainFrame::OnCreate:

    if (!m_statusBarProcessButton.Create(
        _T("Klar"),
        WS_CHILD|WS_TABSTOP,
        CRect(0,0,0,0),
        &m_wndStatusBar,
        IDC_PROCESS))
    {
        TRACE(_T("Failed to create button control.\n"));
        return -1;
    }
    m_wndStatusBar.SetPaneControl(m_statusBarProcessButton, IDS_PANE_PROCESS, false);
    m_statusBarProcessButton.ShowWindow(SW_HIDE);

Then I simply use ShowWindow to show/hide it.
Do you have any idea why it gets visible during resize?

Technical Support Feb 22, 2006 - 12:17 PM

You can just disable/enable the button when needed. If you still want to hide/show the button, make a small change in the CExtStatusControlBar class. Please find a call of the DeferWindowPos method call in the CExtStatusControlBar::RepositionControls() method and comment the SWP_SHOWWINDOW flag:

   _hDWP =
    ::DeferWindowPos(
     _hDWP, 
     hWnd, 
     NULL, 
     rcPane.left,
     rcPane.top, 
     rcPane.Width(), 
     rcPane.Height(),
     SWP_NOZORDER|SWP_NOOWNERZORDER
      |SWP_NOACTIVATE //|SWP_SHOWWINDOW
      |SWP_FRAMECHANGED
      |SWP_NOCOPYBITS
     );


Jonas Gauffin Feb 23, 2006 - 4:54 AM

Thank you for your suggestion. I’ve made a solution that preserves the visible state:

            int showWindowFlag = ::IsWindowVisible(hWnd) ? SWP_SHOWWINDOW : SWP_HIDEWINDOW;
            _hDWP =
                ::DeferWindowPos(
                    _hDWP,
                    hWnd,
                    NULL,
                    rcPane.left,
                    rcPane.top,
                    rcPane.Width(),
                    rcPane.Height(),
                    SWP_NOZORDER|SWP_NOOWNERZORDER
                        |SWP_NOACTIVATE|showWindowFlag
                        |SWP_FRAMECHANGED
                        |SWP_NOCOPYBITS
                    );

Technical Support Feb 23, 2006 - 10:10 AM

Yes, this solution is a correct as well. But we think that we don’t need to change the visible state at all. So to use SWP_SHOWWINDOW and SWP_HIDEWINDOW flags is unnecessary.