( Index )
Month

Brief Information about the May 2007 CSIG Meeting

Safer Browser - an Internet browser with safety features.

by Bruce Arnold

3rd Tuesday of the month. 7:30PM - C/C++ Group, SPRS

Safer Browser Snapshot Safer Browser Logo

Welcome to the CSIG, a Special Interest Group of the ACGNJ. This group is a "Special Interest Group" of the ACGNJ devoted to discussing programming languages in general and C, C++, and C++ for Windows programming in particular. Each month a small but hopefully useful program (complete with source code) is presented for discussion.

Since there have been so many changes in the Browser program that I started in March, we will discuss the features in Microsoft Visual Studio 2005 which enabled the creation of this program. In addition to its test capability, the browser is also quite useful as a normal Internet Browser. The application program demonstrates the ability of the Visual Studio software to include an Internet browser window inside a standard C++ program. It allows creating a custom browser with special features.

During the meeting we will discuss the techniques in programming that allow the creation of a vast number of "Event Handlers" that do not appear in the development enviornment editor (IDE). This methodolgy allows using virtually all of the internal and hidden functions and methods of the new .NET Microsoft classes. For example: In the program, I wanted to grab the event "Can Go Back Changed" which is used to enable or disable the "Back" button or arrow. This was not available in the IDE. By coding it manually, I was able to use its functionality. I will discuss more on this at the meeting.

Here are the latest additions and changes (Version 1.10 March 30, 2007)

  1. A history dropdown has been added with the ability to select and go. Also, the history may be saved to the clipboard.
  2. An "Unsafe" button has been added to bypass all user prompts so that the browser works more or less like a regular browser.
  3. A "Filter" has been added to exclude specific sites. The list may be initialized manually or automatically by selecting "Cancel" when prompted to jump to a new web site.
  4. When a site is ignored via the filter, the button glows Red briefly.
  5. A "Go" button has been added to initiate jumping to a new web site.
  6. The logic for selecting the whole address box has been updated. It is now selected with a single click or a double click just like Internet Explorer.
  7. History stack removed and the Back Button now uses Microsoft's internal logic that keeps its own history. Intermediate ads, etc. are ignored by backup.
  8. Back Button status (Green light) now handled by a Microsoft Event.
  9. Forward Button added with functionality like the Back Button.
  10. Tool Tips added for each button and control.

This application is designed to partially duplicate the functioning of a standard Internet browser. It may be used whenever diagnostics and/or extra safety is required. In order to go to a web site, just type the name in the Address bar at the top. A shortcut with that name as an argument may also be used. The Back Arrow (upper left) allows stepping backwards to sites already visited. Standard Hot Keys are provided: Ctrl-P for printing, Ctrl-C for copying, Ctrl-A for selecting all, and Ctrl-F for finding.

Whenever a new address is provided, or the site code tries to jump to another site, a prompt message appears which allows the user to decide whether to proceed or not. The parachute logo represents the fact that you have much more control over your browsing. You will probable find it surprising that familiar web pages are so complicated. Often going to one page launches 5 others in the background without your realization. Tip: for safe web sites, just hit the Space Bar.

Here's an example of what you might see ...

Safer Browser Logo

The program may be compiled using the C++ .Net compiler included with Visual Studio 2005 as well as the free (!!!) C++ Express compiler. Additionally, since C++ has many similarities with C# or C-Sharp, these compilers may also be used with modifications to the source files. Microsoft provides a C-Sharp compiler with Visual Studio 2005 as well as the free (!!!) C-Sharp Express compiler. Be sure to bring questions about the code and the language.


The programs are normally quite small, about 100 KB, but require a Windows computer that has the following software installed:

Microsoft .NET Framework Version 2.0

This is a large package, about 24 Megs. Most people running updated versions of WinXP will already have it on their computer. If not, it may be downloaded from Microsoft.

Here's the download address for the Microsoft Framework:
Microsoft Software
Or, just look for: Microsoft .NET Framework Version 2.0 Redistributable Package (x86)

There are a number of ways to refer to this compiler and code.

Here's what Wikipedia says about CLI:

The Common Language Infrastructure (CLI) is an open specification developed by Microsoft that describes the executable code and runtime environment that form the core of the Microsoft .NET Framework. The specification defines an environment that allows multiple high-level languages to be used on different computer platforms without being rewritten for specific architectures.

At the meeting on Tuesday night we will be discussing these items and more.


Sample Code - VC7

Sample Code
===========
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
        Form1(void)
        {
            InitializeComponent();
            //
            //TODO: Add the constructor code here
            //
            this->web1->CanGoBackChanged += gcnew System::EventHandler(this, &Form1::web1_CanGoBackChanged);
            this->web1->CanGoForwardChanged += gcnew System::EventHandler(this, &Form1::web1_CanGoForwardChanged);

            Backup->Enabled = false;
            Forward->Enabled = false;
            argv = Environment::GetCommandLineArgs();
            argc = argv->Length;
            FilterList->Visible = false;
            HistoryList->Visible = false;
            Tip1->ShowAlways = true;
            Tip1->SetToolTip( this->Backup, "Go to previous page." );
            Tip1->SetToolTip( this->Forward, "Go to next page." );
            Tip1->SetToolTip( this->FilterButton, "Disallow web sites." );
            Tip1->SetToolTip( this->GoButton, "Go to new web site." );
            Tip1->SetToolTip( this->HistoryButton, "Display all sites visited." );
            Tip1->SetToolTip( this->Address1, "Current or Future web page." );
            Tip1->SetToolTip( this->ByPassBtn, "Bypass all user prompting." );

            IntroMsg->Text = INTRODUCTION;
            Show();
            // Astronomy Picture of the Day 
            // ============================
            if (argc < 2)
                web1->Navigate("http://antwrp.gsfc.nasa.gov/apod/astropix.html");
            else
            {
                String ^foo = argv[1];
                for (int i=2; i<argc; i++) foo += " " + argv[i];
                pictureBox1->Visible = false;       // Turn off splash
                IntroMsg->Visible = false;          // Ditto
                web1->Navigate(foo);
            }
        }

        array <String^> ^argv;      int argc;
        static int NewWindowCancels = 0;
        static bool NoNewWindows = false;
        static bool ByPassFlag = false;
        static bool Address1_FocusEnter = false;

"Random Access" questions start at 7:30 Tuesday night. See you there.

SOURCE CODE

Source Code Files

For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page