Results 1 to 8 of 8

Thread: [2010-09-04] EruLabel control

Threaded View

  1. #1

    Thread Starter
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    [2010-09-04] EruLabel control

    Ever used CSS and then went back to your VB6 and missed a bit something? Rounded corners? Margins? Padding? Opacity? I've put together this little control that should make things a little bit nicer. Not perfect, but nicer.



    Label features
    A lot of the regular Label features are supported!
    • Alignment: left, center, right!
    • AutoSize: yeah, it works flawlessly.
    • BackStyle: enables border & background drawing.
    • UseMnemonic: & character works for setting an access key.
    • WordWrap: works just like you'd expect it to.
    • BackColor, Font, ForeColor, MouseIcon, MousePointer are supported.
    • Change, Click, DblClick, MouseDown, MouseMove, MouseUp events are supported.

    Special about the MouseDown, MouseMove & MouseUp events is that they use the same ScaleMode as the container! This makes it easier to interact with the X & Y values as you do not need to use ScaleX & ScaleY to make the values match with what you have in your container

    Unicode features
    The control is Unicode aware. In IDE design time you can use CaptionHex and CodePoints properties to manipulate the Caption string using UTF-16 codes.
    • CaptionHex is a simple little endian property. If you copy UTF-16 from a hex editor it'll work here.
    • CodePoints shows the same information as a comma separated list displaying the character values in 0 – 65535 range.
    • RightToLeft is supported.


    CSS features
    Some features are made to feel much more familiar from the CSS world. They aren't a perfect imitation, but if you've ever written any CSS stuff you'll feel these features much more convenient than in many other VB6 implementations that do the same thing.
    • BorderRadius is a simple numeric value that will give you some rounded corners. The feature is implemented using native Windows API RoundRect, which means you can't expect perfect CSS imitation.
    • BorderColor, BorderStyle, BorderWidth give you control of the borders. You do not need to set a width for BorderRadius to round the corners of your EruLabel.
    • Margin is a shorthand property nearly identical to what you can find in CSS. It only support px-values, but other than that if you've ever used margins in CSS then you'll find this feature familiar. The order is top, right, bottom, left: 0px 0px 0px 0px
    • Padding is a property just like Margin, but it expands the area within the drawn background.
    • MarginBottom, MarginLeft, MarginRight, MarginTop, PaddingBottom, PaddingLeft, PaddingRight, PaddingTop allow for individual control of margin & padding.
    • Opacity is a floating point value from 0 to 1. 0.5 means the opacity level is at 50%. Just like in CSS!


    Note that Margin & Padding also replicate values like in CSS! If you do:

    EruLabel.Padding = "1px 2px"

    it will be understood as:

    EruLabel.Padding = "1px 2px 1px 2px"

    Which means top & bottom padding = 1 pixel, right & left padding = 2 pixels

    You can even just write 5 in the IDE property window and it turns into 5px 5px 5px 5px!


    Special notes
    This control has been written quickly in just one day (24 hours). I took advantage of my old UniLabel project. I can't yet claim this control to be entirely bug free. But it should be pretty stable: it does not use subclassing! If you have any problems then post them here, tell me what you tried to do, what you expected to happen and then what you got.

    This control does not support MouseEnter & MouseLeave events like UniLabel does.
    Data binding & Link features supported by native Label are not supported.
    Attached Images Attached Images  
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width