Height of status bar?
-
Hello! How can I determine the height in pixels of status bars? The GetSystemMetrics function seems to give many such values, but doesn't support status bars?? Best regards
-
Hello! How can I determine the height in pixels of status bars? The GetSystemMetrics function seems to give many such values, but doesn't support status bars?? Best regards
Perhaps you could try getting the dimensions of the
CStatusBarCtrl
that is contained within aCStatusBar
? /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com -
Hello! How can I determine the height in pixels of status bars? The GetSystemMetrics function seems to give many such values, but doesn't support status bars?? Best regards
The size of a status bar is application-dependent. You'll need to take the height of the main window and then subtract other heights from it like caption, menu, non-client area, and border. There may be other values, too.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
-
Hello! How can I determine the height in pixels of status bars? The GetSystemMetrics function seems to give many such values, but doesn't support status bars?? Best regards
Get the window handle to the status bar's window. Then can call GetWindowRect. Take the height of the rectangle as the height of the status bar.
-
Get the window handle to the status bar's window. Then can call GetWindowRect. Take the height of the rectangle as the height of the status bar.
How can I get the handle? I tried the following from my View-class:
CMyView::OnInitialUpdate() { ... CRect rcStatusBar; CFrameWnd* pFrame = (CFrameWnd*) GetParent(); CStatusBar* pStatusBar = (CStatusBar*) pFrame->GetControlBar(AFX_IDW_STATUS_BAR); CStatusBarCtrl& statusBarCtrl = pStatusBar->GetStatusBarCtrl(); statusBarCtrl.GetWindowRect(rcStatusBar); ... }
But this leaves me with a CRect with the size of 0 height and 0 width... -
How can I get the handle? I tried the following from my View-class:
CMyView::OnInitialUpdate() { ... CRect rcStatusBar; CFrameWnd* pFrame = (CFrameWnd*) GetParent(); CStatusBar* pStatusBar = (CStatusBar*) pFrame->GetControlBar(AFX_IDW_STATUS_BAR); CStatusBarCtrl& statusBarCtrl = pStatusBar->GetStatusBarCtrl(); statusBarCtrl.GetWindowRect(rcStatusBar); ... }
But this leaves me with a CRect with the size of 0 height and 0 width...These are all MFC Window objects. It is possible that during the OnInitialUpdate that the true 'window' have not yet been created? You can check with:
::IsWindow(pFrame->m_hWnd)
and if that is not true, your windows don't exist yet, so all widnow rectangles will return empty rectangles. You might have to investigate something like RecalcLayout and call it from some other location once the windows exist.