📄 udrawframecontrol.pas
字号:
unit UDrawFrameControl;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
RadioGroup_ButtonType: TRadioGroup;
RadioGroup1: TRadioGroup;
RadioGroup2: TRadioGroup;
RadioGroup3: TRadioGroup;
RadioGroup4: TRadioGroup;
RadioGroup5: TRadioGroup;
procedure Button1Click(Sender: TObject);
procedure RadioGroup_ButtonTypeClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
TheRect: Trect; // the bounding rectangle for the control image
TheType: UINT; // holds the type of control
TheState: UINT; // holds the state of the control
begin
{initialize the type and state flags}
TheType := 0;
TheState := 0;
{define the bounding rectangle}
TheRect := Rect(10, 10, 50, 50);
{choose the type of frame control}
case RadioGroup_ButtonType.ItemIndex of
0:
begin
{indicate we are drawing a button}
TheType := DFC_BUTTON;
{chose the state of the control}
case RadioGroup1.ItemIndex of
0: TheState := DFCS_BUTTON3STATE;
1: TheState := DFCS_BUTTONCHECK;
2: TheState := DFCS_BUTTONPUSH;
3: TheState := DFCS_BUTTONRADIO;
4: TheState := DFCS_BUTTONRADIOIMAGE;
5: TheState := DFCS_BUTTONRADIOMASK;
end;
end;
1:
begin
{indicate we are drawing a caption bar button}
TheType := DFC_CAPTION;
{chose the state of the control}
case RadioGroup2.ItemIndex of
0: TheState := DFCS_CAPTIONCLOSE;
1: TheState := DFCS_CAPTIONHELP;
2: TheState := DFCS_CAPTIONMAX;
3: TheState := DFCS_CAPTIONMIN;
4: TheState := DFCS_CAPTIONRESTORE;
end;
end;
2:
begin
{indicate we are drawing a menu item bitmap}
TheType := DFC_MENU;
{chose the state of the control}
case RadioGroup3.ItemIndex of
0: TheState := DFCS_MENUARROW;
1: TheState := DFCS_MENUBULLET;
2: TheState := DFCS_MENUCHECK;
end;
end;
3:
begin
{indicate we are drawing a scroll bar button}
TheType := DFC_SCROLL;
{chose the TheState of the control}
case RadioGroup4.ItemIndex of
0: TheState := DFCS_SCROLLCOMBOBOX;
1: TheState := DFCS_SCROLLDOWN;
2: TheState := DFCS_SCROLLLEFT;
3: TheState := DFCS_SCROLLRIGHT;
4: TheState := DFCS_SCROLLSIZEGRIP;
5: TheState := DFCS_SCROLLUP;
end;
end;
4:
begin
{indicate we are drawing a popup menu}
TheType := DFC_POPUPMENU;
{chose the TheState of the control}
case RadioGroup4.ItemIndex of
0: TheState := DFCS_SCROLLCOMBOBOX;
1: TheState := DFCS_SCROLLDOWN;
2: TheState := DFCS_SCROLLLEFT;
3: TheState := DFCS_SCROLLRIGHT;
4: TheState := DFCS_SCROLLSIZEGRIP;
5: TheState := DFCS_SCROLLUP;
end;
end;
end;
{identify the state of the button}
case RadioGroup5.ItemIndex of
0: TheState := TheState or DFCS_CHECKED;
1: TheState := TheState or DFCS_FLAT;
2: TheState := TheState or DFCS_HOT;
3: TheState := TheState or DFCS_INACTIVE;
4: TheState := TheState or DFCS_MONO;
5: TheState := TheState or DFCS_PUSHED;
6: TheState := TheState or DFCS_TRANSPARENT;
end;
{erase any previous image}
Canvas.Brush.Color := clBtnFace;
Canvas.FillRect(TheRect);
{draw the frame control}
DrawFrameControl(Canvas.Handle, TheRect, TheType, TheState);
end;
procedure TForm1.RadioGroup_ButtonTypeClick(Sender: TObject);
begin
{depending on the type of control selected, disable all non appropriate
groups}
case RadioGroup_ButtonType.ItemIndex of
0: begin
RadioGroup1.Enabled := TRUE;
RadioGroup2.Enabled := FALSE;
RadioGroup3.Enabled := FALSE;
RadioGroup4.Enabled := FALSE;
end;
1: begin
RadioGroup1.Enabled := FALSE;
RadioGroup2.Enabled := TRUE;
RadioGroup3.Enabled := FALSE;
RadioGroup4.Enabled := FALSE;
end;
2: begin
RadioGroup1.Enabled := FALSE;
RadioGroup2.Enabled := FALSE;
RadioGroup3.Enabled := TRUE;
RadioGroup4.Enabled := FALSE;
end;
3: begin
RadioGroup1.Enabled := FALSE;
RadioGroup2.Enabled := FALSE;
RadioGroup3.Enabled := FALSE;
RadioGroup4.Enabled := TRUE;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -