Solved

Open Web Browser, mouseover

Posted on 2000-05-06
13
220 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

862 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

24 Experts available now in Live!

Get 1:1 Help Now