Displaying simple URL in CDialog as underlined text

 Hi all,

 First of all I'd like to say that I'm quite new to MFC and
 Win32 APIs and my question might seem trivial to HC MFC
 programmers.

 I have a dialog based MFC application. When the user
 selects Help->About.. the application shows yet another
 dialog with some information on it. There's an URL too on
 the dialog. I've managed to make the URL, which is a
 CStatic text, clickable and once clicked it opens
 up a web browser using ShellExecute. However I'd like the
 text to be blue and underlined to show the user that it is
 a hyperlink indeed. Now it is just like other texts on the
 dialog i.e. black without underlining.

 I should also implement a mouse listener that changes the
 pointer to a hand when the pointer is over this URL.

 
 Thanks for any help in advance,
-- 
              |||
             (0-0)
+--------oOO--(_)--OOo----------------------------+
| Wellu M�kinen www.wellu.0rg                     |
|                                                 |
| No tears please, it's a waste of good suffering |
+-------------------------------------------------+
0
Wellu
2/24/2005 9:22:24 AM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
482 Views

Similar Articles

[PageSpeed] 59

Now handle the WM_CTLCOLOR message for your Static Control for changing
color

these api will help in this
SetTextColor :- For changing the Text Color
SetBkColor:- for changing the ack Ground color of control

now for color change on HOVER of mouse button.

use above api in OnMouseMove Message


--

With Regards
Alok Gupta
Visit me at http://alok.bizhat.com

                           "I think this will Help"


"Wellu M�kinen" <wellu@n0spamN0rHTml.w3llu.0r9.invalid> wrote in message
news:slrnd1r7b5.4up.wellu@wellu.org...
> Hi all,
>
>  First of all I'd like to say that I'm quite new to MFC and
>  Win32 APIs and my question might seem trivial to HC MFC
>  programmers.
>
>  I have a dialog based MFC application. When the user
>  selects Help->About.. the application shows yet another
>  dialog with some information on it. There's an URL too on
>  the dialog. I've managed to make the URL, which is a
>  CStatic text, clickable and once clicked it opens
>  up a web browser using ShellExecute. However I'd like the
>  text to be blue and underlined to show the user that it is
>  a hyperlink indeed. Now it is just like other texts on the
>  dialog i.e. black without underlining.
>
>  I should also implement a mouse listener that changes the
>  pointer to a hand when the pointer is over this URL.
>
>
>  Thanks for any help in advance,
> --
>               |||
>              (0-0)
> +--------oOO--(_)--OOo----------------------------+
> | Wellu M�kinen www.wellu.0rg                     |
> |                                                 |
> | No tears please, it's a waste of good suffering |
> +-------------------------------------------------+


0
thatsalok1 (226)
2/24/2005 10:34:26 AM
Wellu M�kinen wrote:
>  I have a dialog based MFC application. When the user
>  selects Help->About.. the application shows yet another
>  dialog with some information on it. There's an URL too on
>  the dialog. I've managed to make the URL, which is a
>  CStatic text, clickable and once clicked it opens
>  up a web browser using ShellExecute. However I'd like the
>  text to be blue and underlined to show the user that it is
>  a hyperlink indeed. Now it is just like other texts on the
>  dialog i.e. black without underlining.
> 
>  I should also implement a mouse listener that changes the
>  pointer to a hand when the pointer is over this URL.

Check into some free components from either CodeProject.com or
CodeGuru.com.  CNewLabel makes for a very easy to use clickable
URL link.  It can be found on CodeGuru.com here:

http://snipurl.com/d0q7

-- 
Jonathan Arnold
inSORS
0
2/24/2005 1:33:41 PM
In the March 2005 issue of MSDN Magazine, Paul DiLascia's "C++ At Work"
column includes exactly the class you're looking for: CStaticLink.  See
http://msdn.microsoft.com/msdnmag/issues/05/03/CATWork/default.aspx

Mike


