Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. using CBitmapButton

using CBitmapButton

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicstutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mavrock
    wrote on last edited by
    #1

    I am very new to programming. I have started using Visual C++ 6.0. I am not very familier yet with the terms used in programming. I would like to put a bitmap in place of mu button using CBitmapButton. I have looked over many different sites from MSDN to codeguru trying to find out how to do it. Either I get to the end and it doesn't work for some reason or the words being used are too advanced for me to understand. are there any simpler instructions for using CBitmapButton, on the web? Thank you.

    J J 2 Replies Last reply
    0
    • M Mavrock

      I am very new to programming. I have started using Visual C++ 6.0. I am not very familier yet with the terms used in programming. I would like to put a bitmap in place of mu button using CBitmapButton. I have looked over many different sites from MSDN to codeguru trying to find out how to do it. Either I get to the end and it doesn't work for some reason or the words being used are too advanced for me to understand. are there any simpler instructions for using CBitmapButton, on the web? Thank you.

      J Offline
      J Offline
      JohnnyG
      wrote on last edited by
      #2

      It's in MSDN. Here is it's example followed by my example. Make sure you do as it says and either call create with BS_OWNERDRAW or edit the button in the resource workshop and check on OwnerDraw in the properties for the button.

      Example

      CBitmapButton myButton;

      // Create the bitmap button (must include the BS_OWNERDRAW style).
      myButton.Create(NULL, WS_CHILD|WS_VISIBLE|BS_OWNERDRAW,
      CRect(10,10,100,100), pParentWnd, 1);

      // Load the bitmaps for this button.
      myButton.LoadBitmaps(IDB_UP, IDB_DOWN, IDB_FOCUS, IDB_DISABLE);

      I put this in the header file.

      CBitmapButton btnStop;
      CBitmapButton btnMonitor;

      Then in the .cpp's OnCreate() function....

      // now load the bitmaps for the CBitmapButton items
      if (!m\_wndToolBar.btnStop.LoadBitmaps(\_T("StopUp"), \_T("StopDown"), \_T("StopFocus"), \_T("StopDown")) ||
      	!m\_wndToolBar.btnMonitor.LoadBitmaps(IDB\_MONUP, IDB\_MONDOWN, IDB\_MONFOCUS, IDB\_MONDOWN) )
      {
      	TRACE0("Failed to load bitmaps for buttons\\n");
      	AfxThrowResourceException();
      }
      
      1 Reply Last reply
      0
      • M Mavrock

        I am very new to programming. I have started using Visual C++ 6.0. I am not very familier yet with the terms used in programming. I would like to put a bitmap in place of mu button using CBitmapButton. I have looked over many different sites from MSDN to codeguru trying to find out how to do it. Either I get to the end and it doesn't work for some reason or the words being used are too advanced for me to understand. are there any simpler instructions for using CBitmapButton, on the web? Thank you.

        J Offline
        J Offline
        Joan M
        wrote on last edited by
        #3

        If you want only to get a bitmap into the button CBitmapButton is Ok, but if you want more functionality (flat buttons, changing images depending on the mouse cursor...) without effort take a look at Davide Calabro's CButtonST, it's easy to use and will give you the possibility to use buttons as if you where programming in Delphi or VB (setting properties)... NOTE1: I'm novice too and it works fine for me... NOTE2: I'm new speaking english too... NOTE3: you can find CButtonSt and some other classes at codeproject in the button control related web page. Best regards..

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups