Hi Colin I'd say Ned's answer is spot on. We've also done this sort of thing in the past and I thought you might be interested in a problem we had - or rather the solution to it.
What happened was that we displayed a dialog from a DLL function call and as soon as it was closed MapInfo would crash. The DLL function we were calling from MapInfo took a string as a parameter. It turned out that this was the problem - the string came across fine and if we did not open a dialog box MapInfo continued to run after the dialog was closed. Removing the string from the function solved the problem and everything worked fine after that. We never really got to the bottom of why this caused a crash (I suspect it may have something to do with different calling conversions - but that's just a guess) but since it took us ages to fine the problem I thought I'd warn you in advance just in case. Hope this is useful Gavin -----Original Message----- From: Ned Harding [mailto:[EMAIL PROTECTED]] Sent: 27 January 2003 21:33 To: Colin Henderson; MI-L List (E-mail) Subject: RE: MI-L MI-L: Dialogs in a C DLL called from MI Using resources in .dlls is always hard (having nothing to do with MapInfo), because the default resource handle points to the calling process, which in this case is the MapInfo .exe. In short, you need to make sure that you are loading the resource from the correct module. If you are actually using 'C', then you are probably loading the resources explicitly, so make sure in your call to 'CreateDialog' that the 1st parameter (HINSTANCE) points to the .dll itself. You can save that parameter by making sure to handle DllMain. If you are using MFC or some other library, it will be a little different. In MFC you would need some code like: AFX_MANAGE_STATE(AfxGetAppModuleState()); And depending on your situation, you may need to call "AfxSetResourceHandle(...)" I hope this helps a little... Ned Harding Chief Technology Officer SRC - Extending the Reach of Micromarketing 3825 Iris Ave Suite 150 Boulder, CO 80303 (303) 440-8896 x104 http://www.extendthereach.com Technology in Action: http://www.DemographicsNow.com -----Original Message----- From: Colin Henderson [mailto:[EMAIL PROTECTED]] Sent: Monday, January 27, 2003 9:27 AM To: MI-L List (E-mail) Subject: MI-L MI-L: Dialogs in a C DLL called from MI List, Please help! I am trying to get a dialog to appear in MapInfo from a dll created in C. When i call the function in my dll that will show the dialog I get the return value of -1. I am getting the c dialog to report the error and it returns: "The specified resource type cannot be found in the image file." Has anyone come across this before? I know the dialog I am calling is present in the dll because I can see it when I run ResHack to view the dll. I have included the .rc file and all relevant headers, but still no joy! If I apply the same principle in a standard executable all works fine. Is it not possible to store dialogs in a dll and then call them from mi? All help, greatly appreciated! -------------------------------- Colin Henderson Senior Developer Ordnance Survey Tel: (0)2380 79 2034 -------------------------------- If you have received this email in error, please delete it immediately and notify the sender. This email may contain confidential information and if you are not the intended recipient, you must not copy, distribute or rely on it. As email is not a 100% secure communications medium, you accept that there are risks in communicating by email by doing so. We advise you to check that emails and attachments are virus-free before opening them. No contracts can be entered into on our behalf by email. Opinions expressed in this email are not necessarily endorsed by us unless otherwise specifically stated. We reserve the right to read and monitor any email or attachment entering or leaving our systems without prior notice. Ordnance Survey Romsey Road Southampton SO16 4GU Tel: 023 8079 2000 http://www.ordnancesurvey.co.uk --------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Message number: 5163 --------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Message number: 5166 --------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Message number: 5174
