Solved

ShowHTMLDialog

Posted on 1998-10-22
5
213 Views
Last Modified: 2013-12-03
I found the ShowHTMLDialog in MSDN that is very interesting . The problem is that since I work with plain API , I am not sure how I supply the dialog resource to the function and the other parameter's meaning . I would appreciate a piece of code that calls ShowHTMLDialog .
0
Comment
Question by:WxW
  • 3
  • 2
5 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 30 total points
ID: 1415530
There's an example in the Internet Platform SDK (available at 'http://www.microsoft.com/msdn/sdk/platform.htm') named 'htmldlg'. Excerpt:
int PASCAL WinMain(  HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpCmdLine,
                     int nCmdShow)
{
HINSTANCE   hinstMSHTML = LoadLibrary(TEXT("MSHTML.DLL"));

if(hinstMSHTML)
   {
   SHOWHTMLDIALOGFN  *pfnShowHTMLDialog;
     
   pfnShowHTMLDialog = (SHOWHTMLDIALOGFN*)GetProcAddress(hinstMSHTML, TEXT("ShowHTMLDialog"));

   if(pfnShowHTMLDialog)
      {
      IMoniker *pmk;
      TCHAR    szTemp[MAX_PATH*2];
      OLECHAR  bstr[MAX_PATH*2];

      lstrcpy(szTemp, TEXT("res://"));
      GetModuleFileName(hInstance, szTemp + lstrlen(szTemp), ARRAYSIZE(szTemp) - lstrlen(szTemp));
      lstrcat(szTemp, TEXT("/HTML_RESOURCE"));

      LocalToBSTR(bstr, szTemp, ARRAYSIZE(bstr));

      CreateURLMoniker(NULL, bstr, &pmk);

      if(pmk)
         {
         HRESULT  hr;
         VARIANT  varArgs, varReturn;
         
         VariantInit(&varReturn);

         varArgs.vt = VT_BSTR;
         varArgs.bstrVal = SysAllocString(L"Argument 1;Argument 2;Argument 3;Argument 4");

         hr = (*pfnShowHTMLDialog)(NULL, pmk, &varArgs, NULL, &varReturn);

         VariantClear(&varArgs);
         
         pmk->Release();

         if(SUCCEEDED(hr))
            {
            switch(varReturn.vt)
               {
               case VT_BSTR:
                  {
                  TCHAR szData[MAX_PATH];

                  BSTRToLocal(szData, varReturn.bstrVal, ARRAYSIZE(szData));

                  wsprintf(szTemp, TEXT("The selected item was \"%s\"."), szData);

                  VariantClear(&varReturn);
                  }
                  break;

               default:
                  lstrcpy(szTemp, TEXT("Cancel was selected."));
                  break;
               }
            MessageBox(NULL, szTemp, TEXT("HTML Dialog Sample"), MB_OK | MB_ICONINFORMATION);
            }
         else
            MessageBox(NULL, TEXT("ShowHTMLDialog Failed."), TEXT("HTML Dialog Sample"), MB_OK | MB_ICONERROR);
           
         }
      }
   FreeLibrary(hinstMSHTML);
   }

return 0;
}

0
 
LVL 6

Author Comment

by:WxW
ID: 1415531
I appreciate your answer jkr , but I already knew this . I want to display HTML in my app without the usage of MFC . Is there any API that enables you to show html without messing with IMoniker and Variants ?
0
 
LVL 6

Author Comment

by:WxW
ID: 1415532
Ok I found how , thanks for the info :)
0
 
LVL 86

Expert Comment

by:jkr
ID: 1415533
Hmmm - the example above doesn't use MFC at all ;-)
0
 
LVL 6

Author Comment

by:WxW
ID: 1415534
Right but the doc I found includes mshtml.h that does some tricks .... anyway I went through it
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now