"Wellu M�kinen" <wellu@n0spamN0rHTml.w3llu.0r9.invalid> wrote in message
news:slrnd1r7b5.4up.wellu@wellu.org...
> Hi all,
>
>  First of all I'd like to say that I'm quite new to MFC and
>  Win32 APIs and my question might seem trivial to HC MFC
>  programmers.
>
>  I have a dialog based MFC application. When the user
>  selects Help->About.. the application shows yet another
>  dialog with some information on it. There's an URL too on
>  the dialog. I've managed to make the URL, which is a
>  CStatic text, clickable and once clicked it opens
>  up a web browser using ShellExecute. However I'd like the
>  text to be blue and underlined to show the user that it is
>  a hyperlink indeed. Now it is just like other texts on the
>  dialog i.e. black without underlining.
>
>  I should also implement a mouse listener that changes the
>  pointer to a hand when the pointer is over this URL.
>
>
>  Thanks for any help in advance,
> -- 
>               |||
>              (0-0)
> +--------oOO--(_)--OOo----------------------------+
> | Wellu M�kinen www.wellu.0rg                     |
> |                                                 |
> | No tears please, it's a waste of good suffering |
> +-------------------------------------------------+


0
2/24/2005 3:54:09 PM
On 2005-02-24, Michael K. O'Neill <MikeAThon2000@nospam.hotmail.com> wrote:
> In the March 2005 issue of MSDN Magazine, Paul DiLascia's "C++ At Work"
> column includes exactly the class you're looking for: CStaticLink.  See
> http://msdn.microsoft.com/msdnmag/issues/05/03/CATWork/default.aspx
>

 I've got plenty of answers where to choose from. I'll be
 back with a harder questions next time :) Until then, thanks
 for everyone!

-- 
              |||
             (0-0)
+--------oOO--(_)--OOo----------------------------+
| Wellu M�kinen www.wellu.0rg                     |
|                                                 |
| No tears please, it's a waste of good suffering |
+-------------------------------------------------+
0
Wellu
2/24/2005 7:38:28 PM
I did it as follows:

Subclass a CStatic control. Place a CStatic control on the dialog, and assign it a control
variable of the new type.

Implement the =WM_CTLCOLOR (reflected WM_CTLCOLOR), WM_LBUTTONDOWN, and WM_SETCURSOR
handlers.

In the constructor for the CStatic subclass, create a font. What I tend to do is

CFont * f = GetFont();
LOGFONT lf;
if(f == NULL)
   { /* temporary font */
    CFont ft;
    ft.CreateStockObject(DEFAULT_GUI_FONT);
    ft.GetLogFont(&lf);
   } /* temporary font */
else
  { /* use real font */
   f->GetLogFont(&lf);
  } /* use real font */

lf.lfUnderline = TRUE;
myfont.CreateFontIndirect(&lf);
// myfont is a CFont member variable of the CStatic class
SetFont(&myfont);

Make sure you set the SS_NOTIFY flag on the CStatic

Now, in the WM_SETCURSOR handler you would do
	HCURSOR hand = LoadCursor(NULL, IDC_HAND);
	SetCursor(habd);
	return TRUE;

In the =WM_CTLCOLOR you would do something like

 CRect r;
 GetClientRect(&r);
 CPoint pt;
 ::GetCursorPos(&pt);
 if(r.PtInRect(pt)) // I'm trusting memory here...
     SetTextColor(MY_COLOR_HIGHLIGHT_URL);
 else
     SetTextColor(MY_COLOR_NO_HIGHLIGHT_URL);

in WM_LBUTTONDOWN for your CStatic

CString url;
GetWIndowText(url);
ShellExecute(...url...); // I forget all the parameters...check docs

This is a sketch from memory, so I think it is fairly accurate, but apply grains of salt
as required.
				joe

On Thu, 24 Feb 2005 09:22:24 +0000 (UTC), Wellu M�kinen
<wellu@n0spamN0rHTml.w3llu.0r9.invalid> wrote:

