ShowHTMLDialog working with XP not Win98
-
I have a small function in my app that displays an HTML dialog that works find in Windows XP but not 98. Code is as follows:
void ShowExportTemplatePreview(HWND hwnd) { // Function to show a template export preview in another dialog window HINSTANCE hinstMSHTML = LoadLibrary(TEXT("MSHTML.DLL")); if(hinstMSHTML) { SHOWHTMLDIALOGFN *pfnShowHTMLDialog; pfnShowHTMLDialog = (SHOWHTMLDIALOGFN*) GetProcAddress(hinstMSHTML, TEXT("ShowHTMLDialog")); if(pfnShowHTMLDialog) { char szTemplatePreview[MAX_PATH]; wsprintf(szTemplatePreview, "%s\\Temp_0.html", cStartupData.szAppDirectory); WCHAR wcTemplatePreview[MAX_PATH]; MultiByteToWideChar(CP_THREAD_ACP, NULL, szTemplatePreview, sizeof(szTemplatePreview), wcTemplatePreview, MAX_PATH); IMoniker *pURLMoniker; CreateURLMoniker(NULL, wcTemplatePreview, &pURLMoniker); if (pURLMoniker) { BSTR bstrOptions = SysAllocString(L"dialogHeight:30;dialogWidth:45;resizable:yes"); (*pfnShowHTMLDialog)(hwnd, pURLMoniker, NULL, (char*) bstrOptions, NULL); SysFreeString(bstrOptions); pURLMoniker->Release(); } } FreeLibrary(hinstMSHTML); } }
This is mostly copied from MSDN and I am trying to find compatibility issues with no success. We have pinpointed the problem to: (*pfnShowHTMLDialog)(hwnd, pURLMoniker, NULL, (char*) bstrOptions, NULL); But i have no idea as to what is causing the error or how to even go about solving it. Does anyone have any experience with this function that could be of help? Thanks in advance. -
I have a small function in my app that displays an HTML dialog that works find in Windows XP but not 98. Code is as follows:
void ShowExportTemplatePreview(HWND hwnd) { // Function to show a template export preview in another dialog window HINSTANCE hinstMSHTML = LoadLibrary(TEXT("MSHTML.DLL")); if(hinstMSHTML) { SHOWHTMLDIALOGFN *pfnShowHTMLDialog; pfnShowHTMLDialog = (SHOWHTMLDIALOGFN*) GetProcAddress(hinstMSHTML, TEXT("ShowHTMLDialog")); if(pfnShowHTMLDialog) { char szTemplatePreview[MAX_PATH]; wsprintf(szTemplatePreview, "%s\\Temp_0.html", cStartupData.szAppDirectory); WCHAR wcTemplatePreview[MAX_PATH]; MultiByteToWideChar(CP_THREAD_ACP, NULL, szTemplatePreview, sizeof(szTemplatePreview), wcTemplatePreview, MAX_PATH); IMoniker *pURLMoniker; CreateURLMoniker(NULL, wcTemplatePreview, &pURLMoniker); if (pURLMoniker) { BSTR bstrOptions = SysAllocString(L"dialogHeight:30;dialogWidth:45;resizable:yes"); (*pfnShowHTMLDialog)(hwnd, pURLMoniker, NULL, (char*) bstrOptions, NULL); SysFreeString(bstrOptions); pURLMoniker->Release(); } } FreeLibrary(hinstMSHTML); } }
This is mostly copied from MSDN and I am trying to find compatibility issues with no success. We have pinpointed the problem to: (*pfnShowHTMLDialog)(hwnd, pURLMoniker, NULL, (char*) bstrOptions, NULL); But i have no idea as to what is causing the error or how to even go about solving it. Does anyone have any experience with this function that could be of help? Thanks in advance.You haven't said what the error is? georgiek50 wrote: We have pinpointed the problem to: What problem - besides "not working"? You aren't testing a) if the file exists, b) whether an appropriate version of MSHTML is being used, c) what ShowHTMLDialog() returns, d) whether the hWnd is valid. FYI you should use the pre and code links on the Formatting bar below the mssage area when posting code. Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
-
You haven't said what the error is? georgiek50 wrote: We have pinpointed the problem to: What problem - besides "not working"? You aren't testing a) if the file exists, b) whether an appropriate version of MSHTML is being used, c) what ShowHTMLDialog() returns, d) whether the hWnd is valid. FYI you should use the pre and code links on the Formatting bar below the mssage area when posting code. Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
GetLastError() returns 0 and I don't know specifically which function to call to get this type of error (I'm very new to this stuff and can't find it in MSDN) Not working means the dialog isn't opening. The file is there, MSHTML.dll is being loaded as well. Thanks for the help.
-
GetLastError() returns 0 and I don't know specifically which function to call to get this type of error (I'm very new to this stuff and can't find it in MSDN) Not working means the dialog isn't opening. The file is there, MSHTML.dll is being loaded as well. Thanks for the help.
ShowHTMLDialog() returns a HRESULT. The first thing I'd do is test that. Next I'd verify in the code that the file exists in the specified directory. You'll find info on ShowHTMLDialog here: http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/functions/showhtmldialog.asp[^] and a sample program here: http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/samples/internet/browser/htmldlg/default.asp[^] Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
-
I have a small function in my app that displays an HTML dialog that works find in Windows XP but not 98. Code is as follows:
void ShowExportTemplatePreview(HWND hwnd) { // Function to show a template export preview in another dialog window HINSTANCE hinstMSHTML = LoadLibrary(TEXT("MSHTML.DLL")); if(hinstMSHTML) { SHOWHTMLDIALOGFN *pfnShowHTMLDialog; pfnShowHTMLDialog = (SHOWHTMLDIALOGFN*) GetProcAddress(hinstMSHTML, TEXT("ShowHTMLDialog")); if(pfnShowHTMLDialog) { char szTemplatePreview[MAX_PATH]; wsprintf(szTemplatePreview, "%s\\Temp_0.html", cStartupData.szAppDirectory); WCHAR wcTemplatePreview[MAX_PATH]; MultiByteToWideChar(CP_THREAD_ACP, NULL, szTemplatePreview, sizeof(szTemplatePreview), wcTemplatePreview, MAX_PATH); IMoniker *pURLMoniker; CreateURLMoniker(NULL, wcTemplatePreview, &pURLMoniker); if (pURLMoniker) { BSTR bstrOptions = SysAllocString(L"dialogHeight:30;dialogWidth:45;resizable:yes"); (*pfnShowHTMLDialog)(hwnd, pURLMoniker, NULL, (char*) bstrOptions, NULL); SysFreeString(bstrOptions); pURLMoniker->Release(); } } FreeLibrary(hinstMSHTML); } }
This is mostly copied from MSDN and I am trying to find compatibility issues with no success. We have pinpointed the problem to: (*pfnShowHTMLDialog)(hwnd, pURLMoniker, NULL, (char*) bstrOptions, NULL); But i have no idea as to what is causing the error or how to even go about solving it. Does anyone have any experience with this function that could be of help? Thanks in advance.Check your return values and init your pointers to NULL. Specifically, if
CreateURLMoniker()
fails, you don't look at its retval andpMoniker
will be left as uninitialized (but non-zero) garbage, which you will treat as success. --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ Strange things are afoot at the U+004B U+20DD -
Check your return values and init your pointers to NULL. Specifically, if
CreateURLMoniker()
fails, you don't look at its retval andpMoniker
will be left as uninitialized (but non-zero) garbage, which you will treat as success. --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ Strange things are afoot at the U+004B U+20DDCreateURLMoniker returns S_OK. The only reason I know that it is failing at the specific line is that the HRESULT returned by ShowHTMLDialog != S_OK (I have tested all other return values). I guess the most important question from here is to find what error code exactly the function returns. That is what I can't find documentation on. Thanks for the help.