选择显示字体大小

自制控件方面的有关知识

1. 在程序中注册和注销 ocx 控件 98-7-20
声明(在本例子里使用的是 comctl32.ocx,如果是其他,使用相应的名称):
declare function regcomctl32 lib "comctl32.ocx" _
alias "dllregisterserver" () as long
declare function unregcomctl32 lib "comctl32.ocx" _
alias "dllunregisterserver" () as long
const error_success = &h0

使用:

if regcomctl32 = error_success then
msgbox "registration successful"
else
msgbox "registration unsuccessful"
end if

if unregcomctl32 = error_success then
msgbox "unregistration successful"
else
msgbox "unregistration unsuccessful"
end if

2.建立可下拉选择的属性
例如在 borderstyle 中有以下的四个选择:
0 - none
1 - dashed
2 - single line
3 - double line
4 - 3d
首先在控件中定义以下的集合:
enum bordertype
none
dashed
[single line]
[double line]
[3d]
end enum
然后就可以把属性的类型设置好:
public property get borderstyle() as bordertype
border = m_borderstyle
end property

public property let borderstyle(byval new_borderstyle as bordertype)
m_borderstyle = new_borderstyle
propertychanged "borderstyle"
end property

3.缺省值和可选参数
vb5 加强了函数参数方面,可用以下的代码实现参数缺省:

property get value(optional index as long = 1)
...
end property
也可使用另一个方法(慢):

property get value(optional index as long)
if ismissing(index) then index = 1
...
end property

4.多个参数的属性
在自制的控件中,可能需要对某个属性传递多个值:

property let test (arg1 as string, arg2 as string, arg3 as integer)
end property

用以下的方法传递参数:
test(arg1,arg2) = arg3

5.使用数组做属性
定义一个 variant 类型的属性,即可用它来做数组。
下面定义了一个 carray 类。

private m_myarray as variant

public property get myarray() as variant
myarray = m_myarray
end property

public property let myarray as variant)
m_myarray = a
end property

可用以下的方法使用:

private m_array as carray
private marr(3) as string

private sub form_load()
set m_array = new carray
marr(1) = "one"
marr(2) = "two"
marr(3) = "three"
m_array.myarray = marr()
或者
m_array.myarray = array("one", "two", "three")
end sub

private sub form_unload(cancel as integer)
dim i as integer
for i = 1 to ubound(m_array.myarray)
msgbox m_array.myarray(i)
next
end sub


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons