Click here to Skip to main content
15,916,280 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralKey Combinations Pin
DarrollWalsh20-Oct-04 2:42
DarrollWalsh20-Oct-04 2:42 
Questionaccess CMainFrame? Pin
george ivanov20-Oct-04 2:36
george ivanov20-Oct-04 2:36 
AnswerRe: access CMainFrame? Pin
Vikram Kashyap20-Oct-04 2:55
Vikram Kashyap20-Oct-04 2:55 
GeneralVC6 Custom Appwizard Pin
abarbs20-Oct-04 2:23
abarbs20-Oct-04 2:23 
GeneralRe: VC6 Custom Appwizard Pin
Jim Crafton20-Oct-04 8:10
Jim Crafton20-Oct-04 8:10 
GeneralAdd -ins Pin
savilani120-Oct-04 2:01
savilani120-Oct-04 2:01 
GeneralRe: Add -ins Pin
Vikram Kashyap20-Oct-04 2:36
Vikram Kashyap20-Oct-04 2:36 
GeneralUsing resources from a dll in an exported class Pin
Jon Hulatt20-Oct-04 1:42
Jon Hulatt20-Oct-04 1:42 
Hi,

I have an MFC extension dll, which exports a class. The class is actually CStatic derived and uses several instances of the CImageButton from this site.

That class is exported from the dll using MFC's AFX_EXT_CLASS macro, and imported into my main exe with the same.

I want the CImageButton's in the dll-class to use bitmap resources from the DLL. But, in the code for CImageButton, it uses ::LoadBitmap to actually load the resource, the first argument of which uses AfxGetInstanceHandle() to get the HINSTANCE of the app. Of course, AfxGetInstanceHandle returns the HINSTANCE of the exe, so it all goes pete tong.

The only workaround i've found it to use a global variable of type HINSTANCE in the dll, and in DllMain to set the global var to store the HINSTANCE. Then use that HINSTANCE in place of AfxGetInstanceHandle.

Whilst it works, it doesn't seem "right"- it seems a bit of a bodge.

Is there a better way?

Thanks

Jon

using System.Beer;

GeneralRe: Using resources from a dll in an exported class Pin
Jim Crafton20-Oct-04 8:13
Jim Crafton20-Oct-04 8:13 
GeneralRe: Using resources from a dll in an exported class Pin
Jon Hulatt21-Oct-04 0:32
Jon Hulatt21-Oct-04 0:32 
QuestionHow do I do this? Pin
pubududilena20-Oct-04 0:49
pubududilena20-Oct-04 0:49 
AnswerRe: How do I do this? Pin
Maximilien20-Oct-04 2:43
Maximilien20-Oct-04 2:43 
GeneralRe: How do I do this? Pin
pubududilena20-Oct-04 18:04
pubududilena20-Oct-04 18:04 
GeneralRe: format of a zip (jar) file Pin
parths19-Oct-04 23:53
parths19-Oct-04 23:53 
Questionconvert jpg to bmp? Pin
Larsson19-Oct-04 22:47
Larsson19-Oct-04 22:47 
AnswerRe: convert jpg to bmp? Pin
Graham Bradshaw19-Oct-04 23:38
Graham Bradshaw19-Oct-04 23:38 
GeneralRe: convert jpg to bmp? Pin
Larsson19-Oct-04 23:41
Larsson19-Oct-04 23:41 
AnswerRe: convert jpg to bmp? Pin
pubududilena20-Oct-04 1:17
pubududilena20-Oct-04 1:17 
GeneralRe: convert jpg to bmp? Pin
Larsson20-Oct-04 1:41
Larsson20-Oct-04 1:41 
AnswerMicrosoft Paint Pin
SimpleProgramer20-Oct-04 3:10
SimpleProgramer20-Oct-04 3:10 
GeneralRe: Microsoft Paint Pin
Larsson20-Oct-04 3:12
Larsson20-Oct-04 3:12 
GeneralSave As -- Microsoft Paint Pin
SimpleProgramer20-Oct-04 3:17
SimpleProgramer20-Oct-04 3:17 
GeneralRe: Save As -- Microsoft Paint Pin
Larsson20-Oct-04 3:20
Larsson20-Oct-04 3:20 
AnswerRe: convert jpg to bmp? Pin
XIII20-Oct-04 3:59
XIII20-Oct-04 3:59 
Questionhow to know send data to device Pin
vc-programmer-19-Oct-04 22:31
vc-programmer-19-Oct-04 22:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.