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

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

Netsolutions
(414) 393-9500
9235 W Capitol Dr
Milwaukee, WI
A-Ware Software
(262) 717-2220
330 S Executive Dr
Brookfield, WI
PC Complete
(262) 886-1421
4107 Pennington Ln
Racine, WI
New Resources Consulting
(414) 289-7960
1000 N Water St
Milwaukee, WI
Pronto Progress
(262) 524-5500
W229N1433 Westwood Dr Ste 203
Waukesha, WI
ABC Computers
(608) 783-6911
2755 George St
La Crosse, WI
Technology Consulting Corp
(608) 246-2606
5315 Wall St Ste 105
Madison, WI
Transcendent
(262) 953-2750
N19W24400 Riverwood Dr Ste 220
Waukesha, WI
Dxd Consulting
(715) 292-1217
Washburn, WI
Traver Layton
(715) 381-5224
404 Red Brick Rd
Hudson, WI

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

KMSpecialties

414-751-4009
7434-3 Halverson Rd
Three Lakes, WI
http://www.KMSpecialties.com

Software Services
consulting
custom application and website development / programming
(ETL)data integration
software configuration
MS Access,Visual Basic, VB, VB.net, VBA, SQL
SQL Server, MySQL
PHP,HTML
Three Lakes,Rhinelander, Eagle River,
Minocqua,Tomahawk,Crandon,Wisconsin


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