Code to View/Hide Status Bar in SDI and MDI Applications Springfield VA

Here's a little handler for the OnViewStatusBar message handler to change the "View/Hide Status Bar" menu option so that the application (main) window changes its height according to the size of the visible client area.

Local Companies

Advanced Systems Development Inc
703-998-3900
2800 S Shirlington RD
Arlington, VA
Ask1Expert
703-856-3855
2503-D North Harrison
Arlington, VA
Intelligent Software Solutions
703-416-4111
2001 Jefferson Davis Hwy
Arlington, VA
21st Century Systems
703-418-9333
2611 Jefferson Davis Hwy
Arlington, VA
Solution Technology Systems
703-522-2696
1600 Wilson Blvd
Arlington, VA
FronTech
703-9080651
4900 Leeseburg Pike
Alexandria, VA
Software Engineering Institute
703-908-8200
4301 Wilson Blvd
Arlington, VA
Software Development & Services Corporation
703-359-1380
2200 Wilson Blvd
Arlington, VA
Em Solutions Inc
703-413-3106
1421 Jefferson Davis Hwy
Arlington, VA
Sharp Business Systems
(571) 480-5647
1300 Wilson Blvd
Washington, DC

provided by: 
Originally published at Internet.com


Ever wanted to change the "View/Hide Status Bar" menu option so that the application (main) window changes its height accordingly preserving the size of the visible client area?

Here's a little handler for the OnViewStatusBar message handler to perform this task. Versions for MFC or Non-MFC available. // // OnViewStatusBar handler // // increase or decrease app window height to adapt to // visible or invisible status bar // void CMainFrame::OnViewStatusBar() // MFC version // by Volker Bartheld { CControlBar* pBar = GetControlBar(AFX_IDW_STATUS_BAR); if (pBar != NULL) { RECT AppWinRect, BarRect; GetWindowRect(&AppWinRect); pBar->GetWindowRect(&BarRect); int iBarHeight = BarRect.bottom - BarRect.top; BOOL bShow = (pBar->GetStyle() & WS_VISIBLE) == 0; ShowControlBar(pBar, bShow, FALSE); if (bShow) { // ... increase frame SetWindowPos(&CWnd::wndNoTopMost, AppWinRect.top, AppWinRect.left, AppWinRect.right-AppWinRect.left, AppWinRect.bottom- AppWinRect.top+iBarHeight, SWP_NOMOVE); } else { // ... decrease frame SetWindowPos(&CWnd::wndNoTopMost, AppWinRect.top, AppWinRect.left, AppWinRect.right-AppWinRect.left, AppWinRect.bottom-AppWinRect.top- iBarHeight, SWP_NOMOVE); } } } void CMainFrame::OnViewStatusBar() // non-MFC-version // by Alexander Sailer { // MFC StatusbarHandler aufrufen OnBarCheck(ID_VIEW_STATUS_BAR); CControlBar* pBar = NULL; BOOL bVisible(false); RECT AppWinRect, BarRect; int iBarHeight(0); // get ptr to status bar pBar = GetControlBar(ID_VIEW_STATUS_BAR); ASSERT(pBar); // Abme_ungen holen GetWindowRect(&AppWinRect); pBar->GetWindowRect(&BarRect); iBarHeight = BarRect.bottom - BarRect.top; // Abfrage ob Bar sichtbar ist bVisible = pBar->IsVisible(); if (bVisible)// ... increase frame { SetWindowPos(&CWnd::wndNoTopMost, AppWinRect.top, AppWinRect.left, AppWinRect.right-AppWinRect.left, AppWinRect.bottom-AppWinRect.top+iBarHeight, SWP_NOMOVE); } else // ... decrease frame { SetWindowPos(&CWnd::wndNoTopMost, AppWinRect.top, AppWinRect.left, AppWinRect.right-AppWinRect.left, AppWinRect.bottom-AppWinRect.top-iBarHeight, SWP_NOMOVE); } }

Downloads

Download source - 1 Kb

Author: Volker Bartheld

Read article at Internet.com site

Featured Local Company

FronTech

703-9080651
4900 Leeseburg Pike
Alexandria, VA

Related Articles
- Advanced C++/CLI Springfield VA
C++/CLI has a number of advanced features that make developing and maintaining applications easier. Discover how these allow types to be moved between assemblies without breaking existing application, allow fast and efficient interoperability between native functions, and make it possible to create functions that take a variable number of parameters while still maintaining type safety.
- JavaBean Proxies Springfield VA
- Interacting with .NET WinForms, Part 1 Springfield VA
- ListBox with Grayed Out / Non-Selectable Items Springfield VA
- Audio Mixer Control Classes Springfield VA
- Avoiding Boolean Overload Springfield VA
- Placing Logo on the Top DockBar of the Frame Window Springfield VA
- Enumerate NT services Springfield VA
- Visual Basic .NET Attributes Springfield VA
- Extending CPictureHolder for loading BMP, JPG, etc. Springfield VA
Related Articles
- Advanced C++/CLI Springfield VA
C++/CLI has a number of advanced features that make developing and maintaining applications easier. Discover how these allow types to be moved between assemblies without breaking existing application, allow fast and efficient interoperability between native functions, and make it possible to create functions that take a variable number of parameters while still maintaining type safety.
- JavaBean Proxies Springfield VA
- Interacting with .NET WinForms, Part 1 Springfield VA
- ListBox with Grayed Out / Non-Selectable Items Springfield VA
- Audio Mixer Control Classes Springfield VA
- Avoiding Boolean Overload Springfield VA
- Placing Logo on the Top DockBar of the Frame Window Springfield VA
- Enumerate NT services Springfield VA
- Visual Basic .NET Attributes Springfield VA
- Extending CPictureHolder for loading BMP, JPG, etc. Springfield VA
Related Local Events
National Facilities Management & Technology (NFMT)
Dates: 3/16/2010 - 3/28/2010
Location: Baltimore Convention Center
Baltimore, MD
View Details

DC Chamber Technology Series: Session 4
Dates: 12/10/2009 - 12/10/2009
Location: Robert H. Smith School at the Ronald Reagan Building and International Trade Center
Washington, DC
View Details

CSI 2009: The Next Phase In Security
Dates: 10/24/2009 - 10/30/2009
Location: Gaylord National Resort and Convention Center
National Harbor, MD
View Details

ACIs 3rd Annual Carbon Capture and Sequestration Summit
Dates: 9/14/2009 - 9/15/2009
Location: Omni Shoreham Hotel
Washington, DC
View Details

3rd Carbon Capture and Sequestration Summit
Dates: 9/14/2009 - 9/15/2009
Location: Omni Shoreham Hotel
Washington, DC
View Details

Topics: 
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML