|
Hello James,
First of all, thanks for developing such a good Hyper Link control. This is the best control. I have used it and its working very well. But my problem is that, I have a facility of Print and Print Preview in my tool, but as CJRTSLinkCtrl is dependent on Button, I cannot see the content (Display String) of the button in my Print Preview window. Let me know how to make this control (or its content string) printable in the Print Preview and finally in the Print.
Any help will be appreciated.
Thanks,
Nitin Dangare
|
|
|
|
|
Thank you for your comments on the control.
To be able to assist you further, I would need a better idea of how the control is being used. For example, are you using it on a CFormView-based view and then using Print Preview on the view?
Peace!
-=- James (Sonork:100.21837)
[Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"!] [Get Delete FXP Files Now!]
|
|
|
|
|
Thanks for your quick and prompt reply.
My application is a MDI. I have a class xxxview that is inherited from CDaoRecordView, futhur I have a class yyyView inherited from xxxview. I also have zzzView inherited from yyyView.
Visually this means CDaoRecordView->xxxview->yyyView->zzzView. I have a dialog box that will display the records using the zzzView. This implies that the dialog box is placed on zzzView. The record set contains 2 fields that need hyper linking, hence I used your class for these fields. Navigation from one record to other, paints the hyper linked fields very well. I need to print or print preview this (dialog) view. But due to the buttons used for this hyper linking, I am unable to print or print preview these 2 specific control/fields, rest all fields get printed in the print preview.
Any furthur help is really appreciated.
Thanks,
Nitin Dangare
|
|
|
|
|
I expect that this is a naive question, but I can't get this control to work in a non-dialog window derived from CWnd. In particular, I can't figure out how to use the control's Create method. Is there detailed documentation for this method?
Thanks!
|
|
|
|
|
The easiest thing that I can suggest is to create a normal Button control where you want the link to be, and then subclass it using the Link Control, just like how it normally happens via Classwizard.
The Create method remains unchanged from the base class' version.
Peace!
-=- James (Sonork:100.21837)
[Tip for SUV drivers: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"!] [Get Check Favorites 1.6 Now!]
|
|
|
|
|
Your control doesnt paint properly in Windows XP, or any visual style where the color of a button face (m_crBackground, COLOR_BTNFACE) is not the same as the color of dialog box (COLOR_3DFACE), or even worse the color of a property sheet background (COLOR_.... I dont know, they dont have an index for it! Its white-ish!).
It paints a grey box around the text... looks bad.
I fixed it by replacing
<br />
dcDC.SetBkColor( m_crBackground );<br />
dcDC.ExtTextOut( iSpaceX, iSpaceY, ETO_OPAQUE, &rClient, <br />
m_sDisplay, NULL ); <br />
with
<br />
dcDC.SetBkMode(TRANSPARENT);<br />
dcDC.ExtTextOut( iSpaceX, iSpaceY, 0, &rClient, <br />
m_sDisplay, NULL ); <br />
<br />
But, this causes the focus rect to flash various colors when I move the mouse over the control, since it is XORing with what was there before (no longer a solid color). I just commented out DrawFocusRect cause I dont care about it.
|
|
|
|
|
The article information at the top of the page includes WindowsXP, and it should not -- WindowsXP includes a native HyperLink control in its common controls. Since you already have a native control, you should not be using a replacement like mine.
Turning off styles (if using them), and using Win2K-style controls might help the drawing issue, though.
I will investigate if using COLOR_3DFACE is a more appropriate color index to use. Now that I think about it, it likely is. As for the Property Sheet background... Well, as I said, you should not be using my control on XP, anyway!
Peace!
-=- James (Sonork:100.21837)
[Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"!] [Get Check Favorites 1.5 Now!]
|
|
|
|
|
So if I use this control, customers who run my program under XP will see problems? Am I understanding this correctly? That's a showstopper.
|
|
|
|
|
Since there are already at least three Microsoft Knowledge Base articles regarding Themes, I would suggest trying it without themes enabled; I built the project on XP, and experienced no trouble with it (but I do not use themes).
As mentioned above, Windows XP already has a native link control, so when running on XP, your application should use it instead of mine; why reinvent that wheel?
At some point, I will "code around" the problem. Just not right now.
Peace!
-=- James (Sonork:100.21837)
[Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"!] [Get Delete FXP Files Now!]
|
|
|
|
|
James R. Twine wrote:
As mentioned above, Windows XP already has a native link control, so when running on XP, your application should use it instead of mine; why reinvent that wheel?
I think this is not a good point of view, it is not practical for a coder to choose at runtime a control or another depending on operating system. A good control must consider all cases. If your control doesn't work correctly with WinXP themes then you have 2 alternatives, I think:
1) Make some special arrangements to detect if theme is active to make a different painting.
2) Wrap the WinXP control inside your control and activate it in case a theme is active, this way user will have a UNIQUE interface to use both alternatives.
Best regards,
Jaime.
|
|
|
|
|
Your point is valid, accepting the fact that when I first wrote the control, I did not know about Windows XP having a native one, nor did I even have it installed at that point. All I knew was that the implementations already out there were not entirely correct.
To your point: if I had reason to believe that it was being used by enough developers, I would consider releasing my internal updates to it (same goes for the other controls I have written). But most of the links I see in applications are still based the static control, and I have never seen my name in the credits or even received an email regarding use of my code. If I do release any updates, or new code, they will be released under my FSCL (Free Source Code License, http://www.jrtwine.com/fscl.htm[^]). Since there is no 100% clear license term for code submitted to CP, they will likely only be available from my web site.
Thank you for the feedback!
BTW... Using COLOR_3DFACE solves the background color issue. In the constructor, replace line:
m_crBackground = ::GetSysColor( COLOR_BTNFACE );
With:
m_crBackground = ::GetSysColor( COLOR_3DFACE );
Changes to adjust the "active rect" for the link itself are not included here.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Well, I have tested your control in a simple dialog in WinXP with silver and olive colored themes and seems to work Ok.
So, at least I think it works ok with standard dialogs.
BR
Jaime.
|
|
|
|
|
Problem 1:
m_crHotTrack = ::GetSysColor( COLOR_HOTLIGHT ); //RGB( 0x00, 0x00, 0xFF );
COLOR_HOTLIGHT is defined if WINVER >= 0x0500
What if WINVER < 0x0500 (Win98, ...).
Problem 2:
OCR_NORMAL is available only with # define OEMRESOURCE
I'm using VC6.0
Am I wrong?
Predrag Manojlovic
|
|
|
|
|
> COLOR_HOTLIGHT is defined if WINVER >= 0x0500
> What if WINVER < 0x0500 (Win98, ...).
COLOR_HOTLIGHT is available on 98 and higher and Win2K and higher (read: not 9x or NT 4.0). If you use that value on one of those platforms, it will return 0 .
> OCR_NORMAL is available only with # define OEMRESOURCE
Yes, because OCR_ identifies an OEM resource: OCR == O EM C uR sor.
> Am I wrong?
See above!
Peace!
-=- James (Sonork:100.21837)
[Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"!] [Get Check Favorites 1.5 Now!]
|
|
|
|
|
I cann't complie the source, why?
=============================================
SkinMagic SDK Library
The better solution for Skinnable application
http://www.appspeed.com
==============================================
|
|
|
|
|
Because you're spending too much time spamming the message boards?
--Mike--
I'm bored... Episode I bored.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
|
> I cann't complie the source, why?
Perhaps some example error messages...?
-=- James (Sonork:100.21837)
[Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"!] [Get Check Favorites 1.5 Now!]
|
|
|
|
|
Hi James,
Nice article. I noticed it because i wrote my own hyperlinks just couple weeks ago. I thought it might be useful to anyone reading this article as well as for both of us to help each other improve our libraries. You can download my hyperlinks here www.tooltips.net. To start with,
For example, many of them are based on the Static control, and as such are unable to be focused using the keyboard, which means that they are useless without a mouse (accessibility issue), and have incorrect click behavior.
isn't correct, and CStatic can be overridden to accept keyboard input.
For a difference, i wrote my hyperlink to support different styles and behavior. One of them: when you hover the mouse cursor over the object it gets underlined. Anyway, you also got something i didn't extend my hyperlink with, like drag'n drop support. But hey, very good, nice article, as i said. I hope to hear from you also as regards to my hyperlinks, to compare with the lots of others you mentioned out there in the internet space.
One big problem with your hyperlink i noticed at first glance was that it flicks and updates itself too much when the mouse is moving above it.
I hope i didn't get you offended sticking into your article like this or anything...
Cheers!
Vitaly
Ultimate all-in-one XP-Style UI multiplatform solution: Tooltips, XP Menus, Hyperlinks, Drawing Graphics and formatted documents, plus powerful binary resource reuse. All Free 100%, visit www.tooltips.net now. The most powerful integrate UI library for developers in VC++, C#, Java, VB, Delphi, Borland C++, Borland C++ Builder, as well as any COM-compatible platform; Unified approach, cross-language OS, full .NET integration.
|
|
|
|
|
> To start with:For example, many of them are based on the Static control, and as such are unable to be focused using the keyboard, which means that they are useless without a mouse (accessibility issue), and have incorrect click behavior. > isn't correct, and CStatic can be overridden to accept keyboard input.
A control usually only accepts keyboard input only when it has the input focus. Of course, the Parent window can also handle keyboard input on behalf of the control. But keyboard input is not the problem, the focus is.
However, giving the benefit of the doubt, I downloaded your HyperLinks example program, and the hyperlinks demonstrated in it suffer from some of the problems that I mention in my article: 1: they cannot be focused via the keyboard (the <TAB> key does nothing, the focus remains on the Exit button) and the focus does not change to the control via the mouse; and 2: the links activate on the button-down, not the button-up.
Also, the controls show tooltips even when their parent window does not have the focus (for example, move the browser window so that it overlaps half of the demo application's window; click in the browser to make it the active window, and then mouse-over the controls in the demo). The tooltips are not supposed to be shown. Lastly, your CheckBox and HighLight buttons also activate on the button-down, not the button-up. You can observe the correct behavior by pressing the mouse button down on the Exit and not releasing it, and noting that the application is still running!
The controls also do not appear to capture the mouse correctly (but that may be a moot point because the controls react to the button-down).
However, I do like your tooltips, even if they do take a little while to come and go!
If I may offer a thought: The controls/style that you call "Web-Like Hyperlinks" in your demo application behave more like flyover or "hot" buttons. Most hyperlinks in browsers do not modify their appearance that much when they are moused-over, at least not without the help from JavaScript or DHTML...!
Peace!
-=- James (Sonork:100.21837)
[Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"!] [Get Check Favorites 1.5 Now!]
|
|
|
|
|
About all the problems you described i only can say that the hyperlings i designed are very customizable. You can override them easily to make work the way you want. It got lots of virtual functions for that.
If you're saying that you do not want to see tooltips for inactive applications, just handle WM_ACTIVATE in your application, and switch off the tooltips, if the window is deactivated by calling m_tt.Active = false;
To enable keyboard focus and input set flag WS_TABSTOP visually in the resource designer, then you can draw different QHTML appearance of hyperlinks depending whether or not the control has the input focus. If you don't like it handling WM_LBUTTONDOWN, ok, then just override the windows event, and call OpenUrl when you need it. Again, class CHyperLink can be customized any way you want. And it has very straightforward code in it.
The way i called those Web-Like Hyperlinks isn't so important, but yes, you would need to use JavaScript to simulate it. I always do so, for instance even on my web site, if you noticed that.
The controls also do not appear to capture the mouse correctly
-Why? What do you mean?
Ultimate all-in-one XP-Style UI multiplatform solution: Tooltips, XP Menus, Hyperlinks, Drawing Graphics and formatted documents, plus powerful binary resource reuse. All Free 100%, visit www.tooltips.net now. The most powerful integrate UI library for developers in VC++, C#, Java, VB, Delphi, Borland C++, Borland C++ Builder, as well as any COM-compatible platform; Unified approach, cross-language OS, full .NET integration.
|
|
|
|
|
> About all the problems you described i only can say that the hyperlings i designed are very customizable. You can override them easily to make work the way you want. It got lots of virtual functions for that.
I never said that the problems could not be "worked around". My goal as a software developer is to design/develop things that do not need to be "worked around" in order to function as expected. Some have other goals...
> If you're saying that you do not want to see tooltips for inactive applications, just handle WM_ACTIVATE in your application, and switch off the tooltips, if the window is deactivated by calling m_tt.Active = false;
I am saying that the expected behavior of tooltips is not to be shown if their control/parent is not active. Try this in Explorer and you will see what I mean. My control behaves as expected, without the need to handle WM_ACTIVATE at the application level, and propogate that notification throughout all visible controls. That sounds like a lot of work just to get something to work correctly, when it could have been done at the control level.
> To enable keyboard focus and input set flag WS_TABSTOP visually in the resource designer, then you can draw different QHTML appearance of hyperlinks depending whether or not the control has the input focus.
Actually, you would just draw a normal Focus Rectangle, and while adding the style makes the control navigable via the keyboard, it still cannot be activated without "working around" with some additional code.
> If you don't like it handling WM_LBUTTONDOWN, ok, then just override the windows event, and call OpenUrl when you need it. Again, class CHyperLink can be customized any way you want. And it has very straightforward code in it.
As I said before, I did not say that the issues could not be "worked around", I believe they should not be there in the first place... But we are of different schools of thought, it seems. Oh, well.
>> The controls also do not appear to capture the mouse correctly
> -Why? What do you mean?
I cannot make the point any clearer. Do you not understand what it means to "capture" the mouse? Besides, since the controls activate on the button-down, it is a moot point: this is something else that can be "worked around" if needed.
Peace!
-=- James (Sonork:100.21837)
[Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"!] [Get Check Favorites 1.5 Now!]
|
|
|
|
|
Just use QHTM - http://www.gipsysoft.com/
|
|
|
|
|
Very original, Russ
Very
Ultimate all-in-one XP-Style UI multiplatform solution: Tooltips, XP Menus, Hyperlinks, Drawing Graphics and formatted documents, plus powerful binary resource reuse. All Free 100%, visit www.tooltips.net now. The most powerful integrate UI library for developers in VC++, C#, Java, VB, Delphi, Borland C++, Borland C++ Builder, as well as any COM-compatible platform; Unified approach, cross-language OS, full .NET integration.
|
|
|
|
|
The point is taken,
but again, what's wrong in my code with capturing mouse?
Ultimate all-in-one XP-Style UI multiplatform solution: Tooltips, XP Menus, Hyperlinks, Drawing Graphics and formatted documents, plus powerful binary resource reuse. All Free 100%, visit www.tooltips.net now. The most powerful integrate UI library for developers in VC++, C#, Java, VB, Delphi, Borland C++, Borland C++ Builder, as well as any COM-compatible platform; Unified approach, cross-language OS, full .NET integration.
|
|
|
|
|