> Hi all,
>
> First of all I'd like to say that I'm quite new to MFC and
> Win32 APIs and my question might seem trivial to HC MFC
> programmers.
>
> I have a dialog based MFC application. When the user
> selects Help->About.. the application shows yet another
> dialog with some information on it. There's an URL too on
> the dialog. I've managed to make the URL, which is a
> CStatic text, clickable and once clicked it opens
> up a web browser using ShellExecute. However I'd like the
> text to be blue and underlined to show the user that it is
> a hyperlink indeed. Now it is just like other texts on the
> dialog i.e. black without underlining.
>
> I should also implement a mouse listener that changes the
> pointer to a hand when the pointer is over this URL.
>
> 
> Thanks for any help in advance,

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
2/25/2005 12:19:40 AM
Reply:

Similar Artilces:

Dual Displays
I want to connect my Sharp Aquos flat screen TV to my computer, and see my desktop on both the TV and computer monitor. Windows Vista Home Premium. HP Pavilion a1610n computer. Galaxy GeForce 8400 GS graphics card, outputs: 1-VGA, 1-DVI, and 1-SVGA. There is no HDMI port on the card. I connected a VGA cable between the motherboard "on-board" VGA port and the TV, figuring that I could use that output to work with the TV. The computer monitor is plugged into the GeForce graphics card. Tried the Desktop "Display Setting". It says, the number 2 monitor is "N...

Display a message box "this entry is a duplicate"
How can I display a message box on a form if the shipment number is a duplicate? I need a message box to pop up when user attempts to tab out of the field. Thank you. Something like: Private Sub txtShipNum_BeforeUpdate(Cancel As Integer) If DCount("*", "MyTable", "ShipNum = '" & Me.txtShipNum & "'") > 0 Then Msgbox Me.txtShipNum & " already exists." Cancel = True End If End Sub This assumes that your text box is named txtShipNum, that the name of the field in table MyTable is ShipNum...

Folder could not be displayed
I am running Windows XP and Outlook Express 6 just fine then one day my husband does something to my computer and his email account won't work. My email is working just fine but in his he cannot open his inbox. It says folder could not be displayed, and when you send and receive it gives you this error message: "An unknown error has occured. Account: 'incoming.verizon.net'. Server:'incoming.verizon.net'.Protocol:POP3, port: 110, Secure(SSL): No, error number: 0x800C013B" If anyone could help me with this I would greatly appreciate it. Thank you T...

Converting Revisions to Text
I have two word files. I do a comparison of the two files. I would like to convert the comparison result into a file where the revisions are actual text and formatting. For example, I would like the deletions to become text with strikethrough, not text marked as a deletion displayed with a strikethough. I need this to export to another application. Is there any simple way to do this? ...

Independant Modeless CDialog
Hi, I am having some serious difficulty with a problem of multiple windows in the same application. I use a CDialog as my main window, which is created in the main app call with DoModal, from it however, I wish to create several dialogs that are modeless, each has a taskbar entry (somewhat like MSN messenger) - However, whenever I click on any of these windows the entire job lot pops up, including my origional window. I know in VB that everything was pretty independant, you could switch between windows at your chosing, and only toolbar windows would pop up, thats kind of what I am aft...

A simple but emergent help!!!
I am using MS WORD spreadsheet (EXCEL). I have random 25 integers for each row and there are 100 rows. Now I want to find the sum of the 20 largest integers (out of 25) for each row. What is the fastest/easiest way? Thanks and bow!!! --- Message posted from http://www.ExcelForum.com/ Don't know which is fastest but one way is, probably using large like =LARGE('Sheet1'!$A$2:$Y$101,row(1:1)) then copy down 25 rows and sum that. To get it in one fell swoop =SUMPRODUCT(LARGE(Sheet1!$A$2:$Y$101,ROW(INDIRECT("1:20")))) -- Regards, Peo Sjoblom "ilikeit"...

Simple formula not working
=IF(F4=1,H4,-1) Nearly all cells have numeric values, and for those with a value of 1 it works correctly, where the values are numeric it also works correctly. BUT - a few cells have 1 or 2 alphabetic characters, which means they are not equal to 1, so should yield a value of -1. For example I want XY, as it is clearly not 1, so condition F4=1 fails, to evaluate to -1 The referenced cells are formatted number. Is Excel flawed or am I missing something? Excel 2002 SP3 I would use: =IF(VALUE(F4)=1,H4,-1) Kind regards, Erny <ato_zee@hotmail.com> schrieb im Newsbeitrag news:I-udnel...

