?
Solved

Creating/Using a Cbitmap from a resource only DLL

Posted on 1998-02-06
3
Medium Priority
?
314 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month10 days, 22 hours left to enroll

770 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