GetRubberStampMenuItems Example VC++

This example uses the GetRubberStampMenuItems method to populate a list box with the names of the rubber stamps that are currently available.  It also uses the GetRubberStampItem method to obtain the item number of the stamp that is currently selected.

You can use these methods when designing a custom tool palette to let users select the type of rubber stamp they want to use.

BOOL CStampList::OnInitDialog() 
{
    // Get the names of all available rubber stamps and
    // write them to a listbox.  This could be used when
    // designing a custom tool palette so that when the
    // user clicks on the stamp icon, they could then
    // select the desired stamp from a list.
    CDialog::OnInitDialog();
    CString strAllStamps;
    int intCurStamp;
    
    // Get the stamp list
    strAllStamps = m_pParent->ImgEdit1.GetRubberStampMenuItems();
   
    // Loop to parse stamps
    char sep[] = "\n";
    char *  token;

    /* Establish string and get the first token: */
    token = _tcstok( strAllStamps.GetBuffer(strAllStamps.GetLength()),sep);
    while( token != NULL )
    {
      m_StampList.AddString(token);
      token = _tcstok( NULL, sep );
    }
    // Highlight the stamp that is the currently selected stamp
    intCurStamp = m_pParent->ImgEdit1.GetRubberStampItem();
    m_StampList.SetCurSel(intCurStamp);

    return TRUE;  // return TRUE unless you set the focus to a control
                 // EXCEPTION: OCX Property Pages should return FALSE
}

void CStampList::OnOK() 
{
    // Get the index number of the stamp that was selected
    // in the list box
    m_intNewStamp = m_StampList.GetCurSel();
    // Set the selected stamp as the current stamp to be used.
    CDialog::OnOK();
}