[access查询]利用API函数实现特殊窗体的两种方法
时 间:2007-12-19 14:43:27
作 者:放飞梦想 ID:60 城市:南京
摘 要:利用API函数实现特殊窗体的两种方法
正 文:
---- [方法一]使用区域创建函数
---- 常用的区域创建函数有:
---- CreateEllipticRgn '创建一个椭圆或圆形区域
---- CreateRoundRectRgn '创建一个圆角矩形区域
---- CreatePolygonRgn '创建一个由一系列点围成的区域
---- CombineRgn '将两个区域组合为一个新区域
---- SetWindowRgn '设置新的窗口区域。
---- 通过CombineRgn可以取两个区域的并集、交集等组合,从而创建出复杂形状的窗体。
---- 例程1得到的窗体是两个相连的月牙形:
---- '例程1
Option Explicit
'API声明
Private Declare Function CreateEllipticRgn Lib "gdi32" _
(ByVal x1 As Long, ByVal Y1 As Long, _
ByVal x2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CombineRgn Lib "gdi32" _
(ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, _
ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" _
(ByVal hWnd As Long, ByVal hRgn As Long, _
ByVal bRedraw As Boolean) As Long
'常数声明
Const RGN_XOR = 3
Private Sub Form_Load()
Dim x1, x2
x1 = CreateEllipticRgn(100, 100, 400, 400)
x2 = CreateEllipticRgn(200, 100, 500, 400)
CombineRgn x1, x1, x2, RGN_XOR
SetWindowRgn hWnd, x1, 1
End Sub
---- [方法二]使用BeginPath、EndPath、TextOut、PathToRegion等函数
---- BeginPath函数调用启动一个路径分支,在这个命令后执行的GDI绘图命令会自动成为路径的一部分,Windows95中合法的路径函数有文本绘图函数TextOut、绘制多边形函数Polygon等。
---- EndPath函数用于结束定义一个路径,如果调用成功,BeginPath函数和它之间发生的所有绘图操作都将在指定设备场景的路径中生效。BeginPath函数一般与EndPath函数成对出现。
---- PathToRegion函数调用将当前选定的路径转换到指定区域中。
---- TextOut函数的声明如下:
Declare Function TextOut Lib "gdi32" Alias
"TextOutA" (ByVal hdc As Long, ByVal x As
Long, ByVal y As Long, ByVal lpString As
String, ByVal nCount As Long) As Long
---- 参数说明如下:
---- hdc :设备场景的句柄 ;
---- x,y :绘图的起点,采用逻辑坐标 ;
---- lpString:欲绘制的字串 ;
---- nCount:字串中要绘制的字符数量,一个汉字的字符数量为2 。
---- 例程2生成一个宋体的“国”字形的窗体:
---- '例程2
Option Explicit
'类型声明
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
'API声明
Private Declare Function BeginPath Lib "gdi32" _
(ByVal hdc As Long) As Long
Private Declare Function TextOut Lib "gdi32" _
Alias "TextOutA" (ByVal hdc As Long, _
ByVal X As Long, ByVal Y As Long, _
ByVal lpString As String, _
ByVal nCount As Long) As Long
Private Declare Function EndPath Lib "gdi32" _
(ByVal hdc As Long) As Long
Private Declare Function PathToRegion Lib "gdi32" _
(ByVal hdc As Long) As Long
Private Declare Function GetRgnBox Lib "gdi32" _
(ByVal hRgn As Long, lpRect As RECT) As Long
Private Declare Function CreateRectRgnIndirect Lib "gdi32" _
(lpRect As RECT) As Long
Private Declare Function CombineRgn Lib "gdi32" _
(ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, _
ByVal hSrcRgn2 As Long, _
ByVal nCombineMode As Long) As Long
Private Const RGN_AND = 1
Private Declare Function DeleteObject Lib "gdi32" _
(ByVal hObject As Long) As Long
Privat
Access软件网官方交流QQ群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- Access对子窗体数据进行批...(10.30)
- 最精简的组合框行来源数据快速输...(10.25)
- Access仿平台的多值选择器...(10.24)
- 【Access日期区间段查询】...(10.22)
- 【Access源码示例】VBA...(10.12)
- Access累乘示例,Acce...(10.09)
- 数值8.88,把整数8去掉,转...(10.08)
- 【Access自定义函数】一个...(09.30)
- 【Access选项卡示例】Ac...(09.09)
学习心得
最新文章
- Access快速开发平台--后台D...(11.14)
- 微软Access邀测新Monaco...(11.12)
- Access列表框左右互选、列表框...(11.11)
- 高效率在导入数据前删除记录(11.10)
- Access报价单转订单示例代码(11.08)
- Access系统自带的日期选择器不...(11.08)
- 分享一下Access工程中的acw...(11.07)
- Access快速开发平台--让有权...(11.04)
- Access快速开发平台--审批选...(11.01)
- ACCESS两张表先各自排序,然后...(10.31)