void CEGControlBar::OnLButtonUp(UINT nFlags, CPoint point) { if ( m_bDragging ) { ReleaseCapture(); OnInvertTracker(m_dragRect); DWORD dwStyle = GetBarStyle(); int nMinHeight = GetSystemMetrics( SM_CYCAPTION ) + SPLITTER_SIZE*2; int nMinWidth = nMinHeight*4; if( ( dwStyle & CBRS_TOP ) == CBRS_TOP ) { m_iSize = point.y > nMinHeight ? point.y : nMinHeight; } else if( ( dwStyle & CBRS_BOTTOM ) == CBRS_BOTTOM ) { m_iSize = m_iSize - point.y; if ( m_iSize < nMinHeight ) m_iSize = nMinHeight; } else if( ( dwStyle & CBRS_RIGHT ) == CBRS_RIGHT ) { m_iSize = m_iSize - point.x; if ( m_iSize < nMinWidth ) m_iSize = nMinWidth; } else { m_iSize = point.x > nMinWidth ? point.x : nMinWidth; } GetParentFrame()->RecalcLayout(); } m_bDragging = FALSE; CControlBar::OnLButtonUp(nFlags, point); }
LRESULT CBrowsersToolbarDlg::HandleInitDialog(WPARAM wParam, LPARAM lParam) { LRESULT nStatus = CDialogBar::HandleInitDialog(wParam, lParam); CString sTitle; sTitle.LoadString(IDS_TOOLBARTITLE_BROWSERS); SetWindowText(sTitle); m_cIE.SubclassDlgItem(IDC_BUTTON_TOOLBAR_IE, this); m_cIE.LoadPNG(_T("IEXPLORE32.PNG"), 2); m_cFirefox.SubclassDlgItem(IDC_BUTTON_TOOLBAR_FIREFOX, this); m_cFirefox.LoadPNG(_T("FIREFOX32.PNG"), 2); m_cOpera.SubclassDlgItem(IDC_BUTTON_TOOLBAR_OPERA, this); m_cOpera.LoadPNG(_T("OPERA32.PNG"), 2); m_cSafari.SubclassDlgItem(IDC_BUTTON_TOOLBAR_SAFARI, this); m_cSafari.LoadPNG(_T("SAFARI32.PNG"), 2); SetBarStyle(GetBarStyle() | CBRS_FLYBY | CBRS_TOOLTIPS); EnableToolTips(TRUE); return nStatus; }
BOOL CTestList::Create( CWnd* pParentWnd ) { BOOL b = CSizingControlBarG::Create( _T("Test list"), pParentWnd, 1967, WS_CLIPCHILDREN ); SetSCBStyle(GetSCBStyle() | SCBS_SHOWEDGES | SCBS_SIZECHILD); if( !b ) return FALSE; SetBarStyle( GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC ); m_treeList.Create( WS_VISIBLE | WS_CHILD | TVS_LINESATROOT | TVS_HASBUTTONS | TVS_HASLINES | TVS_SHOWSELALWAYS, CRect( 0, 0, 0, 0 ), this, IDC_TREE ); if( !AddFilesFromPath( GetModulePath( NULL ) + _T("\\Test files\\"), TVI_ROOT ) ) { AddFilesFromPath( GetModulePath( NULL ) + _T("../../\\components\\QHTM\\Test\\Test files\\"), TVI_ROOT ); } CFont font; font.CreateStockObject( DEFAULT_GUI_FONT ); m_treeList.SetFont( &font ); return TRUE; }
void CEGPaneBar::OnSize(UINT nType, int cx, int cy) { CControlBar::OnSize(nType, cx, cy); CRect rc; DWORD dwStyle = GetBarStyle(); if ( (dwStyle & CBRS_LEFT ) == CBRS_LEFT ) { m_dragRect.SetRect( cx - SPLITTER_SIZE, 0, cx, cy); rc.SetRect( 0, 0, cx - SPLITTER_SIZE, cy ) ; } else if ( (dwStyle & CBRS_RIGHT ) == CBRS_RIGHT ) { m_dragRect.SetRect( 0, 0, SPLITTER_SIZE, cy); rc.SetRect( SPLITTER_SIZE, 0, cx, cy ) ; } else if ( (dwStyle & CBRS_TOP ) == CBRS_TOP ) { m_dragRect.SetRect( 0, cy - SPLITTER_SIZE, cx, cy); rc.SetRect( 0, 0, cx, cy - SPLITTER_SIZE ) ; } else { m_dragRect.SetRect( 0, 0, cx, SPLITTER_SIZE); rc.SetRect( 0, SPLITTER_SIZE, cx, cy) ; } if ( NULL != m_pszCaption ) rc.top += GetSystemMetrics( SM_CYCAPTION ) + SPLITTER_SIZE; if ( NULL != m_hPane ) ::MoveWindow( m_hPane, rc.left, rc.top, rc.Width(), rc.Height(), TRUE); }
HRESULT CTRiASToolBar::InitNew (void) { AFX_MANAGE_STATE(AfxGetModuleState()); ASSERT_VALID(this); ASSERT_VALID(m_pMainFrm); #if !defined(_USE_SEC_CLASSES) m_uiID = m_pMainFrm -> GetNextBarID(); if (!Create (m_pMainFrm, WS_CHILD|CBRS_ALIGN_TOP|CBRS_FLOATING, m_uiID)) return E_FAIL; SetBarStyle(GetBarStyle() | (CBRS_TOOLTIPS|CBRS_SIZE_FIXED)); EnableDocking (CBRS_ALIGN_ANY); m_pMainFrm -> AddNewBar (m_pIBar); // jetzt hier, damit alle von außen das geleiche tun können m_pMainFrm -> ShowControlBar (this, false, false); m_pMainFrm -> DockControlBar (this); TBBUTTON tb = { 25, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0L, 0, }; CToolBarCtrl &rTB = GetToolBarCtrl(); rTB.SetButtonSize (CSize(24, 23)); HRESULT hr = (rTB.InsertButton (0, &tb)) ? NOERROR : S_FALSE; if (S_OK == hr) // leeres Feld einfügen m_fHasDummySep = true; #endif // _USE_SEC_CLASSES return NOERROR; }
void CIVReBar::AdjustBorders () { DWORD dwStyle = GetBarStyle(); dwStyle &= ~CBRS_BORDER_ANY; dwStyle |= CBRS_BORDER_LEFT | CBRS_BORDER_3D; SetBarStyle(dwStyle); }
DialogBar::DialogBar( CFrameWnd* pParent, FontDlg* pDlg, UINT nIDTemplate, TCHAR* pszTitle, int nID, DWORD dwDockStyle, bool bUseMaxButton ) : // Call base class. inherited( bUseMaxButton ), // Init vars. m_pDlg ( pDlg ), m_nIDTemplate ( nIDTemplate ), m_pParent ( pParent ) { CRect rectFrame; m_pParent->GetWindowRect( rectFrame ); CSize szDlg = GetDialogSizeFromTemplate( nIDTemplate, pParent ); // determine the initial size of the docked dialog CSize dockSize; if(dwDockStyle & CBRS_ALIGN_LEFT || dwDockStyle & CBRS_ALIGN_RIGHT) dockSize = CSize(szDlg.cx+2*GetSystemMetrics(SM_CXSIZEFRAME) ,rectFrame.Height()); else if(dwDockStyle & CBRS_ALIGN_TOP || dwDockStyle & CBRS_ALIGN_BOTTOM) dockSize = CSize(rectFrame.Width(),szDlg.cy+2*GetSystemMetrics(SM_CYSIZEFRAME)); else dockSize = CSize(szDlg.cx,szDlg.cy); if ( !Create( pszTitle, pParent, dockSize, TRUE, nID // nID, must be unique across bars. ) ) { ASSERT( false ); return; // fail to create } // CBRS_SIZE_DYNAMIC allows the bar to be resized when floating SetBarStyle( GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC ); // Dock the control bar. EnableDocking( dwDockStyle ); }
void CGuiDockToolBarEx::UpdateBars() { DWORD dwstyle = GetBarStyle(); if (m_ArrayButton.GetSize() > 0) ShowWindow(SW_SHOW); else ShowWindow(SW_HIDE); }
void CEGControlBar::GetInsideRect( CRect& rc ) { GetClientRect(rc); DWORD dwStyle = GetBarStyle(); if ( (dwStyle & CBRS_LEFT ) == CBRS_LEFT ) { rc.right -= SPLITTER_SIZE; } else if ( (dwStyle & CBRS_RIGHT ) == CBRS_RIGHT ) { rc.left += SPLITTER_SIZE; } else if ( (dwStyle & CBRS_TOP ) == CBRS_TOP ) { rc.bottom -= SPLITTER_SIZE; } else { rc.top += SPLITTER_SIZE; } }
int CBCGPMSMToolBar::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CBCGPToolBar::OnCreate(lpCreateStruct) == -1) return -1; SetBarStyle((GetBarStyle () & ~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)) | CBRS_SIZE_DYNAMIC); SetBorders (); SetGrayDisabledButtons (FALSE); return 0; }
BOOL ULTooToolBar::SetHorizontal() { m_bVertical = FALSE; SetBarStyle((GetBarStyle() & ~CBRS_ALIGN_ANY) | CBRS_ALIGN_TOP); SetButtonInfo(COMBOBOX_INDEX, ID_TOOLCOMBOBOXID, TBBS_SEPARATOR, COMBOBOX_WIDTH); if (m_ToolBox.m_hWnd != NULL) { CRect rect; GetItemRect(COMBOBOX_INDEX, rect); m_ToolBox.SetWindowPos(NULL, rect.left, rect.top, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOCOPYBITS); m_ToolBox.ShowWindow(SW_SHOW); } return TRUE; }
void CEGControlBar::OnSize(UINT nType, int cx, int cy) { CControlBar::OnSize(nType, cx, cy); DWORD dwStyle = GetBarStyle(); if ( (dwStyle & CBRS_LEFT ) == CBRS_LEFT ) { m_dragRect.SetRect( cx - SPLITTER_SIZE, 0, cx, cy); } else if ( (dwStyle & CBRS_RIGHT ) == CBRS_RIGHT ) { m_dragRect.SetRect( 0, 0, SPLITTER_SIZE, cy); } else if ( (dwStyle & CBRS_TOP ) == CBRS_TOP ) { m_dragRect.SetRect( 0, cy - SPLITTER_SIZE, cx, cy); } else { m_dragRect.SetRect( 0, 0, cx, SPLITTER_SIZE); } CRect rc; GetInsideRect( rc ); OnResize ( rc ); }
void CEGPaneBar::OnLButtonUp(UINT nFlags, CPoint point) { if ( m_bDragging ) { ReleaseCapture(); OnInvertTracker(m_dragRect); DWORD dwStyle = GetBarStyle(); CRect rcCaption = GetCaptionRect(); int nMinHeight = rcCaption.Height() + SPLITTER_SIZE*2; int nMinWidth = nMinHeight*4; if( ( dwStyle & CBRS_TOP ) == CBRS_TOP ) { m_iSize = point.y > nMinHeight ? point.y : nMinHeight; } else if( ( dwStyle & CBRS_BOTTOM ) == CBRS_BOTTOM ) { m_iSize = m_iSize - point.y; if ( m_iSize < nMinHeight ) m_iSize = nMinHeight; } else if( ( dwStyle & CBRS_RIGHT ) == CBRS_RIGHT ) { m_iSize = m_iSize - point.x; if ( m_iSize < nMinWidth ) m_iSize = nMinWidth; } else { m_iSize = point.x > nMinWidth ? point.x : nMinWidth; } GetParentFrame()->RecalcLayout(); } m_bDragging = FALSE; BOOL bOldClosePressed = m_bClosePressed; m_bClosePressed = FALSE; if ( bOldClosePressed ) { ReleaseCapture(); CRect rcCloseButton = GetCloseButtonRect(); if ( rcCloseButton.PtInRect( point ) ) { HidePane( ); } else { InvalidateCaption(); } } CControlBar::OnLButtonUp(nFlags, point); }
CRect CEGPaneBar::GetCaptionRect() { CRect rc; GetClientRect(rc); if ( m_pszCaption ) { rc.bottom = GetSystemMetrics( SM_CYCAPTION ); DWORD dwStyle = GetBarStyle(); if ( (dwStyle & CBRS_LEFT ) == CBRS_LEFT ) { rc.right -= SPLITTER_SIZE; } else if ( (dwStyle & CBRS_RIGHT ) == CBRS_RIGHT ) { rc.left += SPLITTER_SIZE; } else if ( (dwStyle & CBRS_TOP ) == CBRS_TOP ) { //rc.top -= SPLITTER_SIZE; } else { rc.bottom += SPLITTER_SIZE; rc.top += SPLITTER_SIZE; } } else { rc.SetRect( 0, 0, 0, 0 ); } return rc; }
BOOL CScribbleBar::Create(CWnd* pParentWnd) { //if (!CToolBar::Create(pParentWnd) || !LoadToolBar(IDR_MAINFRAME)) // return FALSE; // Remove this if you don't want tool tips SetBarStyle(GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED); // By setting the button style of each the marker color buttons // to TBBS_CHECKGROUP, we ensure that only one may be depressed // at a time. SetButtonStyle(0, TBBS_CHECKGROUP); SetButtonStyle(1, TBBS_CHECKGROUP); SetButtonStyle(2, TBBS_CHECKGROUP); SetButtonStyle(3, TBBS_CHECKGROUP); //GetToolBarCtrl().CheckButton(IDB_BLACK_MARKER); return TRUE; }
void CDynToolBar::SetTitle(char* pTxt, BOOL SaveChange) { SetWindowText(pTxt); if (SaveChange) sTitle = pTxt; if ((GetBarStyle() & CBRS_FLOATING) && (GetStyle() & WS_VISIBLE)) { RECT Rect; CWnd* pWnd = GetParent(); if (pWnd && pWnd->GetParent()) { pWnd->GetParent()->GetWindowRect(&Rect); Location.x = Rect.left; Location.y = Rect.top; } //new title in floating toolbar is not shown unless the toolbar is docked and //then floated; ie unless the toolbar frame is re-created ShowWindow(SW_HIDE); //reduce flicker pTBMngr->pMainFrame->DockControlBar(this); ShowWindow(SW_SHOWNA); pTBMngr->pMainFrame->FloatControlBar(this, Location); } }
HRESULT CTRiASToolBar::GetBarStyleEx (LPSTR pName, ULONG ulLen, ULONG *pulWritten, DWORD *pdwStyle, DWORD *pdwStyleEx) { AFX_MANAGE_STATE(AfxGetModuleState()); ASSERT_VALID(this); ASSERT(::IsWindow(m_hWnd)); bool fOK = false; if (NULL != pdwStyle) { // Style abfragen *pdwStyle = GetBarStyle(); if (GetStyle() & WS_VISIBLE) *pdwStyle |= WS_VISIBLE; else *pdwStyle &= ~WS_VISIBLE; fOK = true; } if (NULL != pdwStyleEx) { *pdwStyleEx = m_dwFlags; #if defined(_USE_SEC_CLASSES) *pdwStyleEx |= m_dwExStyle; #endif // _USE_SEC_CLASSES } if (NULL != pName) { // Caption abfragen int iLen = GetWindowText (pName, ulLen); if (pulWritten) *pulWritten = iLen; fOK = true; } return fOK ? S_OK : S_FALSE; }
void CDynToolBar::LoadState(char* pFilename) { CProfINIFile PF(pFilename); CMDIFrameWnd* pM = pTBMngr->pMainFrame; Strng Section; Section.Set("ToolBar_%d", iWindowID); Strng NewTitle = PF.RdStr(Section(), "Title", (char*)(const char*)sTitle); if (NewTitle.Length()!=sTitle.GetLength() || strcmp(NewTitle(), (const char*)sTitle)!=0) { SetWindowText(NewTitle()); sTitle = NewTitle(); } DWORD BarStyle = GetBarStyle(); DWORD Style = GetStyle(); BarStyle = PF.RdLong(Section(), "BarStyle", BarStyle); BarStyle &= CBRS_ALL; //CNM Prevent an ASSERT SetBarStyle(BarStyle); if (bCanConfigure) { CToolBarCtrl& bc = GetToolBarCtrl(); int Cnt = bc.GetButtonCount(); Cnt = PF.RdInt(Section(), "ButtonIDCount", Cnt); BOOL Chngd = (Cnt!=bc.GetButtonCount()); UINT* NewIDs = new UINT[Cnt]; Strng Item; for (int i=0; i<Cnt; i++) { Item.Set("ID_%d", i); int Cmd = (i<(int)iLen ? BtnIDs[i] : ID_SEPARATOR); Cmd = PF.RdInt(Section(), Item(), Cmd); NewIDs[i] = (UINT)Cmd; Chngd = (Chngd || (NewIDs[i]!=BtnIDs[i])); } if (Chngd) ChangeButtons(NewIDs, Cnt); delete []NewIDs; } flag Visible = ((Style & WS_VISIBLE) != 0); Visible = PF.RdInt(Section(), "Visible", Visible); pM->ShowControlBar(this, Visible, FALSE); pM->RecalcLayout(); //get MFC to adjust the dimensions of all docked ToolBars so that GetWindowRect will be accurate CRect Rect; CWnd* pWnd = GetParent(); if (BarStyle & CBRS_FLOATING) { if (pWnd && pWnd->GetParent()) { if (PrjFileVerNo()>=25) { CRect MRect; AfxGetMainWnd()->GetWindowRect(MRect); Rect.OffsetRect(-MRect.left, -MRect.top); int L=PF.RdInt(Section(), "Left", Rect.left); int T=PF.RdInt(Section(), "Top", Rect.top); Rect.OffsetRect(L-Rect.left, T-Rect.top); Rect.OffsetRect(+MRect.left, +MRect.top); } else { pWnd->GetParent()->GetWindowRect(&Rect); Location.x = PF.RdInt(Section(), "Left", Rect.left); Location.y = PF.RdInt(Section(), "Top", Rect.top); } pM->FloatControlBar(this, Location); } } else { GetWindowRect(&Rect); if (PrjFileVerNo()>=25) { CRect MRect; AfxGetMainWnd()->GetWindowRect(MRect); Rect.OffsetRect(-MRect.left, -MRect.top); int L=PF.RdInt(Section(), "Left", Rect.left); int T=PF.RdInt(Section(), "Top", Rect.top); Rect.OffsetRect(L-Rect.left, T-Rect.top); Rect.OffsetRect(+MRect.left, +MRect.top); } else { //Rect.left = PF.RdInt(Section(), "Left", Rect.left); //Rect.top = PF.RdInt(Section(), "Top", Rect.top); int L=PF.RdInt(Section(), "Left", Rect.left); int T=PF.RdInt(Section(), "Top", Rect.top); Rect.right += L-Rect.left; Rect.bottom += T-Rect.top; Rect.left += L-Rect.left; Rect.top += T-Rect.top; } //Rect.top = PF.RdInt(Section(), "Top", Rect.top); UINT n = 0; if (BarStyle & CBRS_ALIGN_TOP) { Rect.top -= 1; Rect.bottom -= 1; n = AFX_IDW_DOCKBAR_TOP; } if (n==0 && BarStyle & CBRS_ALIGN_BOTTOM) { Rect.top += 1; Rect.bottom += 1; n = AFX_IDW_DOCKBAR_BOTTOM; } if (n==0 && BarStyle & CBRS_ALIGN_LEFT) { Rect.left -= 1; Rect.right -= 1; n = AFX_IDW_DOCKBAR_LEFT; } if (n==0 && BarStyle & CBRS_ALIGN_RIGHT) { Rect.left += 1; Rect.right += 1; n = AFX_IDW_DOCKBAR_RIGHT; } pM->DockControlBar(this, n, &Rect); } pM->RecalcLayout(); }
void CDynToolBar::SaveState(char* pFilename) { CProfINIFile PF(pFilename); Strng Section; //Section.Set("ToolBar%s_%d", gs_License.IsRunTime() ? "_rt" : "", iWindowID); Section.Set("ToolBar_%d", iWindowID); DWORD BarStyle = GetBarStyle(); DWORD Style = GetStyle(); CRect Rect; CWnd* pWnd = GetParent(); if (BarStyle & CBRS_FLOATING) { if (pWnd && pWnd->GetParent()) { pWnd->GetParent()->GetWindowRect(&Rect); if (PrjFileVerNo()>=25) { CRect MRect; AfxGetMainWnd()->GetWindowRect(MRect); Rect.OffsetRect(-MRect.left, -MRect.top); } PF.WrInt(Section(), "Left", Rect.left); PF.WrInt(Section(), "Top", Rect.top); } } else { if (pWnd) { //pWnd->GetWindowRect(&Rect); GetWindowRect(&Rect); if (PrjFileVerNo()>=25) { CRect MRect; AfxGetMainWnd()->GetWindowRect(MRect); Rect.OffsetRect(-MRect.left, -MRect.top); } //pWnd->ScreenToClient(&Rect); PF.WrInt(Section(), "Left", Rect.left); PF.WrInt(Section(), "Top", Rect.top); } } PF.WrStr(Section(), "Title", (char*)(const char*)sTitle); PF.WrLong(Section(), "BarStyle", BarStyle); flag Visible = ((Style & WS_VISIBLE) != 0); PF.WrInt(Section(), "Visible", Visible); if (bCanConfigure) { CToolBarCtrl& bc = GetToolBarCtrl(); const int Cnt = bc.GetButtonCount(); PF.WrInt(Section(), "ButtonIDCount", Cnt); Strng Item; TBBUTTON Btn; for (int i=0; i<Cnt; i++) { Item.Set("ID_%d", i); if (bc.GetButton(i, &Btn)) PF.WrInt(Section(), Item(), Btn.idCommand); else PF.WrInt(Section(), Item(), ID_SEPARATOR); } } }
int CDynToolBar::Create(BOOL ShowTitle, BOOL FloatIt, DWORD dwDockingStyle, DWORD dwBarStyle, BOOL Show, BOOL UseEscape) { DWORD dwStyle = WS_CHILD|CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY; if (Show) dwStyle |= WS_VISIBLE; if (bCanConfigure) dwStyle |= CCS_ADJUSTABLE; if (!CToolBar::Create(pTBMngr->pMainFrame, dwStyle, iWindowID)) return -1; //if (!SetButtons(pBtnIDs, iLen)) // return -2; BITMAP bm; bm.bmType = 0; bm.bmWidth = pTBMngr->BtnWidth * iBitLen * 8 / pTBMngr->BitsPixel; bm.bmHeight = pTBMngr->BtnHeight; bm.bmWidthBytes = pTBMngr->BtnWidth * iBitLen; bm.bmPlanes = 1; bm.bmBitsPixel = pTBMngr->BitsPixel; bm.bmBits = (LPVOID)pBits; if (!Bitmap.CreateBitmapIndirect(&bm)) return -3; CToolBarCtrl& bc = GetToolBarCtrl(); if (bc.AddBitmap(iBitLen/*(bButtonsOnce ? iBitLen : iLen)*/, &Bitmap)<0) return -4; if (!DoCreateButtons()) return -5; if (iTxtLen>0) { pTxtButtons = new CButton[iTxtLen]; UINT TxtCnt = 0; CRect rect; for (UINT i=0; i<iLen; i++) if (BtnStyles[i]==ButText) { SetButtonInfo(i, BtnIDs[i], TBBS_SEPARATOR, (BtnTxts[TxtCnt].GetLength()+3)*6); GetItemRect(i, &rect); pTxtButtons[TxtCnt].Create((const char*)(BtnTxts[TxtCnt]), WS_VISIBLE|WS_TABSTOP, rect, this, BtnIDs[i]); pTxtButtons[TxtCnt].SetFont(&(pTBMngr->Font)); TxtCnt++; } } if (iComboLen>0) { bComboListChanged = 0; const int nDropHeight = 100; pComboButtons = new CComboBox[iComboLen]; UINT ComboCnt = 0; CRect rect; for (UINT i=0; i<iLen; i++) if (BtnStyles[i]==ButCombo) { SetButtonInfo(i, BtnIDs[i], TBBS_SEPARATOR, 120); GetItemRect(i, &rect); rect.top = 3; rect.bottom = rect.top + nDropHeight; pComboButtons[ComboCnt].Create(CBS_DROPDOWN|CBS_AUTOHSCROLL|WS_VISIBLE|WS_TABSTOP, rect, this, ID_TOOLBAR_COMBO_0+ComboCnt);//BtnIDs[i]); pComboButtons[ComboCnt].SetFont(&(pTBMngr->Font)); ComboCnt++; } } if (iEditLen>0) { pEditButtons = new CEdit[iEditLen]; UINT EditCnt = 0; CRect rect; for (UINT i=0; i<iLen; i++) if (BtnStyles[i]==ButEdit) { SetButtonInfo(i, BtnIDs[i], TBBS_SEPARATOR, 120); GetItemRect(i, &rect); //rect.top = 3; //rect.bottom = rect.top + nDropHeight; pEditButtons[EditCnt].Create(WS_VISIBLE|WS_TABSTOP, rect, this, BtnIDs[i]);//ID_TOOLBAR_EDIT_0+EditCnt); pEditButtons[EditCnt].SetFont(&(pTBMngr->Font)); EditCnt++; } } SetBarStyle(GetBarStyle() | dwBarStyle); if (ShowTitle) SetWindowText((const char*)sTitle); EnableDocking(dwDockingStyle); if (FloatIt) pTBMngr->pMainFrame->FloatControlBar(this, Location); else pTBMngr->pMainFrame->DockControlBar(this); bUseEscape = UseEscape; bWasVisible = Show; return 0; }
BOOL CEGPaneBar::IsVertical() { DWORD dwStyle = GetBarStyle(); return ( dwStyle & CBRS_TOP) == CBRS_TOP || ( dwStyle & CBRS_BOTTOM ) == CBRS_BOTTOM; }
HRESULT CTRiASToolBar::AddButtons ( const TBBUTTON *pBttns, int iCnt, ITRiASUIOwner *pIOwner) { AFX_MANAGE_STATE(AfxGetModuleState()); ASSERT_VALID(this); ASSERT(::IsWindow(m_hWnd)); ASSERT(0 < iCnt); ASSERT(NULL != pBttns); // jetzt Owner zusammen mit dem ID speichern ... for (int i = 0; i < iCnt; i++) { if (pBttns[i].fsStyle & TBSTYLE_SEP && 0 == pBttns[i].idCommand) continue; // Separators not handled here pair<UIOwners::iterator, bool> p = m_Owners.insert (pBttns[i].idCommand, pIOwner); ASSERT(p.second); if (!p.second) return ResultFromScode (E_FAIL); } // ... und zur Toolbar hinzufügen #if !defined(_USE_SEC_CLASSES) // wenn dieses der erste Zugriff ist, dann Separator entfernen if (m_fHasDummySep) { DeleteItem (0); m_fHasDummySep = false; } CToolBarCtrl &rTB = GetToolBarCtrl(); HRESULT hr = rTB.AddButtons (iCnt, const_cast<TBBUTTON *>(pBttns)) ? NOERROR : ResultFromScode (S_FALSE); // jetzt Controls installieren DWORD dwStyle = GetBarStyle() & CBRS_ALIGN_ANY; for (int j = 0; j < iCnt; j++) { if (pBttns[j].fsStyle & TBSTYLE_SEP) { if (0 == pBttns[j].idCommand) continue; // Separators not handled here if (0 != pBttns[j].dwData) { HRESULT hr1 = reinterpret_cast<ITRiASBarInstallControl *>(pBttns[j].dwData) -> InstallControl (m_pIBar, pBttns[j].idCommand, dwStyle); if (SUCCEEDED(hr1)) { // Enable/Disable des neuen Controls CWnd *pWnd = GetDlgItem (pBttns[j].idCommand); pWnd -> EnableWindow (pBttns[j].fsState & TBSTATE_ENABLED); } } } } #else HRESULT hr = m_pMainFrm -> AddButtons (this, iCnt, pBttns, pIOwner); #endif // _USE_SEC_CLASSES if (S_OK == hr && IsWindowVisible()) m_pMainFrm -> DelayRecalcLayout(); return hr; }
BOOL CRRECToolBar::Create( CWnd* parent) { if (CreateEx(parent, TBSTYLE_FLAT | TBSTYLE_WRAPABLE, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP | CBRS_SIZE_DYNAMIC/* | WS_CLIPCHILDREN*/, CRect(0, 0, 0, 0), TOOLBAR_CONTROL) && LoadToolBar(TOOLBAR_CONTROL)) { SetImage(IDB_TOOLBAR, RGB(255, 0, 255)); // very important - turn OFF all the auto positioning and sizing // by default have no borders UINT nStyle = GetBarStyle(); // nStyle &= ~(CCS_NORESIZE | CCS_NOPARENTALIGN | CBRS_BORDER_ANY); nStyle |= (/*CBRS_SIZE_FIXED | */CBRS_TOOLTIPS | CBRS_FLYBY); SetBarStyle(nStyle); SetOwner(parent); GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS); // colour drop buttons int nIndex = CommandToIndex(BUTTON_BACKCOLOR); SetButtonStyle(nIndex, GetButtonStyle(nIndex) | TBSTYLE_DROPDOWN); nIndex = CommandToIndex(BUTTON_TEXTCOLOR); SetButtonStyle(nIndex, GetButtonStyle(nIndex) | TBSTYLE_DROPDOWN); ///////////////////////////////////// // Map in combo boxes // TBBUTTON buttons[] = { { 0, FONT_NAME_ID, 0, TBSTYLE_SEP, 0, NULL }, { 0, -1, 0, TBSTYLE_SEP, 0, NULL }, { 0, FONT_SIZE_ID, 0, TBSTYLE_SEP, 0, NULL }, { 0, -1, 0, TBSTYLE_SEP, 0, NULL }, }; const int BTNCOUNT = sizeof(buttons) / sizeof(TBBUTTON); for (int nBtn = 0; nBtn < BTNCOUNT; nBtn++) GetToolBarCtrl().InsertButton(nBtn, &buttons[nBtn]); CRect rect; TBBUTTONINFO tbi; tbi.cbSize = sizeof( TBBUTTONINFO ); tbi.cx = FONT_COMBO_WIDTH; tbi.dwMask = TBIF_SIZE; // By index // The font name combo GetToolBarCtrl().SetButtonInfo( FONT_NAME_ID, &tbi ); GetItemRect( FONT_NAME_POS, &rect ); rect.left++; rect.top++; rect.bottom += COMBO_HEIGHT; if (!m_font.Create( WS_CHILD | WS_VSCROLL | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST | CBS_SORT, rect, this, DROPDOWN_FONT )) return FALSE; m_font.SetFont( CFont::FromHandle( ( HFONT ) ::GetStockObject( DEFAULT_GUI_FONT ) ) ); m_font.FillCombo(); // The font size combo tbi.cx = COMBO_WIDTH; GetToolBarCtrl().SetButtonInfo( FONT_SIZE_ID, &tbi ); GetItemRect( FONT_SIZE_POS, &rect ); rect.top++; rect.bottom += COMBO_HEIGHT; if (!m_size.Create(WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST | CBS_HASSTRINGS, rect, this, DROPDOWN_SIZE )) return FALSE; m_size.SetFont( CFont::FromHandle( ( HFONT ) ::GetStockObject( DEFAULT_GUI_FONT ) ) ); m_size.FillCombo(); return TRUE; } return FALSE; }
void ULTooToolBar::InitControlWithULInfo(CWnd* pParentWnd) { CFDMSApp* pApp = (CFDMSApp*)AfxGetApp(); Create(pParentWnd); LoadToolBar(IDR_TOOLBAR1); DWORD sty = GetBarStyle(); SetBarStyle(sty | CBRS_TOOLTIPS | CBRS_FLYBY); EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM); SetWindowText(_T("Integrated Tools")); CRect rect(-COMBOBOX_WIDTH, -COMBOBOX_HEIGHT, 0, 0); // The ID of the ComboBox is important for two reasons. One, so you // can receive notifications from the control. And also for ToolTips. // During HitTesting if the ToolBar sees that the mouse is one a child // control, the toolbar will lookup the controls ID and search for a // string in the string table with the same ID to use for ToolTips // and StatusBar info. if (m_ToolBox.Create(WS_CHILD | CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | CBS_HASSTRINGS, rect, this, ID_TOOLCOMBOBOXID)) { HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); if (hFont == NULL) hFont = (HFONT)GetStockObject(ANSI_VAR_FONT); m_ToolBox.SendMessage(WM_SETFONT, (WPARAM)hFont); // determine if UL is available. UINT num_tools = 0; if (pApp->m_pRT_Init != NULL) num_tools = pApp->m_pRT_Init->Get_Tools_Num(); if (num_tools > 0) { const char * tool_name; unsigned int i, j; BOOL tool_status; m_bULToolsAvailable = true; j = 0; for (i=0; i<num_tools; i++) { tool_status = pApp->m_pRT_Init->Get_Tool_Installed (i); if (tool_status == FALSE) continue; tool_status = pApp->m_pRT_Init->Get_Data_Match_Tool (i); if (tool_status == FALSE) continue; tool_name = pApp->m_pRT_Init->Get_Tool_Name (i); m_ToolBox.InsertString(j, tool_name); m_ToolBox.SetItemData(j, i); j++; } } else m_ToolBox.InsertString(0, "None Available"); if (ULSupport::ULIRSDataPath.GetLength() > 5) // need something with suffix at least { // no UL no IRS no FacMgr or whtever so don't bother to check CheckForImportFileExistence(); SetTimer(TIMER_CHECKIMP,21000,0); // check every 21 seconds } } if(!SetHorizontal()) return; }
void CToolBarEx::SetTextOptions( ETextOptions eTextOptions, bool bUpdate /*=true*/ ) { ASSERT( ::IsWindow( m_hWnd ) ); ASSERT( GetStyle() & TBSTYLE_TOOLTIPS ); ASSERT( !( GetBarStyle() & CBRS_TOOLTIPS ) ); ASSERT( IsTextOptionAvailable( eTextOptions ) ); m_eTextOptions = eTextOptions; // Modify toolbar style according to new text options ModifyStyle( ( eTextOptions == toTextOnRight ) ? 0 : TBSTYLE_LIST, ( eTextOptions == toTextOnRight ) ? TBSTYLE_LIST : 0 ); CToolBarCtrl& tbCtrl = GetToolBarCtrl(); DWORD dwStyleEx = tbCtrl.GetExtendedStyle(); tbCtrl.SetExtendedStyle( ( eTextOptions == toTextOnRight ) ? ( dwStyleEx | TBSTYLE_EX_MIXEDBUTTONS ) : ( dwStyleEx & ~TBSTYLE_EX_MIXEDBUTTONS ) ); VERIFY( tbCtrl.SetMaxTextRows( ( eTextOptions == toNoTextLabels ) ? 0 : 1 ) ); if ( eTextOptions == toTextLabels ) { VERIFY( tbCtrl.SetButtonWidth( 0, 76 ) ); } // Modify all (even currently hidden ones) buttons in internal cache int nIndex; for ( nIndex = 0; nIndex <= m_aButtons.GetUpperBound(); nIndex++ ) { TBBUTTON& tbinfo = m_aButtons[ nIndex ].tbinfo; if ( !( tbinfo.fsStyle & TBSTYLE_SEP ) ) { CString strButtonText; GetButtonText( tbinfo.idCommand, strButtonText ); CString strToAdd( strButtonText, strButtonText.GetLength() + 1 ); tbinfo.iString = tbCtrl.AddStrings( strToAdd ); switch ( eTextOptions ) { case toTextLabels: tbinfo.fsStyle &= ~( TBSTYLE_AUTOSIZE | BTNS_SHOWTEXT ); break; case toTextOnRight: tbinfo.fsStyle |= ( TBSTYLE_AUTOSIZE | ( HasButtonText( tbinfo.idCommand ) ? BTNS_SHOWTEXT : 0 ) ); break; case toNoTextLabels: tbinfo.fsStyle &= ~BTNS_SHOWTEXT; tbinfo.fsStyle |= TBSTYLE_AUTOSIZE; break; } } } // If requested, reflect changes immediately if ( bUpdate ) { ReloadButtons(); UpdateParentBandInfo(); } }
BOOL COXSizeControlBar::IsProbablyFloating() { // used to check the dock bar status, but this has problems when we // docking/undocking - so check the actual bar style instead return (m_pDockBar == NULL || (GetBarStyle() & CBRS_FLOATING)); }