 |
|
 |
I'm trying to use this control to 'activate' text on a dialog - meaning I don't want the hyperlink to act like a hyperlink, I just want to know in my dialog that it has been clicked.
So, how does one reroute the OnClicked message to the containing dialog? And is it possible to identify which CHyperlink control was clicked (if I have more than one)?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
IMHO the possible way is to modify the source by adding the RegisterMessage with some pseudo-unique message call in the header and then firing that registered message from the GotoURL to parent, basing on some condition, for example - if the URL string passed in is empty. Like that:
Add to Hyperlink.h: ~~~~~~~~~~~~~~~~~~~
const UINT NEAR WM_HYPERLINK_NOTYFY_PARENT_CLICK = ::RegisterWindowMessage(_T("WM_HYPERLINK_NOTYFY_PARENT_CLICK"));
Change the Hyperlink.cpp like this: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void CHyperLink::OnClicked() { m_bOverControl = FALSE; if (m_strURL.IsEmpty()) { GetParent()->PostMessage(WM_HYPERLINK_NOTYFY_PARENT_CLICK, (WPARAM)GetDlgCtrlID(), 0); return; } int result = (int)GotoURL(m_strURL, SW_SHOW); .............. }
Then proceed that message in parent window like this:
afx_msg LRESULT OnHyperlink(WPARAM wParam, LPARAM lParam) { if (wParam == IDC_STATIC_URL1) AfxMessageBox(L"Url1"); else if (wParam == IDC_STATIC_URL2) AfxMessageBox(L"Url2"); return 1; }; and add ON_REGISTERED_MESSAGE(WM_HYPERLINK_NOTYFY_PARENT_CLICK, OnHyperlink) to the message map. And don't forget to call SetURL(_T("")) to make it work. This method avoids us from changing the reflection idea.
modified on Friday, April 3, 2009 11:58 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
In this example there is one dialog named "HyperLink Sample". On this dialog there is static text named "mail me" and Ok button is there.
I want same functionality but just want to destroy "HyperLink Sample" dialog when someone clicks on it as well as it should work as HyperLink.
Thanks, Hemang
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I'd like to thank for this wonderful MFC control. It really looks simple and professional. I was saved quite a lot of work. x10 ))
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
there are not completely understandable explanations in the article, which way can people use Hyperlink control ? If the usage of yours Hyperlink control is forbidden in the commercial products, please, let me know ASAP.
I have mentioned you and CHyperLink in the "Credits" section of the Help file.
Please, check this. If everything OK, or I should make credits some another way?
The product site is: http://www.timestimator.com/
If you found Timestimator useful for you, of course, you are always welcome for free license (when the program become completely commercial)
With the best regards, Vit
With the best regards, Vit
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hello
I am using CHyperLink in my application to open a page. This opens in IE. But how is it possible to make this open in Firefox?
thanks in advance Renjith
|
| Sign In·View Thread·PermaLink | 4.20/5 (2 votes) |
|
|
|
 |
|
 |
I just want to create a Hyperlink control with "Create()"Function like this : m_Hyperlink.Create(_T("Add Custom"),WS_VISIBLE,Rect(10,10,90,30), this, 99999); But I got this : Unhandled exception at 0x78337cba (mfc80ud.dll) in Manager.exe: 0xC0000005: Access violation reading location 0x00000004. Can you help me ?
|
| Sign In·View Thread·PermaLink | 1.67/5 (3 votes) |
|
|
|
 |
|
 |
I'm not sure if these fixes are 100% correct, but I had to make these changes in order for things to work...
1) In SetURL
m_strURL = strURL; SetWindowText(m_strURL); <-- added this
The url wouldn't change using this method, so I added the SetWindowText call. A check to see if it's an empty string might be useful too.
2) In PositionWindow
My center aligned url was being cut off on the left side.
I changed... Extent.cx += WndRect.Width() - ClientRect.Width(); to Extent.cx += WndRect.Width() - ClientRect.Width() + 1;
Now the text is showing correctly.
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi,
You have it wrong with the fix #1. This is not a bug. It allows you to have the hyperlink caption set to something with SetWindowText() and associate a URL with SetURL.
Go on any web page and you'll see that it is quite rare that a hyperlink text is the underlying URL associated to the link.
If you want both the caption to be the URL text, the correct way of using it would be to both call SetWindowText and SetURL().
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi, Thanks for this nice Hyperlink control. I am encountering one problem. I have 10-15 static controls on my form, and I am using Hyperlink class for 3 static controls. But the CtlColor event of Hyperlink class is not firing. I am firing OnCtlColor event in my View class. Please tell me how to fire the CtlColor event of Hyperlink class.
Thanks, Sanat
Sanat
|
| Sign In·View Thread·PermaLink | 1.50/5 (2 votes) |
|
|
|
 |
