/** * @brief writeRegister Method to append a whole registry. Add new element to database. * @param pFileName is the name of database file to add to. * @param pColumnData it's what to append. * @param columnPos is where to append it. */ bool writefile::writeRegister(string pFileName, array<char*>* pColumnData , array<char*>* pColumnNam){ int currSeek = file.tellg(); string standardDir = createNewFile(pFileName); file.open(standardDir.c_str()); bool isOpen = true; if(!file.is_open()){ cout << "NED " + pFileName << endl; return false; } file.seekg(K->ZE_ROW); int spacesToMove; int Csize; int lon = pColumnNam->getLenght(); array<char*> tempCDataArr = *pColumnData; array<char*> tempNames = *pColumnNam; array<int> ColumnPos (lon); string registerToWrite = K->EMPTY_STRING; string Cdata; const char* charT ; for (int i = K->ZE_ROW ; i < lon ; i++){ charT = tempNames[i]; string strToAdd(charT); ColumnPos[i] = getColumnNumber(&pFileName, &strToAdd); } //Get the register and fill the blanks. fillString (®isterToWrite , getRegisterSize()); for (int i = 0 ; i < ColumnPos.getLenght() ; i++){ Cdata = tempCDataArr[i]; checkString(&Cdata); Csize = columnSize(ColumnPos[i]); //Not sure spacesToMove = sizeUntilColumn(ColumnPos[i]); fillString(&Cdata ,Csize); registerToWrite.replace(spacesToMove , Csize , Cdata.c_str()); } if (file.is_open()){ file.seekg(K->ZE_ROW , ios::end); file << registerToWrite; } file.seekg(currSeek); file.close(); return isOpen; }
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(); } }
int CToolBarPopup::OnCreate( LPCREATESTRUCT lpCreateStruct ) { if ( CWnd::OnCreate( lpCreateStruct ) == -1 ) { return -1; } // Create embedded toolbar control if ( !m_tbCtrl.Create( TBSTYLE_FLAT | TBSTYLE_WRAPABLE | TBSTYLE_LIST | TBSTYLE_TOOLTIPS | CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_NORESIZE | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, CRect( 0, 0, 0, 0 ), this, m_pToolBar->GetDlgCtrlID() ) ) { return -1; } m_tbCtrl.SetExtendedStyle( TBSTYLE_EX_DRAWDDARROWS | TBSTYLE_EX_MIXEDBUTTONS ); VERIFY( m_tbCtrl.GetToolTips()->ModifyStyle( 0, TTS_ALWAYSTIP ) ); if ( CWinAppEx::GetInstance()->IsWinXP() ) { HRESULT hr = ::SetWindowThemeXP( m_tbCtrl.m_hWnd, L"", L"" ); ASSERT( SUCCEEDED( hr ) ); } // There could be only two modes, depending on text options // of the original toolbar: with or without text labels. ETextOptions eTextOptions = m_pToolBar->GetTextOptions(); m_bTextLabels = ( eTextOptions == toTextLabels ) || ( eTextOptions == toTextOnRight ); // Copy all required information from the original toolbar CToolBarCtrl& tbCtrl = m_pToolBar->GetToolBarCtrl(); m_tbCtrl.SetImageList( tbCtrl.GetImageList() ); m_tbCtrl.SetHotImageList( tbCtrl.GetHotImageList() ); m_tbCtrl.SetDisabledImageList( tbCtrl.GetDisabledImageList() ); CRect rcItem, rcClient; tbCtrl.GetClientRect( rcClient ); TBBUTTON tbinfo; int nMaxWidth = 0; int nButtons = tbCtrl.GetButtonCount(); int nIndex; for ( nIndex = 0; nIndex < nButtons; nIndex++ ) { tbCtrl.GetItemRect( nIndex, rcItem ); if ( rcItem.right > rcClient.right ) { VERIFY( tbCtrl.GetButton( nIndex, &tbinfo ) ); if ( !( tbinfo.fsStyle & TBSTYLE_SEP ) && !( tbinfo.fsState & TBSTATE_HIDDEN ) ) { CString strButtonText; m_pToolBar->GetButtonText( tbinfo.idCommand, strButtonText ); CString strToAdd( strButtonText, strButtonText.GetLength() + 1 ); tbinfo.iString = m_tbCtrl.AddStrings( strToAdd ); tbinfo.fsStyle |= TBSTYLE_AUTOSIZE | ( m_bTextLabels ? BTNS_SHOWTEXT : 0 ); VERIFY( m_tbCtrl.AddButtons( 1, &tbinfo ) ); VERIFY( m_tbCtrl.GetItemRect( m_tbCtrl.CommandToIndex( tbinfo.idCommand ), rcItem ) ); nMaxWidth = max( nMaxWidth, rcItem.Width() ); } } } nButtons = m_tbCtrl.GetButtonCount(); if ( nButtons == 0 ) { ASSERT( false ); // this should never happen return -1; } if ( m_bTextLabels ) { TBBUTTONINFO tbbi; tbbi.cbSize = sizeof( tbbi ); tbbi.dwMask = TBIF_SIZE | TBIF_STYLE; for ( nIndex = 0; nIndex < nButtons; nIndex++ ) { VERIFY( m_tbCtrl.GetButton( nIndex, &tbinfo ) ); tbbi.cx = ( WORD )nMaxWidth; tbbi.fsStyle = ( BYTE )( tbinfo.fsStyle & ~TBSTYLE_AUTOSIZE ); VERIFY( m_tbCtrl.SetButtonInfo( tbinfo.idCommand, &tbbi ) ); } } m_tbCtrl.AutoSize(); // Calc toolbar size if ( nButtons > 1 ) { m_tbCtrl.SetRows( nButtons, m_bTextLabels, rcClient ); } else { VERIFY( m_tbCtrl.GetItemRect( 0, rcClient ) ); } m_tbCtrl.MoveWindow( rcClient ); return 0; }