1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

[Article] WebBrowser Control in DEV C++ / MingW-GCC

Discussion in 'Programming' started by Vooler, Jun 17, 2008.

  1. #1
    This article is based on another article, published by Jaff Glatt at codeproject.com. http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=88625

    YOU DO NOT NEED TO LINK ANY LIBRARY (except cwebpage.dll) OR WRITE CODE OF MORE THAN 2 LINES TO INTEGRATE THE CONTROL.

    Most of DEV C++ (which integrates mingw compiler) users are unable to use Jeff’s example up to now, that is not fault of Jeff but insufficient headers support in mingw include libraries. One more author, published an article where s/he claims that s/he was able to compile MSHTMLTest.zip file with mingw at http://www.adp-gmbh.ch/win/misc/mshtml/index.html, but after reviewing it for sometime, I personally came to know that it cannot be compiled with mingw easily, there are still too many changes to be made and new headers are required to compile it flawlessly.

    So, the solution is very simple; Why not use a 3 kb dll for the time being, although I personally do not like using dll files and love independent & standalone executables. Example of Jeff Glatt includes a DLL file called cwebpage.dll, that I will be using with my example and linking it explicitly and form a very simple to use class, which will be 100% compatible with dev c++ mingw.

    In the example project that is downloadable, I have created a dev c++ project, which does not link any extra library, but just includes windows.h for LoadLibrary, FreeLibrary functions.

    FINALLY: having browser support in extra 3 kb is not bad idea.

    Usage of the class (make sure WebBrowser.h is in the same folder, as well as cwebpage.dll is in the same folder or in system folder)

    #include "WebBrowser.h"
    
    WebBrowser br; //declare instance here
    
    ……….
    
    WinMain…………..
    
    HWND parent = Create some dialog……………
    
    //create the browser control here
    
    br.create("<b>Hi am browser in 3 kb</b>, default text", 0,0,200,200, parent);
    Code (markup):

    To load webpage, use function WebBrowser::loadPage as

    br.loadPage("http://www.apitalk.com");
    Code (markup):
    And that’s it. A complete example and dev C++ project is included in the zip file.


    WHAT’s NEXT? I am working on another browser class that will be independent from any external DLL, after I finish it, developers will be use the new file without dll dependency and without modifying even a single line of your code. The major problem is mingw lacks complete headers to build application as per winapi standards. So my recommendation is, use above supplied resource for now, and wait until I finish new one, and do not switch to proprietary software like BCC or VC++ just for Browser Control.


    Advanced Programmers: Do not touch the GWL_USERDATA element of the WebBrowser::control which is the parent window of browser. Or you are responsible for any crash/damage caused either at application and/or system level.


    License: Not stupid license terms from me atleast, follow the terms of use at codeproject.com, which clearly state that you can utilize the resource either for personal, educational and/or commercial projects.

    Screenshot:
    http://www.imageshrek.com/images/4pqo96yg33q2c6n54th.jpg


    Let me know if I missed anything.

    regards
     

    Attached Files:

    Vooler, Jun 17, 2008 IP
  2. jpinheiro

    jpinheiro Peon

    Messages:
    1,211
    Likes Received:
    15
    Best Answers:
    1
    Trophy Points:
    0
    #2
    download link is broken :(
     
    jpinheiro, Aug 10, 2008 IP
  3. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #3
    Vooler, Aug 21, 2009 IP