Web browser Control

This is a discussion on Web browser Control within the Windows Programming forums, part of the Platform Specific Boards category; 'Lo - I'm new to the forum - been reading it for some time. However, I finally have a question ...

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    5

    Web browser Control

    'Lo -

    I'm new to the forum - been reading it for some time. However, I finally have a question that I haven't been able to solve elsewhere:

    Now that I have delved into the Win32 API, I would like to find some resources on how to connect to a web server through my win32 C app. Basically I want to be able to connect to my website(s), access a PHP script that displays an image, and display that image in the application.

    Any help/resources/tutorials on the subject would be greatly appreciated.

    Ay thank you

    - rednax

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    There is a few ways to do this. If you just want to display a web page in a dialog, try this:

    Code:
    #include <windows.h>
    #include <Urlmon.h>
    #include <mshtmhst.h>
    
    int main() {
      SHOWHTMLDIALOGFN* pfnShowHTMLDialog;
      HINSTANCE hinstMSHTML = LoadLibrary(TEXT("MSHTML.DLL"));
    
       if (hinstMSHTML == NULL)
       {
           // Error loading module -- fail as securely as possible
           return 0;
       }
       
       pfnShowHTMLDialog = (SHOWHTMLDIALOGFN*)GetProcAddress(hinstMSHTML,
                                                                  TEXT("ShowHTMLDialog"));
       if (pfnShowHTMLDialog)
       {
           IMoniker *pURLMoniker;
           BSTR bstrURL = SysAllocString(L"http://www.cboard.cprogramming.com");
           CreateURLMoniker(NULL, bstrURL, &pURLMoniker);
    
           if (pURLMoniker)
           {
               (*pfnShowHTMLDialog)(NULL, pURLMoniker, NULL, NULL, NULL);
               pURLMoniker->lpVtbl->Release(pURLMoniker);
           }
    
           SysFreeString(bstrURL);
       }
    
       FreeLibrary(hinstMSHTML);
    
      return 0;
    }
    Alternatively, for simplicity you can use UrlDownloadToFile or OleLoadPicturePath.

  3. #3
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    I don't have that mshtmhst.h header file. How can I do it then?

  4. #4
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Remove the #include <mshtmhst.h> line and add this line instead.
    Code:
    typedef HRESULT STDAPICALLTYPE SHOWHTMLDIALOGFN (HWND hwndParent, IMoniker *pmk, VARIANT *pvarArgIn, WCHAR* pchOptions, VARIANT *pvArgOut);

  5. #5
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    But I still get one error:
    Code:
    25 C:\Programs\Dev-Cpp\Templates\webcontrol.cpp 'struct IMoniker' has no member named 'lpVtbl'

  6. #6
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Either compile the code as C rather than C++ or change the line:
    Code:
              pURLMoniker->lpVtbl->Release(pURLMoniker);
    to:
              pURLMoniker->Release();

  7. #7
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    What library I should include?
    Code:
    [Linker error] undefined reference to `SysAllocString@4'
    [Linker error] undefined reference to `CreateURLMoniker@12'
    [Linker error] undefined reference to `SysFreeString@4'

  8. #8
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    I tested some libraries and I got rid of the sysallocstring and sysfreestring errors with liboleaut32.a library, but I still get the CreateURLMoniker@12 error.
    Where can I get urlmon.lib library? I don't have it...
    Last edited by maxorator; 10-10-2005 at 11:14 AM.

  9. #9
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    308
    Basically Dev-C++'s uses lib as prefix for the libraries.. if not... try those free ones
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  10. #10
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    I know it uses lib prefix, but I didn't find any library that contains urlmon in the filename...
    And what free ones are you talking about?

  11. #11
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Why the hell is a thread from 2003 being revived?

    maxorator read the freakin rules before posting again. I'm getting tired of this

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Web browser based program
    By Lauris in forum C++ Programming
    Replies: 3
    Last Post: 11-14-2007, 04:01 PM
  2. Web Browser Control Help
    By dcboy in forum C# Programming
    Replies: 0
    Last Post: 10-22-2006, 09:25 AM
  3. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 05:23 AM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21