Solved

Open Web Browser, mouseover

Posted on 2000-05-06
13
222 Views
Last Modified: 2010-04-02
[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
0
Comment
Question by:Subhuman
  • 5
  • 4
  • 4
13 Comments
 
LVL 1

Expert Comment

by:yz
ID: 2783827
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
 
LVL 1

Expert Comment

by:yz
ID: 2783828
yz changed the proposed answer to a comment
0
 
LVL 1

Expert Comment

by:yz
ID: 2783831
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:yz
ID: 2783852
yz changed the proposed answer to a comment
0
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 50 total points
ID: 2783956
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
 
LVL 1

Author Comment

by:Subhuman
ID: 2785059
Thanks, I'll see what I can do with it.

What's the platform sdk?
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 2785122
>>What's the platform sdk?
Windows 95/98/NT

0
 
LVL 1

Author Comment

by:Subhuman
ID: 2785135
? huh ?

So I'm supposed to look for a sample called "MouseInfo", eh?
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 2785768
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
 
LVL 1

Author Comment

by:Subhuman
ID: 2787805
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
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 2788800
ShellExecute has been defined in
you ...\include\Win32\shellapi.h
0
 
LVL 1

Author Comment

by:Subhuman
ID: 2790641
so I need a

#include<shellapi.h>

in there?
0
 
LVL 1

Author Comment

by:Subhuman
ID: 2790992
Thank you Alex :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Socket Programming (Unix) 8 140
How to split this in C++ 4 106
Header of docx file 17 114
How to Correctly derive class from CWinThread in MFC 4 64
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question