Code to View/Hide Status Bar in SDI and MDI Applications Gautier 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

Premise Inc
(601) 579-9475
7 Woodstone Plz Ste 6
Hattiesburg, MS
Integrated Concepts and Research Corp
(601) 636-6616
3516 Manor Dr
Vicksburg, MS
Grayco Systems
(601) 583-0430
201 Campbell Loop
Hattiesburg, MS
Carraway Computer Systems Llc
(601) 943-6838
6093 N Williamsburg Rd
Bassfield, MS
Inacom Information Systems
(601) 362-4272
1920 Dunbarton Dr
Jackson, MS
Scruggs & Associates
(601) 426-3419
542 Central Ave
Laurel, MS
Cisco Systems
(601) 957-5132
Jackson, MS
World Class Computers & Associates
(601) 376-0910
Jackson, MS
C A Business Consultants Inc
(601) 981-1438
2570 Bailey Ave Ste 9
Jackson, MS
Exact Solutions International
(228) 255-7199
Pass Christian, 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

i.t.works

6012640969
6641 hwy 98 west
hattiesburg, MS
http://www.thinkitworks.com

Related Local Events
December 2009 Gulf Coast Technology Council Meeting
Dates: 12/16/2009 - 12/16/2009
Location: ITT Technical Institute
Mobile, AL
View Details

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