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

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

Computer Links
(206) 575-3979
612 Industry Dr # 8
Tukwila, WA
Sagem Morpho Inc
(253) 383-3617
1145 Broadway Ste 200
Tacoma, WA
Ikon Office Solutions
(425) 885-6505
8383 158th Ave NE Ste 250
Redmond, WA
Data House Inc
(360) 647-1891
Bellingham, WA
Key Advice Inc
(425) 271-3826
Renton, WA
Bit Llc
(425) 251-0833
710 SW 34th St Apt B
Renton, WA
Chromix
(206) 526-8278
8320 5th Ave NE
Seattle, WA
Braaten's Services Inc
(360) 446-6080
PO Box 129
Rainier, WA
Asix Inc
(425) 635-0709
10900 NE 8th St Ste 700
Bellevue, WA
Mindcorps Inc
(206) 340-0475
1326 5th Ave
Seattle, WA

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

ClearStar.net

360-892-0687
915 Broadway
Vancouver, WA
http://www.clearstar.net

Related Articles
- Visual Basic .NET Attributes Kelso WA
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.
- JavaBean Proxies Kelso WA
- Extending CPictureHolder for loading BMP, JPG, etc. Kelso WA
- ListBox with Grayed Out / Non-Selectable Items Kelso WA
- Enumerate NT services Kelso WA
- Advanced C++/CLI Kelso WA
- Avoiding Boolean Overload Kelso WA
- Placing Logo on the Top DockBar of the Frame Window Kelso WA
- Interacting with .NET WinForms, Part 1 Kelso WA
- Audio Mixer Control Classes Kelso WA
Related Articles
- Visual Basic .NET Attributes Kelso WA
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.
- JavaBean Proxies Kelso WA
- Extending CPictureHolder for loading BMP, JPG, etc. Kelso WA
- ListBox with Grayed Out / Non-Selectable Items Kelso WA
- Enumerate NT services Kelso WA
- Advanced C++/CLI Kelso WA
- Avoiding Boolean Overload Kelso WA
- Placing Logo on the Top DockBar of the Frame Window Kelso WA
- Interacting with .NET WinForms, Part 1 Kelso WA
- Audio Mixer Control Classes Kelso WA
Related Local Events
2010 InnoTech
Dates: 5/6/2010 - 5/6/2010
Location: Oregon Convention Center
Portland, OR
View Details

WOOD TECHNOLOGY CLINIC & SHOW 2010
Dates: 3/9/2010 - 3/11/2010
Location: Oregon Convention Center
Portland, OR
View Details

Intellectual Property: Commercialization & Protection
Dates: 2/17/2010 - 2/17/2010
Location: AHA!
Vancouver, WA
View Details

January Forum: The future of Portland's media industry
Dates: 1/20/2010 - 1/20/2010
Location: Governor Hotel
Portland, OR
View Details

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