Solved

Open Web Browser, mouseover

Posted on 2000-05-06
13
219 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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now