Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,
i created my dialogboxe as dll in mfc.
and loading my icon in my dll like this

this->setIcon(Loadicon(AfxGetInstanceHandle() ,IDI_MYICON));

then load my dll in the app. but the icon did not display in the dialogbox.

any one can tell me reason abount this.And how i get the HInstance of the app Window in the dll dialogbox.

regards
jj
Posted
Comments
Ivan Ivanov 83 3-Nov-10 9:03am    
By "the icon did not display in the dialogbox" I'm guesing it didn't show in the upper left corner in the dialog frame just before the dialog's caption? If that's the case you can see hoe it's done in the default MFC dialog applications. It's like this:

HICON m_hIcon; // In the dialog class definition (the dialog that's in the DLL).

m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); //Inside the dialog's constructor.

And finally.. This code is inside the OnInitDialog
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

If you've created the DLL as a MFC DLL the 'theApp' should be available and hence you shouln't have any problem obtaining the hInstance of the DLL.
If you didn't create the project as a MFC DLL I advise you do.

I hope that helps :)
mahesh_mtech 6-Mar-14 7:17am    
this helped thank you
Ivan Ivanov 83 6-Mar-14 15:17pm    
You are welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900