SoloCodigo

Programación General => C/C++ => Visual C++ => Mensaje iniciado por: Davinia en Lunes 31 de Mayo de 2004, 14:19

Título: No Aparece Bitmap En Un Boton
Publicado por: Davinia en Lunes 31 de Mayo de 2004, 14:19
Hola,
tengo dos botones y quiero que aparezcan con la imagen de un bitmap pero no logro que aparezca la imagen y llevo un monton de tiempo intentandolo.
¿alguien me puede ayudar?

Gracias por adelantado.


/////CReprodBar.cpp
CReprodBar::CReprodBar()
{
   if (!stop2.LoadBitmaps(IDB_STOP2,IDB_STOP2D,IDB_STOP2) ||
      !play2.LoadBitmaps(IDB_PLAY2,IDB_PLAY2D,IDB_PLAY2))
   {
      TRACE0("Failed to load bitmaps for buttons\n");
      AfxThrowResourceException();
   }
}

void CReprodBar::InitButtons()
{   
   VERIFY(stop2.SubclassDlgItem(ID_STOP2, this));
   //stop2.SizeToContent();  //sizeToContent se encarga de ajustar el boton al tamaño del
bitmap
   VERIFY(play2.SubclassDlgItem(ID_PLAY2, this));
   //play2.SizeToContent();
}


/////Reprod.h
    ...
protected:
   CReprodBar m_pDlgBar;
    ...


/////ReprodBar.h

class CReprodBar : public CDialogBar
{
public:
   void InitButtons();

    ...
protected:
   CBitmapButton stop2, play2;



//////Reprod.h

int CReprod::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
   if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
      return -1;
   
   // TODO: Add your specialized creation code here
   if (!m_pDlgBar.Create(this,IDD_REPRODBAR,CBRS_BOTTOM,IDD_REPRODBAR))
   {
      TRACE0("Failed to create toolbar\n");
      return -1;      // fail to create
   }

   m_pDlgBar.InitButtons();
   
   ...
}
Título: Re: No Aparece Bitmap En Un Boton
Publicado por: navisoft en Miércoles 2 de Junio de 2004, 00:53
Para no complicarte con este metodo, puedes implementar botones iconizados con una clase que implementé:

Los botones se ven de esta manera:

(http://www.programacion.uni.cc/prj/vc/imagebutton/imagebutton.gif)

Programacion.uni.cc (http://www.programacion.uni.cc)

Espero que te sirva... ;)