Solved

Creating/Using a Cbitmap from a resource only DLL

Posted on 1998-02-06
3
301 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
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 70 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
WinWaitActive parameters 12 31
Best tools for Backup and restore of Wordpress site 6 53
Window placement 17 65
Sed question 2 48
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now