|Outlook add-in, display dialog box [message #763]
||Thu, 03 August 2006 05:22
Registered: August 2006
I am currently developping in C++ (with Visual Studio 6) an outlook
add-in. I need to ask the user to choose something from a combobox. So
what I thought is to do a Dialog Box asking the user to select an item
in a combobox. I did the same thing I would do for a normal exe that
is: creating the ressource, the class linked to the ressource and then
in my code when pressing a certain button displaying the DialogBox in a
modal way :
Yes but it doesn't work ! GetLastError returns 1812
(ERROR_RESOURCE_DATA_NOT_FOUND : The specified image file did not
contain a resource section.). After a few researches I found out that
for a dll when doing that windows tries to load the ressource from the
exe (using the exe context) when it should load it from the DLL. Some
people proposed to add :
HINSTANCE hRes = NULL;
hPrevRes = AfxGetResourceHandle();
hRes = LoadLibrary("OutlookPhoenix.dll");
in the InitInstance of the dll
in the ExitInstance.
This is setting the global resource handler to the dll instance
Right now the DialogBox is showing but ... Outlook crashes.
I tried a FreeLibrary in the ExitInstance, I tried not to get the hRes
by loading the library but using some
GetModuleHandle("OutlookPhoenix.dll") ... But still it's not working !
Outlook still crashes. I think it's because I'm setting globaly the
ResourceHandle for all the application and Outlook doesn't like that
(probably it tries also to load some resources and then crashes).
I tried to do the job using a modeless dialog box but can't manage to
display it (the Create fails, I can't get the full error description).
I don't have anymore ideas, could you help me ?
Thanks in advance,