随笔 - 2146  文章 - 97 评论 - 11767 trackbacks - 253

//声明:
DrawFrameControl(
  DC: HDC;            {设备环境句柄}
  const Rect: TRect;  {矩形}
  uType, uState: UINT {控件类型与控件状态}
): BOOL;


//控件类型 uType 参数可选值:
DFC_CAPTION   = 1; {标题按钮}
DFC_MENU      = 2; {菜单}
DFC_SCROLL    = 3; {滚动条按钮}
DFC_BUTTON    = 4; {标准按钮}
DFC_POPUPMENU = 5; {弹出菜单}


//控件状态  uState 参数可选值:

{针对 DFC_CAPTION}
DFCS_CAPTIONCLOSE   = 0;
DFCS_CAPTIONMIN     = 1;
DFCS_CAPTIONMAX     = 2;
DFCS_CAPTIONRESTORE = 3;
DFCS_CAPTIONHELP    = 4;

{针对 DFC_MENU}
DFCS_MENUARROW      = 0;
DFCS_MENUCHECK      = 1;
DFCS_MENUBULLET     = 2;
DFCS_MENUARROWRIGHT = 4;

{针对 DFC_SCROLL}
DFCS_SCROLLUP            = 0;
DFCS_SCROLLDOWN          = 1;
DFCS_SCROLLLEFT          = 2;
DFCS_SCROLLRIGHT         = 3;
DFCS_SCROLLCOMBOBOX      = 5;
DFCS_SCROLLSIZEGRIP      = 8;
DFCS_SCROLLSIZEGRIPRIGHT = $10;

{针对 DFC_BUTTON}
DFCS_BUTTONCHECK      = 0;
DFCS_BUTTONRADIOIMAGE = 1;
DFCS_BUTTONRADIOMASK  = 2;
DFCS_BUTTONRADIO      = 4;
DFCS_BUTTON3STATE     = 8;
DFCS_BUTTONPUSH       = $10;

{通用状态}
DFCS_INACTIVE    = $100;
DFCS_PUSHED      = $200;
DFCS_CHECKED     = $400;
DFCS_TRANSPARENT = $800;
DFCS_HOT         = $1000;
DFCS_ADJUSTRECT  = $2000;
DFCS_FLAT        = $4000;
DFCS_MONO        = $8000;

//举例: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TForm1 = class(TForm) RadioGroup1: TRadioGroup; RadioGroup2: TRadioGroup; RadioGroup3: TRadioGroup; RadioGroup4: TRadioGroup; RadioGroup5: TRadioGroup; RadioGroup6: TRadioGroup; Panel1: TPanel; procedure RadioGroup1Click(Sender: TObject); procedure RadioGroup2Click(Sender: TObject); procedure RadioGroup3Click(Sender: TObject); procedure RadioGroup4Click(Sender: TObject); procedure RadioGroup5Click(Sender: TObject); procedure RadioGroup6Click(Sender: TObject); procedure Draw; end; var Form1: TForm1; implementation {$R *.dfm} var DFC : Integer = 0; DFCS1: Integer = 0; DFCS2: Integer = 0; procedure TForm1.Draw; begin Panel1.Refresh; DrawFrameControl(GetDC(Panel1.Handle), Rect(10,10,100,50), DFC, DFCS1 or DFCS2); end; procedure TForm1.RadioGroup1Click(Sender: TObject); begin Panel1.Refresh; case RadioGroup1.ItemIndex of 0: begin DFC := DFC_CAPTION; RadioGroup3.Enabled := True; RadioGroup4.Enabled := False; RadioGroup5.Enabled := False; RadioGroup6.Enabled := False; end; 1: begin DFC := DFC_MENU; RadioGroup3.Enabled := False; RadioGroup4.Enabled := True; RadioGroup5.Enabled := False; RadioGroup6.Enabled := False; end; 2: begin DFC := DFC_SCROLL; RadioGroup3.Enabled := False; RadioGroup4.Enabled := False; RadioGroup5.Enabled := True; RadioGroup6.Enabled := False; end; 3: begin DFC := DFC_BUTTON; RadioGroup3.Enabled := False; RadioGroup4.Enabled := False; RadioGroup5.Enabled := False; RadioGroup6.Enabled := True; end; 4: begin DFC := DFC_POPUPMENU; RadioGroup3.Enabled := False; RadioGroup4.Enabled := True; RadioGroup5.Enabled := False; RadioGroup6.Enabled := False; end; end; end; procedure TForm1.RadioGroup2Click(Sender: TObject); begin case RadioGroup2.ItemIndex of 0: DFCS1 := DFCS_INACTIVE; 1: DFCS1 := DFCS_PUSHED; 2: DFCS1 := DFCS_CHECKED; 3: DFCS1 := DFCS_TRANSPARENT; 4: DFCS1 := DFCS_HOT; 5: DFCS1 := DFCS_ADJUSTRECT; 6: DFCS1 := DFCS_FLAT; 7: DFCS1 := DFCS_MONO; end; Draw; end; procedure TForm1.RadioGroup3Click(Sender: TObject); begin case RadioGroup3.ItemIndex of 0: DFCS2 := DFCS_CAPTIONCLOSE; 1: DFCS2 := DFCS_CAPTIONMIN; 2: DFCS2 := DFCS_CAPTIONMAX; 3: DFCS2 := DFCS_CAPTIONRESTORE; 4: DFCS2 := DFCS_CAPTIONHELP; end; Draw; end; procedure TForm1.RadioGroup4Click(Sender: TObject); begin case RadioGroup4.ItemIndex of 0: DFCS2 := DFCS_MENUARROW; 1: DFCS2 := DFCS_MENUCHECK; 2: DFCS2 := DFCS_MENUBULLET; 3: DFCS2 := DFCS_MENUARROWRIGHT; end; Draw; end; procedure TForm1.RadioGroup5Click(Sender: TObject); begin case RadioGroup5.ItemIndex of 0: DFCS2 := DFCS_SCROLLUP; 1: DFCS2 := DFCS_SCROLLDOWN; 2: DFCS2 := DFCS_SCROLLLEFT; 3: DFCS2 := DFCS_SCROLLRIGHT; 4: DFCS2 := DFCS_SCROLLCOMBOBOX; 5: DFCS2 := DFCS_SCROLLSIZEGRIP; 6: DFCS2 := DFCS_SCROLLSIZEGRIPRIGHT; end; Draw; end; procedure TForm1.RadioGroup6Click(Sender: TObject); begin case RadioGroup6.ItemIndex of 0: DFCS2 := DFCS_BUTTONCHECK; 1: DFCS2 := DFCS_BUTTONRADIOIMAGE; 2: DFCS2 := DFCS_BUTTONRADIOMASK; 3: DFCS2 := DFCS_BUTTONRADIO; 4: DFCS2 := DFCS_BUTTON3STATE; 5: DFCS2 := DFCS_BUTTONPUSH; end; Draw; end; end.
//效果图:

