Click here to Skip to main content
15,896,526 members
Articles / Desktop Programming / MFC

Launch and control MSIE using IWebBrowser2

Rate me:
Please Sign up or sign in to vote.
3.29/5 (8 votes)
28 Nov 2006 66K   6.1K   35  
A simple interface for launching MSIE and controlling IE components.
// IWebBrowser2.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "resource.h"

extern void spawn_browser(
  const char *uri,	// URL
  int nWidth,				// Window Width
  int nHeight,			// Window Height
	HICON hIcon);			// Handle to the icon

int _tmain(int argc, _TCHAR* argv[])
{
	argc; argv;
	HICON hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1));
	// If you're not interested in changing IE's window icon, then pass NULL instead of hIcon.
	spawn_browser("http://www.codeproject.com", 800, 600, hIcon);

	// hang around so the handle to the icon stays valid.
	printf("Press 'q' CR to exit.");
	while(getchar() != 'q')
			Sleep(200);
	return 0;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
John Klein is an experienced C/C++ and C# developer with an emphisis on WiFi and 802.11 systems. John has 19 years of development and management experience and participated in the development of the IEEE 802.11 wireless protocol.

John currently works at JiWire, Inc. as a principal engineer.

Comments and Discussions