How to create Delphi TSpeedButton or SpeedButton in C # 2.0?

How to create Delphi TSpeedButton or SpeedButton in C # 2.0?

+3
source share
4 answers

I am wondering if you want to create a control like TSpeedButton, or if you only need the same end result ...

Programming from scratch is, of course, possible, but I would only do it as a training exercise.

Assuming you want to achieve a similar end result ...

In Delphi TSpeedButton there are differences from the standard TButton, which the developers find useful - it was flat, it did not focus, and it consumed less resources than a regular button (because it did not have a basic Windows handle).

Which ones are important to you?

, , FlatStyle = Flat ( PopUp) TabStop = false. , Image, ImageList ImageIndex/ImageKey.

, - Krypton Toolkit ( , . http://www.componentfactory.com/toolkit_buttoncontrols.php).

, , , , .

Windows 3.1 (Delphi 1) Windows 95 (Delphi 2) , . Windows XP Vista , - , . , .

+3

TabStop false ...

( ) , , , .

, , Button , SetStyles, , , Selectable to false:

public class ButtonNoFocus : Button
{
    public ButtonNoFocus()
        : base()
    {
        base.SetStyle(ControlStyles.Selectable, false);
    }
}

, , , . , ...

+2

Does this help? It looks like you will have to handle the OnPaint event, not focus ...

0
source

The regular .net 2.0 button supports part of what TSpeedbutton does:

  • Symbol: Image
  • Flat: FlatStyle

It does not handle:

  • Down
  • Group

These two are related to each other, you can inherit from the button and ownerdraw, adding the Down and Group functions.

There is an example of ownerdraw buttons in the codeproject.

0
source

Source: https://habr.com/ru/post/1698535/


All Articles