|
 |
I tried to build the demo project in VC6, and I got compile error:
Cannot open include file: 'atlconv.h'
I suspect I need to add some compile option. Can anyone advice?
Thanks a lot,
Don Chen
|
| Sign In·View Thread·PermaLink | 2.00/5 (2 votes) |
|
|
|
 |
|
 |
Hello Sir, I want create hyperlink control as u show but i don't like to use mfc so how can i create hyperlink control using win32(api)
plz ,help me
|
| Sign In·View Thread·PermaLink | 3.00/5 (2 votes) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
 |
First of all, thanks for this very good control. 
I have only one suggestion about the default hand cursor : on Windows 98/Me/2000/XP, you can use IDC_HAND to load the cursor which gives you also support for the drop shadow. To keep compatibility for Win 95, you can modify the SetDefaultCursor() in the following way :
void CHyperLink::SetDefaultCursor() { if (m_hLinkCursor == NULL) { #ifdef IDC_HAND m_hLinkCursor = ::LoadCursor(NULL, IDC_HAND); if (m_hLinkCursor == NULL) #endif { CString strWndDir; GetWindowsDirectory(strWndDir.GetBuffer(MAX_PATH), MAX_PATH); strWndDir.ReleaseBuffer();
strWndDir += _T("\\winhlp32.exe"); HMODULE hModule = LoadLibrary(strWndDir); if (hModule) { HCURSOR hHandCursor = ::LoadCursor(hModule, MAKEINTRESOURCE(106)); if (hHandCursor) m_hLinkCursor = CopyCursor(hHandCursor); } FreeLibrary(hModule); } } }
|
| Sign In·View Thread·PermaLink | 5.00/5 (3 votes) |
|
|
|
 |
|
 |
Hi Chris !
First, nice work, this control is really cool. But I have the following problem :
If I update the window text of the CHyperLink on runtime, it would not erase the control background (and the old text) before overwriting the new text ... I've tried Invalidate(), InvalidateRect() and RedrawWindow() for both only the control and the main dialog, the only thing that will function is RedrawWindow for the main dialog, but then it goes to flickering Can you help me with that ? (It can be that I do not know how to RedrawWindow() properly only the control, too )
Thanks a lot.
~RaGE();
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
i have a win32-project (without mfc) building upon the scrnsave.lib by microsoft. i have a dialog for the screensaver and want to use a text or image as a hyperlink there. how can i get a click-message from a static text in my wndproc?
greets,
morgler
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
I wonder if anybody knows how hyperlink control can be plugged into a dialog bar. If I am using Chris Maunder's dialog with hyperlink control on it as my dialog bar, the dialog bar would be created in MainFrm.cpp :
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1;
if (!m_wndDlgBar.Create(this, IDD_HLSAMPLE_DIALOG, CBRS_ALIGN_RIGHT, AFX_IDW_DIALOGBAR)) { TRACE0("Failed to create dialogbar\n"); return -1; // fail to create }
return 0; }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
hi, i want to show hyperlink on a particular column. this column is in listcontrol. So how can i do this? i want to show hand cursor if i am on that column or row and after clicking on it i get some dialog. I am ablre to get dialog after clicking. My requirement is to display hyperlink or hand cursor for that column or row. this is highpriority for my project. Please tell me how can i achieve this? thank you, kalpana
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
In your code you are using a timer to determine whether the user is moving the mouse inside or outside the control. This is a good way to do it, but you get WM_TIMER msg every 100 ms. And even you have left the control, you will see a sort of delay after the underline is removed. You see it especially when you have more than one hyperlink. A better way to detect that the mouse is outside the control is to capture all OnMouseMove messages. If the point retrieved is not inside the rectangular of the control, then you know that the mouse is not on the control anymore. This is the code to replace the OnMouseMove function:
void CHyperLink::OnMouseMove(UINT nFlags, CPoint point) { if (m_bOverControl != FALSE) { CRect rect; GetClientRect(&rect);
if (rect.PtInRect(point) == FALSE) { m_bOverControl = FALSE; SetFont(&m_StdFont); Invalidate(); ReleaseCapture(); } } else { m_bOverControl = TRUE; SetFont(&m_UnderlineFont); Invalidate(); SetCapture(); }
CStatic::OnMouseMove(nFlags, point); }
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |