文档章节

WinAPI: DrawFrameControl - 绘制控件

涂孟超
 涂孟超
发布于 2014/09/26 15:33
字数 719
阅读 10
收藏 0
//声明:
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

本文转载自:http://www.cnblogs.com/del/archive/2008/02/10/1066732.html

涂孟超
粉丝 12
博文 2011
码字总数 14107
作品 0
深圳
程序员
私信 提问
Go语言开发Windows应用

当第一次看到Go程序在windows平台生成可执行的exe文件,就宣告了windows应用也一定是Go语言的战场。Go不是脚本语言,但却有着脚本语言的轻便简单的特性。相较于php和python之类以服务器控制台...

Robin3D
2013/04/24
0
4
win32程序怎么使编辑框输入的文字自己转换为*号

如题 想用WINAPI做一个简单的用户登陆界面,密码输入我是直接用编辑框实现的 但是我不知道用什么函数可以直接让输入的文字直接变成*号或不可见的文字 求教各位 该怎么实现这个功能,或者说密...

西行寺幽幽子
2013/06/12
445
4
问个winapi的

哪里能找到winapi的帮助文档。不要mfc啥的,就是直接include window.h就写的。下了msdn vs2008版,发现里面控件基本都是mfc还是什么的?其实我就想找一个,各种createwindow出来winclass的示例...

ericsoul
2013/06/07
38
0
mfc里面关于创建窗口控件的问题

遇到的问题是使用在WM_CREATE消息中使用CreateWindow()创建控件,可是运行后并没有显示出来,不知道问题所在,求解!!!下面是代码: #include #include #include long WINAPI WndProc(HWN...

CodeZero
2013/05/19
347
2
2.5D/2D 游戏框架--Games Frame with Lua

Games Frame with Lua 是 2.5D/2D 游戏框架,C++ 驱动,Lua 编写。 对windows开发熟悉的同学肯定都知道MFC库对winAPI完善的封装,使得窗口编程中许多重复的事情不必再亲自去处理,根据共性和...

大夏天
2015/12/21
392
0

没有更多内容

加载失败,请刷新页面

加载更多

vmstat命令详解

https://www.cnblogs.com/ggjucheng/archive/2012/01/05/2312625.html

流光韶逝
20分钟前
0
0
如何理解算法时间复杂度的表示

先从O(1) 来说,理论上哈希表就是O(1)。因为哈希表是通过哈希函数来映射的,所以拿到一个关键 字,用哈希函数转换一下,就可以直接从表中取出对应的值。和现存数据有多少毫无关系,故而每次执...

yky20190625
36分钟前
2
0
分布式架构 实现分布式锁的常见方式

一、我们为什么需要分布式锁? 在单机时代,虽然不需要分布式锁,但也面临过类似的问题,只不过在单机的情况下,如果有多个线程要同时访问某个共享资源的时候,我们可以采用线程间加锁的机制...

太猪-YJ
今天
7
0
GitLab Docker 安装记录

安装环境 环境Centos7.4 64 1.拉取镜像文件 docker pull gitlab/gitlab-ce:latest 2.docker 安装 git.zddts.com 为访问域名或换成可以访问的IP docker run -d --hostname git.***.com -p ......

侠者圣
今天
0
0
EfficientNet: 再论 CNN 的网络规模

由于这里公式无法正常显示,所有内容以图片内容上传,如有需要,可提供 pdf 版。

爱吃草莓的皮卡丘
今天
0
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部