Open Web Browser, mouseover

[Borland C++ Builder 3 Standard]

I have a program I am working on, and I want to have a link that you can click on in the program that opens up the default Web Browser at a given address.

Can someone please give me some code for the onclick handler to do this?

Also, is there a simple mouseover/mouseout event handler? I can't find any in the Help system.

Thanks,

Daniel
LVL 1
SubhumanAsked:
Who is Participating?
 
AlexVirochovskyConnect With a Mentor Commented:
Create a temporary text file in your apps directory
(or in the c:\windows\temp directory) with this content:

[InternetShortcut]
URL=http://www.experts-exchange.com

Name this file "temp.url" and start it with ShellExecute:

#include <vcl\vcl.h>
#include <vcl\clipbrd.hpp>
#include <windows.h>
#pragma hdrstop

#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button1Click(TObject *Sender)
{
  ::ShellExecute(NULL,"open","temp.url",NULL,NULL, SW_SHOW);
}
I hope, it helps. Alex
0
 
yzCommented:
Please refer to platform sdk , there are a sample named "MouseInfo" can tell u how to handle WM_MOUSEHOVER message, if u want to open browser, I think ShellExecture function can do it.
0
 
yzCommented:
yz changed the proposed answer to a comment
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
yzCommented:
Please refer to platform sdk , there is a sample named "MouseInfo" can tell u how to handle WM_MOUSEHOVER message, if u want to open browser, I think ShellExecute function can do it.
0
 
yzCommented:
yz changed the proposed answer to a comment
0
 
SubhumanAuthor Commented:
Thanks, I'll see what I can do with it.

What's the platform sdk?
0
 
AlexVirochovskyCommented:
>>What's the platform sdk?
Windows 95/98/NT

0
 
SubhumanAuthor Commented:
? huh ?

So I'm supposed to look for a sample called "MouseInfo", eh?
0
 
AlexVirochovskyCommented:
May be such code exists, i don't know.
But for what? If you want launch brouser pressing on the Button or other
control, simple set my code in OnClick
event header,
0
 
SubhumanAuthor Commented:
This is what I've got:

#include <stdio.h>
#include <math.h>
//these two are for the link
#include <vcl\clipbrd.hpp>
#include <windows.h>

#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
double Principal, Rate, Time, Accum, Interest, Num;
//char * const Principal = TEdit.PrincipalInput.Text;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------

//etc, some event handlers for other objects and such

//---------------------------------------------------------------------------

void __fastcall TForm1::URLnClick(TObject *Sender)
{
// The name of the TStaticText object I'm using for my link is "URLn"
// This stands for URL Normal (as opposed to URLu[nderline]), because
// of the two objects I want to swap the visibility of on mouseover.
// I'll get the link to work before I go screwing around with mouseover
// routines though. :)

  ::ShellExecute(NULL,"open","temp.url",NULL,NULL, SW_SHOW);
}
//---------------------------------------------------------------------------


--------------------------

This is the error message:

[C++Error] Unit1.cpp(211): Call to undefined function 'ShellExecute'.

I looked through the help system and there doesn't appear to be a ShellExecute function included with my version of C++ Builder. :(

What do you suggest (other than get a better compiler :) ?)
0
 
AlexVirochovskyCommented:
ShellExecute has been defined in
you ...\include\Win32\shellapi.h
0
 
SubhumanAuthor Commented:
so I need a

#include<shellapi.h>

in there?
0
 
SubhumanAuthor Commented:
Thank you Alex :)
0
All Courses

From novice to tech pro — start learning today.