// sets the flags for a pane by the pane's index BOOL CStatusBarACT::SetPaneFlagsIndex(int nIndex, DWORD dwFlags/*=SBACTF_NORMAL*/) { // make sure array is big enough int nMax = GetStatusBarCtrl().GetParts(0, NULL); if (nIndex >= nMax || nIndex < 0) { return FALSE; } if ((dwFlags & SBACTF_CLICKFLAGMASK) == 0) { dwFlags |= SBACTF_DOUBLECLICK; // default to just double-click } if ((dwFlags & SBACTF_BUTTONFLAGMASK) == 0) { dwFlags |= SBACTF_LEFTBUTTON; // default to just left button } if (dwFlags & SBACTF_STRETCHY) { dwFlags &= ~SBACTF_AUTOFIT; SetPaneStyle(nIndex, GetPaneStyle(nIndex) | SBPS_STRETCH); } m_adwFlags.SetAtGrow(nIndex, dwFlags); return TRUE; }
void MPCStatusBar::PositionControls() { int h,v,s; GetStatusBarCtrl( ).GetBorders( h, v, s ) ; for(int i = 0; i < m_aPans.GetSize(); i++ ) { CRect rect; int index = CommandToIndex( m_aPans[i]->m_nPaneID ); GetItemRect(index,rect); if( (GetPaneStyle(index) & SBPS_NOBORDERS) == SBPS_NOBORDERS) m_aPans[i]->m_hWnd->MoveWindow(rect); else { rect.top+=v; rect.bottom-=v; rect.left+=h+s; rect.right-=(h+s); m_aPans[i]->m_hWnd->MoveWindow(rect); } } }
int CMSMToolBar::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMFCToolBar::OnCreate(lpCreateStruct) == -1) return -1; SetPaneStyle((GetPaneStyle () & ~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)) | CBRS_SIZE_DYNAMIC); SetBorders (); SetGrayDisabledButtons (FALSE); return 0; }
void CColorStatusBar::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { int iPane = lpDrawItemStruct->itemID; if (!(GetPaneStyle(iPane) & SBPS_DISABLED)) { CWnd *pParentWnd = GetParent(); ASSERT(pParentWnd != NULL); // parent window must exist // get pane's background color from parent window COLORREF BkColor = (COLORREF)pParentWnd->SendMessage( UWM_COLORSTATUSBARPANE, WPARAM(lpDrawItemStruct->hDC), iPane); CDC dc; dc.Attach(lpDrawItemStruct->hDC); // attach CDC object to device context CRect r(&lpDrawItemStruct->rcItem); dc.FillSolidRect(r, BkColor); dc.SetBkMode(TRANSPARENT); dc.SetTextAlign(TA_CENTER); dc.TextOut(r.left + r.Width() / 2, r.top, GetPaneText(iPane)); // must detach CDC object from device context, otherwise device // context would be destroyed when CDC object goes out of scope dc.Detach(); } }
bool CIVStatusBar::IsOverURL(CPoint pt, CString & rstr ) { if ( ! IsWindowEnabled() || !GetTopLevelParent()->IsWindowEnabled() ) return false; CStatusBarCtrl & sb = GetStatusBarCtrl(); int iPart = -1; CRect rc; for (int i=0; i < sb.GetParts(0, NULL); i++ ) { sb.GetRect (i, rc); if (rc.PtInRect(pt) && ( GetPaneStyle(i) & SBT_OWNERDRAW ) ) { iPart = i; break; } } if (iPart == -1) return false; if ( ! (GetPaneStyle(iPart) & SBPS_NOBORDERS) ) rc.InflateRect(-GetSystemMetrics(SM_CYBORDER), -GetSystemMetrics(SM_CXBORDER)); if (!rc.PtInRect(pt)) return false; CString strText = GetPaneText(iPart); CDC * pDC = GetDC(); CFont * pFont = GetFont(); CFont fntURL; GetLinkFont(fntURL); CFont * pOldFont = pDC->SelectObject (pFont); int x = CalcX (pDC, rc, strText); bool bFound = false; for (int i = 0; i < strText.GetLength();) { CSize szPos = FindURL (strText, i ); if (szPos.cx != -1) { CString strStart = strText.Mid (i, szPos.cx-i); CRect rcURL; x += pDC->GetTextExtent (strStart).cx; rcURL.left = x; pFont = pDC->SelectObject (&fntURL); CString strURL = strText.Mid(szPos.cx, szPos.cy); CSize szURL = pDC->GetTextExtent (strURL); x += szURL.cx; rcURL.right = x; rcURL.top = rc.top; rcURL.bottom = rc.top + szURL.cy; pDC->SelectObject (pFont); if (rcURL.PtInRect(pt)) { rstr = strURL; bFound = true; break; } i = szPos.cx + szPos.cy; } else break; } pDC->SelectObject (pOldFont); return bFound; }