Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Menu Resources in DLLs

This topic is 5753 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a menu resource in a DLL and I am trying to do the following:
	wc.cbClsExtra		= NULL;
	wc.cbWndExtra		= NULL;
	wc.hbrBackground	= (HBRUSH)::GetStockObject( GRAY_BRUSH );
	wc.hCursor			= ::LoadCursor( NULL, IDC_ARROW );
	wc.hIcon			= ::LoadIcon( NULL, IDI_APPLICATION );
	wc.hInstance		= hInstance;
	wc.lpfnWndProc		= WinProc;
	wc.lpszClassName	= APP_NAME;
	wc.lpszMenuName		= MAKEINTRESOURCE( IDR_MENU1 );
	wc.style			= CS_HREDRAW | CS_VREDRAW;
This is just a small portion of your standed window setup code, the only difference being that it is called in a DLL. For some resion, MAKEINTRESOURCE gives me a bad pointer. Why is this? Is it because you cannot have menu resources in a DLL? the code works fine as long as its not in a DLL. Any Ideas?

Share this post

Link to post
Share on other sites
I am not sure if thiis will help as it is MFC based

The MSDN gives the following example code

  BOOL CMyApp::InitInstance()
//Default Appwizard code.

hRes= LoadLibrary("ResourceD.dll");
//Rest of wizard code

return CWinApp::InitInstance();

I am not sure about the SDK equivelent.

One approach could be to set ws.lpszMenuName to NULL
and then dynamincaly load the menu with LoadMenu(hRes,IDR_MENI1)
where hRes is the handle to the loaded DLL

Hope this helps

Share this post

Link to post
Share on other sites
Although I''ve never tried it, I don''t think you can mix/match modules when registering a class. That''s because you only have one instance variable to specify for both your winproc as well as your resources. So, if your winproc is in hInstance I think your menu you specify via RegisterClass must also be in that module.

What you could do is set the menu handle to NULL for the class and then use LoadMenu and SetMenu to set up the main window menu during CreateWindow WM_NCCREATE processing. The resource dll will have had to have been pre-loaded (via LoadLibrary as Box2020 mentioned, or via static linking) and you would need that dll''s module handle for use as the hInstance parm in the LoadMenu call.

Hope this helps.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!