Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ShowHTMLDialog working with XP not Win98

ShowHTMLDialog working with XP not Win98

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionhtmltutorialannouncement
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    georgiek50
    wrote on last edited by
    #1

    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.

    N M 2 Replies Last reply
    0
    • G georgiek50

      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.

      N Offline
      N Offline
      Neville Franks
      wrote on last edited by
      #2

      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"

      G 1 Reply Last reply
      0
      • N Neville Franks

        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"

        G Offline
        G Offline
        georgiek50
        wrote on last edited by
        #3

        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.

        N 1 Reply Last reply
        0
        • G georgiek50

          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.

          N Offline
          N Offline
          Neville Franks
          wrote on last edited by
          #4

          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"

          1 Reply Last reply
          0
          • G georgiek50

            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.

            M Offline
            M Offline
            Michael Dunn
            wrote on last edited by
            #5

            Check your return values and init your pointers to NULL. Specifically, if CreateURLMoniker() fails, you don't look at its retval and pMoniker 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

            G 1 Reply Last reply
            0
            • M Michael Dunn

              Check your return values and init your pointers to NULL. Specifically, if CreateURLMoniker() fails, you don't look at its retval and pMoniker 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

              G Offline
              G Offline
              georgiek50
              wrote on last edited by
              #6

              CreateURLMoniker 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.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups