[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Creating/Using a Cbitmap from a resource only DLL

Posted on 1998-02-06
3
Medium Priority
?
316 Views
Last Modified: 2013-11-19
Using MSVC++ 5.0, Windows95

I created a Resource Only DLL following the instructions in the online help (pretty easy). I have a bitmap in that DLL called "IDB_P38_1024".

In my application, I load the DLL and I get a valid handle back. I then try to load the bitmap with LoadBitmap(), but the handle comes back NULL. I call GetLastError() and it returns 120, which means that this function is not supported on the platform. Huh??!  Here is the code I am trying to use:


      DWORD err;

      HINSTANCE h_library = LoadLibrary( "GSviews.dll" );

      HBITMAP h_p38_1024 = LoadBitmap( h_library, "IDB_P38_1024" );
 
      if( h_p38_1024 == NULL )
      {
            err = GetLastError();
      }

      CBitmap m_Bitmap_P38_1024.FromHandle( h_p38_1024 );

At the end here, I want to attach the HBITMAP handle I got from the DLL (when I get it to work) to a CBitmap object so I can manipulate it the way I have been (I used to have the bitmap right with the application). Is this the way to do it right? It was the only function I could find that used HBITMAP and CBitmap together ;)

Thanks,

Tom
0
Comment
Question by:gunn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 210 total points
ID: 1315698
Are you absolutely sure that the name of the resource is a string called IDB_P38_1024? My guess is that there is a resource identifier with that name but it really is a number. Then in that case, you should use

  LoadBitmap(h_library, MAKEINTRESOURCE(number));


0
 

Author Comment

by:gunn
ID: 1315699
Ok, thanks a lot; I looked in resource.h for the DLL and found that there was a #define IDB_P38_1024 101 , so I used 101 with your code and that did it.

Now though, what about the end of my question? Is using .FromHandle( h_P38_1024 ) the way to get a CBitmap object from the handle ?

Thanks again.
Tom

0
 

Author Comment

by:gunn
ID: 1315700
I think I figured it out. I used the member function .Attach() to attach the handle to a CBitmap object. Seems to work.

Tom
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question