Tying an Attribute to a Control

From Hang The DJ
Jump to: navigation, search

ATTRIBUTE TIE-DOWN TO CONTROLS

On load:

           BOOL PlayDlg::OnInitDialog()
           |  m_pSongTable->Open( _T("Songs" ) );
              -----------------------------------
                 SongSet::Open()
                    m_pAttributes = new AttributeData[ m_nAttributesCount ];
              -----------------------------------
            |  // Create a control for each of the attributes of the song set.  
            |  // The attribute data was initialized when we opened the song set.
            |  // Then set them up and tie them down.  
            |  // This will also add the new controls to the column-control map.
            |  for ( nA = 0; nA < m_pMasterSong->m_nAttributesCount; nA++ )
             |     AddAttributeAccess( nA );
                 ----------------------------------
                 void PlayDlg::AddAttributeAccess()
                     pNewSlider->Initialize( 
                         &m_pMasterSong->m_pAttributes[ nAttribIndex ].byValue,
                         &m_pTempSong->m_pAttributes[ nAttribIndex ].byValue,
                         COL_COUNT + nAttribIndex
                     );


On dynamic attrib add:

           BOOL OptionsAttributesPage::OnApply()
              m_pPlayDlg->m_pTempSong->AddAttribute()
              ----------------------------
              bool SongSet::AddAttribute()
                  // Create a new array and copy the old contents over.
                  AttributeData* pNewAttribs = new AttributeData[ m_nAttributesCount ];
                  for ( int i = 0; i < ( m_nAttributesCount - 1 ); i++ )
                      pNewAttribs[i] = m_pAttributes[i];
              ----------------------------
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox