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

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

KGS Software Engineering
(802) 879-7848
Po Box 8286
Essex, VT
C Y Associates Inc
(802) 434-4994
420 Ridge Dr
Huntington, VT
Mbf Bioscience
(802) 288-9290
185 Allen Brook Ln
Williston, VT
Diversified Technology
(802) 885-6316
86 Chester Rd
Springfield, VT
Mosson Technologies
(802) 785-2246
2945 Route 5
Thetford, VT
Divergent Technology Group Inc
(802) 263-5195
Perkinsville, VT
Computer Concepts Inc
(802) 295-3089
Wrj
White River Junction, VT
West Hill Energy and Computing Inc
(802) 685-4424
Chelsea, VT
Soundshore Technology Group Llc
(802) 457-9235
39 Central St
Woodstock, VT
Divergent Technology Group Inc
(802) 263-9564
Perkinsville, VT

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

KGS Software Engineering

8028797848
Po Box 8286
Essex, VT
http://www.kgsse.com

Related Articles
- Visual Basic .NET Attributes Vermont
Attributes are classes that allow individual developers to extend VS.NET tools without rebuilding VS.NET each time. Many attributes are already available, but most of the interesting ones haven't even been written yet. Perhaps you will do so.
- Extending CPictureHolder for loading BMP, JPG, etc. Vermont
- Enumerate NT services Vermont
- Interacting with .NET WinForms, Part 1 Vermont
- JavaBean Proxies Vermont
- Advanced C++/CLI Vermont
- Audio Mixer Control Classes Vermont
- ListBox with Grayed Out / Non-Selectable Items Vermont
- Placing Logo on the Top DockBar of the Frame Window Vermont
- Avoiding Boolean Overload Vermont
Related Articles
- Visual Basic .NET Attributes Vermont
Attributes are classes that allow individual developers to extend VS.NET tools without rebuilding VS.NET each time. Many attributes are already available, but most of the interesting ones haven't even been written yet. Perhaps you will do so.
- Extending CPictureHolder for loading BMP, JPG, etc. Vermont
- Enumerate NT services Vermont
- Interacting with .NET WinForms, Part 1 Vermont
- JavaBean Proxies Vermont
- Advanced C++/CLI Vermont
- Audio Mixer Control Classes Vermont
- ListBox with Grayed Out / Non-Selectable Items Vermont
- Placing Logo on the Top DockBar of the Frame Window Vermont
- Avoiding Boolean Overload Vermont

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

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