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

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

Fontaine David A
(401) 766-0600
68 Cumberland St
Woonsocket, RI
Compu Abel Inc
(401) 284-1566
90 Spice Bush Trl
Narragansett, RI
Prism Solutions
(401) 312-0486
560 Mineral Spring Ave
Pawtucket, RI
Caccia Donna
(401) 766-0600
68 Cumberland St
Woonsocket, RI
Unicom
(401) 765-3000
1026 Park E Dr
Woonsocket, RI
Komputer Klinic the
(401) 921-4888
2845 Post Rd
Warwick, RI
Nesoft Corp
(401) 738-8081
2699 Post Rd Ste B
Warwick, RI
Herbalife Distributor
(401) 453-5600
92 Standish Ave
Providence, RI
Comprehensive Consulting Services
(401) 349-0011
24 B Lark Industril Par
Smithfield, RI
Application Design Services Llc
(401) 737-2040
250 Centerville Rd
Warwick, RI

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
Related Local Events
Fuel Cells 2009
Dates: 7/26/2009 - 7/31/2009
Location: Bryant University
Smithfield, RI
View Details

Gordon Research Conference - Organometallic Chemistry
Dates: 7/12/2009 - 7/17/2009
Location: Salve Regina University
Newport, RI
View Details

Nuclear Physics 2009
Dates: 7/12/2009 - 7/17/2009
Location: Bryant University
Smithfield, RI
View Details

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