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. LoadBitmap results in Assertion at AfxMakeResourceHandle

LoadBitmap results in Assertion at AfxMakeResourceHandle

Scheduled Pinned Locked Moved C / C++ / MFC
helpgraphics
5 Posts 2 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.
  • G Offline
    G Offline
    greekgoddj
    wrote on last edited by
    #1

    Greetings, Frustrations from yesterday.I am trying to load a bitmap into a CBitmap object. I have succesfully done this 100 times before but this time I get an assertion error caused at AfxMakeResourceHandle(). I am calling the LoadBitmap() function at the constructor so it only takes place ones, so its not a problem of loading a bitmap over an existing one. The image exists and the path is correct and the function is as follows: [code] m_bmKnob.LoadBitmap(IDB_51MAX); [/code] I have already made sure that there is no duplicate IDB number. Cannot find any informationm about this elsewhere. Something tells me its something very small and silly that I am missing but I have been going over and over it with no luck... :^) Thanks!

    G 1 Reply Last reply
    0
    • G greekgoddj

      Greetings, Frustrations from yesterday.I am trying to load a bitmap into a CBitmap object. I have succesfully done this 100 times before but this time I get an assertion error caused at AfxMakeResourceHandle(). I am calling the LoadBitmap() function at the constructor so it only takes place ones, so its not a problem of loading a bitmap over an existing one. The image exists and the path is correct and the function is as follows: [code] m_bmKnob.LoadBitmap(IDB_51MAX); [/code] I have already made sure that there is no duplicate IDB number. Cannot find any informationm about this elsewhere. Something tells me its something very small and silly that I am missing but I have been going over and over it with no luck... :^) Thanks!

      G Offline
      G Offline
      greekgoddj
      wrote on last edited by
      #2

      Some more details... According to MSDN AfxGetResourceHandle is: Use the HINSTANCE handle returned by this function to access the application's resources directly, for example, in calls to the Windows function FindResource. Example //Load the menu specifying the module handle where resource is to be //found & resource ID HMENU hMenu = ::LoadMenu(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_PANEL)); I have also tried: m_bmKnob.FromHandle(LoadBitmap(_AtlBaseModule.GetModuleInstance(), MAKEINTRESOURCE(IDB_51MAX))); That compiles and doesn't give an assertion, however later when the bitmap needs to be used it crashes as actually nothing was ever "sucessfully" loaded into theCBitmap file. Does this shed any light into possibilities? I willl post any progress as soon as there is some...have a nice weekend!

      C 1 Reply Last reply
      0
      • G greekgoddj

        Some more details... According to MSDN AfxGetResourceHandle is: Use the HINSTANCE handle returned by this function to access the application's resources directly, for example, in calls to the Windows function FindResource. Example //Load the menu specifying the module handle where resource is to be //found & resource ID HMENU hMenu = ::LoadMenu(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_PANEL)); I have also tried: m_bmKnob.FromHandle(LoadBitmap(_AtlBaseModule.GetModuleInstance(), MAKEINTRESOURCE(IDB_51MAX))); That compiles and doesn't give an assertion, however later when the bitmap needs to be used it crashes as actually nothing was ever "sucessfully" loaded into theCBitmap file. Does this shed any light into possibilities? I willl post any progress as soon as there is some...have a nice weekend!

        C Offline
        C Offline
        Chris Losinger
        wrote on last edited by
        #3

        are these resources in your EXE, or do they live in some external DLL ? Image Toolkits | Image Processing | Cleek

        G 1 Reply Last reply
        0
        • C Chris Losinger

          are these resources in your EXE, or do they live in some external DLL ? Image Toolkits | Image Processing | Cleek

          G Offline
          G Offline
          greekgoddj
          wrote on last edited by
          #4

          Hello, The project contains several ATL based ActiveX controls with MFC support, the resources are added to the project.

          G 1 Reply Last reply
          0
          • G greekgoddj

            Hello, The project contains several ATL based ActiveX controls with MFC support, the resources are added to the project.

            G Offline
            G Offline
            greekgoddj
            wrote on last edited by
            #5

            Well... it seems the answer is the following: [code] CBitmap myBitmap; AFX_MANAGE_STATE(AfxGetStaticModuleState()); myBitmap.LoadBitmap(IDB_SOMEBITMAP); [/code] Now I need to figure out what that all means! Ciao

            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