Button mit Pfeil an der Seite



  • http://www.c-plusplus.net/forum/viewtopic.php?t=86569

    Weiß jemand, wie ich denselben Button in VC 6.0 hinbekomme?

    mfg



  • Hallo guest0!

    Du kannst mit dem u.a. Code-Schnippel beliebige Bitmaps auf einen Button malen.
    Die Bitmaps werden in den Resourcen des Projekts deklariert.
    Die nachfolgende Methode ist als Event-Handler des Views deklariert, welches den Button beinhaltet:

    void Ctest8View::OnPaint()
    {
      CBitmap bmp;
      if (bmp.LoadBitmap(IDB_BITMAP1))
      {
        // Get the size of the bitmap
        BITMAP bmpInfo;
        bmp.GetBitmap(&bmpInfo);
    
        // Create an in-memory DC compatible with the
        // display DC we're using to paint
        CDC dcMemory;
        dcMemory.CreateCompatibleDC(m_BitmapButton.GetDC());
    
        // Select the bitmap into the in-memory DC
        CBitmap* pOldBitmap = dcMemory.SelectObject(&bmp);
    
        // Find a centerpoint for the bitmap in the client area
        CRect rect;
        m_BitmapButton.GetClientRect(&rect);
    
        int nX = rect.left + (rect.Width() - bmpInfo.bmWidth) / 2;
        int nY = rect.top + (rect.Height() - bmpInfo.bmHeight) / 2;
    
        // Copy the bits from the in-memory DC into the on-
        // screen DC to actually do the painting. Use the centerpoint
        // we computed for the target offset.
        m_BitmapButton.GetDC()->BitBlt(nX, nY, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory, 0, 0, SRCCOPY);
      }
    }
    

    Viel Spaß beim Malen, Lothar.



  • Was soll ich denn damit? Ich will kein Bitmap dadrauf, sondern einen Button mit einem Pfeil auf der Seite, der ein Kontext Menü öffnet (wie im Link schon beschrieben).

    MfG


Anmelden zum Antworten