附上窗体结构代码: object Form1: TForm1 Left = 0 Top = 0 Caption = 'Form1' ClientHeight = 386 ClientWidth = 499 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Tahoma' Font.Style = [] OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 object RadioGroup1: TRadioGroup Left = 0 Top = 8 Width = 137 Height = 129 Caption = 'RadioGroup1' Items.Strings = ( 'DFC_CAPTION ' 'DFC_MENU ' 'DFC_SCROLL ' 'DFC_BUTTON ' 'DFC_POPUPMENU ') TabOrder = 0 OnClick = RadioGroup1Click end object RadioGroup2: TRadioGroup Left = 0 Top = 143 Width = 137 Height = 170 Caption = 'RadioGroup2' Items.Strings = ( 'DFCS_INACTIVE' 'DFCS_PUSHED' 'DFCS_CHECKED' 'DFCS_TRANSPARENT' 'DFCS_HOT' 'DFCS_ADJUSTRECT' 'DFCS_FLAT' 'DFCS_MONO') TabOrder = 1 OnClick = RadioGroup2Click end object RadioGroup3: TRadioGroup Left = 143 Top = 8 Width = 178 Height = 129 Caption = 'RadioGroup3' Items.Strings = ( 'DFCS_CAPTIONCLOSE ' 'DFCS_CAPTIONMIN' 'DFCS_CAPTIONMAX' 'DFCS_CAPTIONRESTORE' 'DFCS_CAPTIONHELP') TabOrder = 2 OnClick = RadioGroup3Click end object RadioGroup4: TRadioGroup Left = 327 Top = 8 Width = 170 Height = 129 Caption = 'RadioGroup4' Items.Strings = ( 'DFCS_MENUARROW' 'DFCS_MENUCHECK' 'DFCS_MENUBULLET' 'DFCS_MENUARROWRIGHT') TabOrder = 3 OnClick = RadioGroup4Click end object RadioGroup5: TRadioGroup Left = 143 Top = 143 Width = 178 Height = 170 Caption = 'RadioGroup5' Items.Strings = ( 'DFCS_SCROLLUP' 'DFCS_SCROLLDOWN' 'DFCS_SCROLLLEFT' 'DFCS_SCROLLRIGHT' 'DFCS_SCROLLCOMBOBOX' 'DFCS_SCROLLSIZEGRIP' 'DFCS_SCROLLSIZEGRIPRIGHT') TabOrder = 4 OnClick = RadioGroup5Click end object RadioGroup6: TRadioGroup Left = 327 Top = 143 Width = 170 Height = 170 Caption = 'RadioGroup6' Items.Strings = ( 'DFCS_BUTTONCHECK' 'DFCS_BUTTONRADIOIMAGE' 'DFCS_BUTTONRADIOMASK' 'DFCS_BUTTONRADIO' 'DFCS_BUTTON3STATE' 'DFCS_BUTTONPUSH') TabOrder = 5 OnClick = RadioGroup6Click end object Panel1: TPanel Left = 0 Top = 319 Width = 499 Height = 67 Align = alBottom Caption = 'Panel1' TabOrder = 6 end end
posted on 2008-02-10 22:01  万一  阅读(...)  评论(...编辑  收藏