Code to View/Hide Status Bar in SDI and MDI Applications Pass Christian MS

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

Inacom Information Systems
(601) 362-4272
1920 Dunbarton Dr
Jackson, MS
Third Day Solutions Llc
(601) 847-9301
218 N West St
Mendenhall, MS
Logista
(601) 362-4272
1920 Dunbarton Dr
Jackson, MS
Ciber Inc
(601) 957-5131
3900 Lakeland Dr
Flowood, MS
D & L Systems
(601) 758-4990
1079 Highway 42
Sumrall, MS
Exact Solutions International
(228) 255-7199
Pass Christian, MS
Infinite Concepts Llcr
(662) 335-3513
537 Highway 82 E Ste 211
Greenville, MS
Consultrix Technologies
(601) 206-4624
405 Legacy Park
Ridgeland, MS
Software Plus
(601) 634-8496
3402 Wisconsin Ave Ste 10
Vicksburg, MS
Third Day Solutions Llc
(601) 957-7200
6360 I
Jackson, MS

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

Raven Software Systems Inc

504-367-6661
3201 General Degaulle DR
New Orleans, LA

Related Articles
- Advanced C++/CLI Pass Christian MS
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.
- Avoiding Boolean Overload Pass Christian MS
- JavaBean Proxies Pass Christian MS
- ListBox with Grayed Out / Non-Selectable Items Pass Christian MS
- Extending CPictureHolder for loading BMP, JPG, etc. Pass Christian MS
- Enumerate NT services Pass Christian MS
- Placing Logo on the Top DockBar of the Frame Window Pass Christian MS
- Interacting with .NET WinForms, Part 1 Pass Christian MS
- Visual Basic .NET Attributes Pass Christian MS
- Audio Mixer Control Classes Pass Christian MS
Related Articles
- Advanced C++/CLI Pass Christian MS
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.
- Avoiding Boolean Overload Pass Christian MS
- JavaBean Proxies Pass Christian MS
- ListBox with Grayed Out / Non-Selectable Items Pass Christian MS
- Extending CPictureHolder for loading BMP, JPG, etc. Pass Christian MS
- Enumerate NT services Pass Christian MS
- Placing Logo on the Top DockBar of the Frame Window Pass Christian MS
- Interacting with .NET WinForms, Part 1 Pass Christian MS
- Visual Basic .NET Attributes Pass Christian MS
- Audio Mixer Control Classes Pass Christian MS
Related Local Event
OCEANS 2009
Dates: 10/27/2009 - 10/29/2009
Location: Mississippi Coast Coliseum and Convention Center
Biloxi, MS
View Details

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