Extract usercontrols from issuevision Part I-panecaption

Source: Internet
Author: User
ArticleDirectory
    • Panecaption

Issuevision is the code example for smart client at devdays 2004. You can get more infomation from devdays 2004 video.

There are several XP style usercontrols contained in this solution. Now, let's extract them for our own projects.

Panecaption

Panecaption draws the caption for each pane. contains an active state and draws the caption different for each State. caption is drawn with a gradient fill and antialias font.

Just pick out two files, panecaption. CS panecaption. resx, we can extract this control.

Create your new "Windows control library" project mycontrols and add the tow files to your project folder. Build this project and test it in another project.

OK, it's working now!

Oh, wait! Why anitalias dose not work? I changed again and again, but it is only available in design time! What's wrong?

Yeah, you find out a little bug (I think it belongs the IDE what I am using -- vs. net2003). Let's defeat it.

Look at the following codes:

Private BoolM_antialias= False ; 

 

[Categoryattribute ( " Appearance " )]
[Descriptionattribute ( " If shoshould draw the text as antialiased. " )]
[Defavaluvalueattribute ( True )]
Public   Bool Antialias {
Get   {
ReturnM_antialias;
}  

Set   {
M_antialias=Value;
Invalidate ();
}
}  

 

Understood?

What? Did not?

Oh, my God. Let me explain.

"[Defaultvalueattribute (true)]"Means the default value of this property (antialias) is "true";"Private bool m_antialias = false;"Means it sets the property variant into "false" when you put the control on Form (design time ).

As we known, in Visual Studio, it will modify the initializecomponent () automatically when you changed a value in property toolbox. now, the initialized value is "false" not the default value "true ". obviusly, the IDE think it's the default value! So, it write the opposite code.

Thus, modify"Private bool m_antialias = false;"Into"Private bool m_antialias = true;"Then you will enable" antialias "ability.

Moreover, allowactive has this problem too. I believe you can solve it yourself.

Enjoy it .;)

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.