how to display values in 3 cells into one cell
Anyone can help me how do I display the 3 separate different values in 3 cells into just one single cell ? thanks so much in advance. Either there was a typo or there's an echo in here. That line should have been: = A1 & " " & B1 & " " & C1 "Bradley Dawson" <bradleydawson@earthlink.net> wrote in message news:l464b.2224$Lk5.2093@newsread3.news.pas.earthlink.net... > In the target cell, type: > > = A1 & B1 & C1 > > where A1, B1, C1 are the cell addresses that you want to concatenate. > > If these have number...

Trouble with CDialog DoModal()
I created a new dialog with two buttons and a richedit area. I used the wizard to create a new class and the code. Now, I got: ///////////////////////////////////////////////////////////////////////////// // CStatDialog dialog CStatDialog::CStatDialog(CWnd* pParent /*=NULL*/) : CDialog(CStatDialog::IDD, pParent) { //{{AFX_DATA_INIT(CStatDialog) m_StatisticText = _T(""); //}}AFX_DATA_INIT } void CStatDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CStatDialog) DDX_Text(pDX, IDC_RICHEDIT1, m_StatisticText); //}}AFX_DATA_MAP } ...

How to select & display distinct values
Hello, I need help with a form please. My form has two controls, the first being a combo box. This box should select the company name from a lookup table. The lookup table has only two companies in it, however, they each are repeated several time. Company 1 has about 10 rows, company 2 has 3 rows. I used the query builder and came up with the statement: "SELECT DISTINCT Lktbl_Role_Master.CompanyName FROM Lktbl_Role_Master;" When I run the statement directly from query view, it executes perfectly and returns exactly two rows (one for each company, in a datasheet view) ho...

grey text box
Need help adding the grey box to a document to click and fill basically. Deanna wrote: > Need help adding the grey box to a document to click and fill > basically. See http://www.computorcompanion.com/LPMArticle.asp?ID=22. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. ...

Display Time in Outlook
The time setting in my Outlook is one hour behind my actual time. I cannot determine how to change the time. Outlook is the only item that is incorrect. Other display times in operating system are correct. Thanks, Jodi ...

PK and FK Displayed
I am a complete Visio newbie, and cannot find the answer I need in books or online help. I am trying to create ER diagrams from scratch, and not connected to real tables, using VEA. I have added tables ('Entities') to the form, connected them with a Relationship connector, and, in the Database Properties window I've assigned the end points to a Primary Key on the left and a Foreign Key on the right. But the model shows the connector as running between the top colums on both sides, whereas I want the keys to be in that upper box and provide the connector's end points. Wh...

Simple hack to get $1500 to your home
Simple hack to get $1500 to your home At http://bannerclickandget.tk Due to high security risks, i have hidden the cheque link in an image. in that website on left side Above search box, click on image and enter your name and address where you want to receive your cheque. please don,t tell to anyone. ...

