VC use keyboard to operate static links open URLs in applications

Source: Internet
Author: User
Tags resource visual studio

Over the years I've been using your Cstaticlink class in the company's business processes, and in the 1998 MSJ March, you demonstrated how to add a hand cursor to a hyperlink, but now I want to use this class in another way. In Microsoft's IE browser, you can use the TAB key to iterate through any hyperlinks in the Web page and press ENTER to click the link. Can I get cstaticlink to do the same thing? Am I a little more than an inch?

If you want me to lend you 1000 dollars, that's an inch--but using the keyboard to operate cstaticlink is a reasonable requirement. I can imagine that this is especially true for a person who is accustomed to using a keyboard. I hate to reach for the boring mouse (which is why I use Emacs), and I hate apps that provide enough keyboard support. So your request is not excessive; instead, you should get the user interface Best Award.

For new readers, Cstaticlink is a class I wrote back in December 1997 that allows you to add Web links to a form or to a dialog box. The Cstaticlink class is based on the MFC static control class CStatic. According to the reader's requirements for this kind of functional characteristics, I continued to improve it and enhance it, it seems that this time there is something to do. Cstaticlink starts the URL with a mouse click, and there are other friendly features, such as using standard blue/purple to draw the text display color (you can customize) of the unread/accessed links, text underlines, and mouse cursors when the mouse is moved over the link. Cstaticlink can even find a string of resources with the same ID number as the control in the resource file, thereby automatically loading the URL. If you haven't used Cstaticlink, try it.

Now Tom wisely asked me to do a static link with a keyboard operation available. There are two basic things to do, one is to make the link with the tab style, the second is to handle the linked keyboard navigation. Let's start by creating the Tab style.

When the user presses the TAB key in the dialog box, Windows moves the input focus to the next control in the tab order. The focus rests on a control that has a tab attribute-a control that has a ws_tabstop style. By default, the dialog editor does not create static controls that have ws_tabstop styles. Because static controls are static, they do nothing, they do not change at all, and they do not interact with the user.

However, now that Cstaticlink is given the ability to click on the mouse, it makes sense to ask for the Tab attribute. One of the most important principles of the user interface (note, buddy) is that no matter what the user can do with the mouse, it must be able to do it with the keyboard. This is not only the object of my habitual use of the keyboard friendly people, but also convenient to use the mouse to prevent the mouse line off. Maybe your users use a wireless mouse, but the mouse battery runs out at 1:00 and the report is to be submitted on the morning of the day-when you know you can do it with the keyboard, wouldn't that be a great thing?

So the first thing is to have the static link have the Tab Stop property, add Ws_tabstop to the resource file, or set the control's TABSTOP property to True in Visual Studio. NET, as shown in figure one.

Figure 1 Setting the Tab Stop property for a static link

Once you set the tab Stop property for the control, the dialog box runs, and the user can then use the TAB key to manipulate it. The only problem now is that when the user does this, nothing happens. There is no visual indication that the control has input focus. If you use the tab to manipulate an edit box control, it displays a flashing cursor. If it is a list box, Windows draws a dotted rectangle around the first item, and if it is a button, Windows will draw a focus rectangle inside the button. But Cstaticlink do nothing.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.