vc++ api question...........

hello folks,

i recently started playing with vc++ api for solidworks...

I have VC++ version 6.0 and SolidWorks 2001 plus...

i started with the solidworks add in app wizard which generated a skeleton application with a toolbar and a menu bar built in...

i tried to build a dialog box class which can be invoked from the toolbar and menu...however..the application hangs..immediately when the dialog box appears...

solidworks issues a message saying that solidworks has terminated due to an unhandled error...please contact your local support representative for help in troubleshooting this problem...

can anybody please tell me what the problem could be....

thanks in advance..

~sushil.

Reply to
Sushil
Loading thread data ...

This is a welcome message. Welcome in the wonderful world of c++ api! Seriously, this happens in most cases when your program crashes or does something wrong, you'll see it many times... What you have to do is:

1) run your program in the Visual Studio Debugger. 2) check the "Exceptions" under the "Debug" menu (visible only while running the debugger) and set at least c00000005 "Access violation" to "Stop Always". It might help to find what's wrong 3) put all your code in try/catch statements to exit smoothly from your add-in if something goes wrong. Hopefully, SW will be able to continue after that. Good luck!
Reply to
Philippe Guglielmetti

Found in the MSDN Library help about AFX_MANAGE_STATE By default, MFC uses the resource handle of the main application to load the resource template. If you have an exported function in a DLL, such as one that launches a dialog box in the DLL, this template is actually stored in the DLL module. You need to switch the module state for the correct handle to be used. You can do this by adding the following code to the beginning of the function:

AFX_MANAGE_STATE(AfxGetStaticModuleState( )); This swaps the current module state with the state returned from AfxGetStaticModuleState until the end of the current scope.

Example : void CTest::CreateAlias() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CDlgAlias dlg; dlg.DoModal(); }

It may correct your problem

P. Scanu

formatting link

"Sushil" a écrit dans le message de news: snipped-for-privacy@posting.google.com...

Reply to
Pascal Scanu

Hi Pascal,

I tried it out...but this is what I am getting...

mfcs42.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in Boring1.obj mfcs42.lib(dllmodul.obj) : error LNK2005: __pRawDllMain already defined in Boring1.obj mfcs42.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in Boring1.obj; second definition ignored mfcs42.lib(dllmodul.obj) : warning LNK4006: __pRawDllMain already defined in Boring1.obj; second definition ignored Creating library Boring1___Win32_MBCS_Release/Boring1.lib and object Boring1___Win32_MBCS_Release/Boring1.exp Boring1___Win32_MBCS_Release/Boring1.dll : fatal error LNK1169: one or more multiply defined symbols found Error executing link.exe.

Boring1.dll - 3 error(s), 2 warning(s)

Is there anything that I am missing again...please help me out...

~Sushil.

Reply to
Sushil

you're linking the wrong MFC dlls. In project settings, C/C++ tab, select "Multithreaded DLL" under "Use run-time library". You must select this for all libs or dlls your project is using.

Reply to
Philippe Guglielmetti

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.