Formulas are displayed, results are not
Hello, For some reason, when I enter a formula into a cell and press enter, the formula just stays there. Anyone know what I can do to show the results? I tried pressing Cntrl + `, but that didn't work. FYI, when I cut and paste a column from a separate workbook, that column works like normal (i.e., the formulas produce results). Thanks for any suggestions! Hi Mike, Maybe your cell is preformatted as Text. Try formatting to general then erase your = and type it in again. HTH Martin "Mike C" <js2k111@yahoo.com> wrote in message news:f699bcd4-ad82-4a88-9759-5638c147b...

underline in row not repeating
It seems as if my bottom of the cell outline is not repeating on subsequent pages. I have a few header rows on a sheet. The bottom row has a bottom line. I'm talking about cell outlines, not underlining of words in the cell. Anyway, I've told the print option to repeat the first 3 rows on following pages but the bottom outline does not seem to repeat. How can I fix this? Thanks, Keith Never mind. This seems to be working. Not sure what was going on the first time. "Keith G Hicks" <krh@comcast.net> wrote in message news:OM82rj8rIHA.2068@TK2MSFTNGP05.phx.gbl... >...

Stop displaying a line
I have a line graph/chart and it gets its values using a formula and the values of another column. However this poses a problem because if there is nothing in the targetted column the formula returns 0 cause the line to drop to the bottom, instead of casuing the line to just end until a value is added to the target column. How can I do this? Change your formula to use NA() if the cell is empty. For example: =IF(A1="",NA(),A1) To hide the resulting #N/A errors on the worksheet, you can use conditional formatting. There are instructions here: http://www.contextures.com/xlC...

Converting number to text
Is it possible to convert, say 1234 to one thousand two hundred and thirty four Thanks There is no direct functions to convert this. For a VBA solution check out the below links http://www.ozgrid.com/VBA/ValueToWords.htm http://support.microsoft.com/kb/213360 http://www.xldynamic.com/source/xld.xlFAQ0004.html -- Jacob (MVP - Excel) "booshi" wrote: > Is it possible to convert, say 1234 to one thousand two hundred and thirty > four > > > Thanks > > > . > ...

unattached textboxes disappear when a msgbox is displayed on a tab control
I'm using Access 2003. I have a form with a tab control on it. I was having problems with labels flashing and I followed the suggesting from Allen Browne - http://allenbrowne.com/ser-46.html. The flashing went away but now when a msgbox is displayed the unattached textboxes that I'm using as labels disappear. They come back as soon as the msgbox is removed from the screen. I've searched google looking for an answer but have come up short. Does anyone know why I'm experiencing this behavior and how to make it go away? Thanks, Rick That *is* strange. Have you tr...

A question about Console window(display or not display)
I've redirected the (stdin stdout stderr) of a console window process I spawned to a pipe. And I want to display the redirected console window, the question is: If I display it(set Create_new_CONSOLE in createprocess and some flags in startupinfo), I cannot use the redirected way of pipe, which means if i do not display, i can use the pipe communicating with the child process. Does it mean that as long as I disply the console window, windows will change stdin stdout to "screen&keyboard" instead of my pipe? That's right. If you redirect stdin or stdout then you preemp...

Display or not display series
I have a graph with four series but some of the series may be blank, i.e. the series name is <blank series>. Is there a way to not display these series on the graph and/or legend if they are blank, and display them if they are without deleting the series? Thanks! Clay Create a chart from all the data Select the data on which the chart is based. Choose Data>Filter>AutoFilter In the heading cell for the series name column, select (NonBlanks) from the dropdown list The series with blank name cells will be hidden in the chart. Clay wrote: > I have a graph with four serie...

does Excel support multiple display monitors?
Hello All Excel Experts How do I move chart windows to multiple display montors?? (one computer runnng three monitors... Excel Charts will not move off the primary monitor. Your advice is EXTREMELY appreciated thanks. Denni ...

Displaying an equation
I have an equation setup that is referencing a few other cells that have equations in them. I want to have a cell that displays this equation with the answers that are calculated from these other cells displayed as values in the new equation. Any help would be greatly appreciated. Thanks Check out http://www.mvps.org/dmcritchie/excel/formula.htm#getformula In article <E4143E2B-360A-4B43-955F-73BF8EC60694@microsoft.com>, "hoising8" <hoising8@discussions.microsoft.com> wrote: > I have an equation setup that is referencing a few other cells that have > eq...

Retrieve Meeting Response Text Associated with an Appointment
How do I retrieve the text of meeting responses associated with an appointment? I have redeveloped a macro which produces a word document listing the meeting response status of invitees to an appointment. I would like, for those who declined, to include the body of the meeting response (ie., where the invitee has chosen to "Edit response before sending." While the Meeting Response Status is a Recipient property, the text of the response is not. Any ideas? I'm including the macro below: Public Sub PrintAttendees() ' Gather data from an opened appointment ...

Serialisation
A general query Im serialising a person object with the following member variables Class Person Private _forenames As String Private _surname As String Private _dob As Date Private _marital_status As MaritalStatus 'Public Get and Set Properties here for each of the above ' I'll not detail them all to save space but Ill show attributes <XmlElementAttribute(Elementname:="forename")> _ <XmlElementAttribute(Elementname:="surname")> _ <XmlElementAttribute(Elementname:="dob"...