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. Bitmap button dose not displayed

Bitmap button dose not displayed

Scheduled Pinned Locked Moved C / C++ / MFC
graphicslearning
2 Posts 2 Posters 3 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.
  • J Offline
    J Offline
    johnnyXP
    wrote on last edited by
    #1

    I have created a SDI application (with no Document/View) support. I 'm trying to attach a CBitmap button, but dose not displayed at all. Here is my code (that handles the WM_CREATE message on the CChildView class): int CChildView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CWnd::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here RECT rect; rect.left = 20; rect.right = rect.left + 20; rect.top = 100; rect.bottom = rect.top + 20; CBitmapButton bnPlay; if(bnPlay.Create(NULL, WS_CHILD|WS_VISIBLE|BS_OWNERDRAW, CRect(&rect), this, IDC_BN_PLAY)==0) { AfxMessageBox("BnPlay cannot be created", MB_ICONSTOP); return -1; } //IDB_BNPLAY is the resource bitmap bnPlay.LoadBitmaps(IDB_BNPLAY/*, 0, 0, 0*/); bnPlay.SizeToContent(); return 0; } The result of this code is an empty window... :mad:

    M 1 Reply Last reply
    0
    • J johnnyXP

      I have created a SDI application (with no Document/View) support. I 'm trying to attach a CBitmap button, but dose not displayed at all. Here is my code (that handles the WM_CREATE message on the CChildView class): int CChildView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CWnd::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here RECT rect; rect.left = 20; rect.right = rect.left + 20; rect.top = 100; rect.bottom = rect.top + 20; CBitmapButton bnPlay; if(bnPlay.Create(NULL, WS_CHILD|WS_VISIBLE|BS_OWNERDRAW, CRect(&rect), this, IDC_BN_PLAY)==0) { AfxMessageBox("BnPlay cannot be created", MB_ICONSTOP); return -1; } //IDB_BNPLAY is the resource bitmap bnPlay.LoadBitmaps(IDB_BNPLAY/*, 0, 0, 0*/); bnPlay.SizeToContent(); return 0; } The result of this code is an empty window... :mad:

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      The CWnd dtor destroys the window that the CWnd is managing, so when bnPlay goes out of scope, the button gets destroyed. --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | 1ClickPicGrabber | NEW~! CP SearchBar v3.0 | C++ Forum FAQ Strange things are afoot at the U+004B U+20DD

      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