如何设置窗体左上角的图标?
时 间:2007-10-21 09:30:16
作 者:cuxun ID:70 城市:闵行
摘 要:如何设置窗体左上角的图标?
正 文:
如何设置窗体左上角的图标?
方法很多,这里介绍3种:
方法一:
在菜单中设置, 工具 -> 启动 -> 应用程序图标
如果在“用作窗体和报表的图标”前面打勾,那么你的这个access数据库中所有的窗体和报表的图标都会一致
方法二:
用api,代码如下:
There are no direct way to place a custom icon in a form's caption bar. However, by loading an ICO file into memory, we can assign the icon to a form by sending a WM_SETICON message to the window.
'*********** Code Start ********
'Code courtesy of
'Klaus H. Probst
'
'// Place all this in a module
Public Declare Function LoadImage Lib "user32" _
Alias "LoadImageA" _
(ByVal hInst As Long, _
ByVal lpsz As String, _
ByVal un1 As Long, _
ByVal n1 As Long, _
ByVal n2 As Long, _
ByVal un2 As Long) _
As Long
Public Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
LParam As Any) _
As Long
Public Const WM_GETICON = &H7F
Public Const WM_SETICON = &H80
Public Const ICON_SMALL = 0
Public Const ICON_BIG = 1
'// LoadImage() image types
Public Const IMAGE_BITMAP = 0
Public Const IMAGE_ICON = 1
Public Const IMAGE_CURSOR = 2
Public Const IMAGE_ENHMETAFILE = 3
'// LoadImage() flags
Public Const LR_DEFAULTCOLOR = &H0
Public Const LR_MONOCHROME = &H1
Public Const LR_COLOR = &H2
Public Const LR_COPYRETURNORG = &H4
Public Const LR_COPYDeleteORG = &H8
Public Const LR_LOADFROMFILE = &H10
Public Const LR_LOADTRANSPARENT = &H20
Public Const LR_DEFAULTSIZE = &H40
Public Const LR_LOADMAP3DCOLORS = &H1000
Public Const LR_CreateDIBHeader = &H2000
Public Const LR_COPYFROMRESOURCE = &H4000
Public Const LR_SHARED = &H8000
Public Function SetFormIcon(hWnd As Long, IconPath As String) As Boolean
Dim hIcon As Long
hIcon = LoadImage(0&, IconPath, IMAGE_ICON, 16, 16, LR_LOADFROMFILE)
'// wParam = 0; Setting small icon. wParam = 1; setting large icon
If hIcon <> 0 Then
Call SendMessage(hWnd, WM_SETICON, 0, ByVal hIcon)
SetFormIcon = True
End If
End Function
'*********** Code Start ********
'翻译成中文如下:
没有一个直接的办法为窗体设置自己的图标,然而, 通过加载图标文件到内存,
然后通过发送WM_SETICON 消息到这个窗体来指定这个窗体的图标
'*********** 代码开始 ********
'Code courtesy of
'Klaus H. Probst
'
'// 引用API 函数loadimage及 sendmessage
Public Declare Function LoadImage Lib "user32" _
Alias "LoadImageA" _
(ByVal hInst As Long, _
ByVal lpsz As String, _
ByVal un1 As Long, _
ByVal n1 As Long, _
ByVal n2 As Long, _
ByVal un2 As Long) _
As Long
Public Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
LParam As Any) _
As Long
Public Const WM_GETICON = &H7F
Public Const WM_SETICON = &H80
Public Const ICON_SMALL = 0
Public Const ICON_BIG = 1
'// LoadImage() image types
'指定了欲载入的图象类型:IMAGE_BITMAP, IMAGE_CURSOR, IMAGE_ICON
Public Const IMAGE_BITMAP = 0
Public Const IMAGE_ICON = 1
Public Const IMAGE_CURSOR = 2
Public Const IMAGE_ENHMETAFILE = 3
'// LoadImage() 参数
'LR_DEFAULTCOLOR 以常规方式载入图象
'LR_LOADREALSIZE 不对图象进行缩放处理。忽略n1和n2的设置
'LR_CreateDIBSECTION 如果指定了IMAGE_BITMAP,就返回DIBSection的句柄,而不是位图
的句柄
'LR_DEFAULTSIZE 如果n1和n2为零,就使用由系统定义的图象默认大小,而不是图象本身
定义的大小
'LR_LOADFROMFILE 如hInst为零,lpsz就代表要载入适当类型的一个文件的名字,仅适用
于Win95
'LR_LOADMAP3DCOLORS 将图象中的深灰、灰、以及浅灰像素都替换成COLOR_3DSHADOW,
COLOR_3DFACE以及COLOR_3DLIGHT的当前设置
'LR_LOADTRANSPARENT 与
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邀测新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)
- Access对子窗体数据进行批量+...(10.30)