Jump to content
  • Advertisement
Sign in to follow this  
floatingwoods

Creating a toolbar through C-API

This topic is 3674 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

Hi, I made a dll that has a bunch of function. One of them creates a CFrameWnd window. Inside the function that creates my CFrameWnd, I can create a CToolBar object. However I now want the user of the dll to be able to attach a customized CToolBar object to that window (instead of the default CToolBar object that I created during window creation). So I thought I simply create the customized CToolBar object in the client application in the same way I did in the dll function. That however does not seem to work: in release mode the toolbar appears, but doesn't have any bitmap, in debug mode, I get a debug assertion error in following function of "afxwin1.inl":
_AFXWIN_INLINE HINSTANCE AFXAPI AfxGetInstanceHandle()
	{ ASSERT(afxCurrentInstanceHandle != NULL);
		return afxCurrentInstanceHandle; }

my toolbar is created (or rather I attempt to create my toolbar) in the client application with:
	CToolBar* toolBar;
	toolBar=new CToolBar();
	toolBar->CreateEx((CFrameWnd*)dllFunctionGetFrameWnd(),TBSTYLE_FLAT,WS_CHILD|WS_VISIBLE|CBRS_SIZE_DYNAMIC|CBRS_TOP|WS_CLIPCHILDREN|WS_CLIPSIBLINGS);

What can I possibly be doing wrong?

Share this post


Link to post
Share on other sites
Advertisement
Thank you LessBread. I had a look at CodeProject and might have found where my problem lies. I cannot test it right now but the mistake I could have done is that at the beginning of each exported dll function, I call following function:

void commonDllStartRoutine()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
}


I didn't realize that the macro AFX_MANAGE_STATE would loose its effect at the end of its scope! (so my calls to commonDllStartRoutine() don't have any effect it seems!)

Might that be my problem?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!