设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 2815|回复: 6
打印 上一主题 下一主题

如何用API调用颜色选择对话框?[求助]

[复制链接]
跳转到指定楼层
1#
发表于 2002-11-25 06:54:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
如何用API调用颜色选择对话框?
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅

点击这里给我发消息

2#
发表于 2002-11-25 20:35:00 | 只看该作者
在ACCESS2000的开发版里带的示例文件里有。
3#
发表于 2002-11-25 21:39:00 | 只看该作者
奥?能否贴上来?
4#
 楼主| 发表于 2002-11-26 01:24:00 | 只看该作者
郑板主也不放上来,只好自己到MVPS网站照了一个:
If you want this function to simply return the value of the Color the user selected from the Dialog, then  just change the function declaration in modColorPicker to something like:

Public Function DialogColor(ctl As Control) As Long
' Remember to add the line of code at the
' end of the Function
' DialogColor = CS.rgbResult

Then call it from your Form with code like:

'***Code Start ***
Private Sub CmdChooseBackColor_Click()
    ' Pass the TextBox Control to the function
    Me.textCtl.BackColor = DialogColor(Me.textCtl)
End Sub
'***Code End ***
' ******** Code Start ********
'This code was originally written by Terry Kreft,
'and modified by Stephen Lebans
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
' Contact Stephen@lebans.com
'
Private Type COLORSTRUC
  lStructSize As Long
  hwnd As Long
  hInstance As Long
  rgbResult As Long
  lpCustColors As String
  Flags As Long
  lCustData As Long
  lpfnHook As Long
  lpTemplateName As String
End Type

Private Const CC_SOLIDCOLOR = &H80

Private Declare Function ChooseColor _
    Lib "comdlg32.dll" Alias "ChooseColorA" _
    (pChoosecolor As COLORSTRUC) As Long

Public Function aDialogColor(prop As Property) As Boolean
  Dim x As Long, CS As COLORSTRUC, CustColor(16) As Long

  CS.lStructSize = Len(CS)
  CS.hwnd = hWndAccessApp
  CS.Flags = CC_SOLIDCOLOR
  CS.lpCustColors = String$(16 * 4, 0)
  x = ChooseColor(CS)
  If x = 0 Then
    ' ERROR - use Default White
    prop = RGB(255, 255, 255) ' White
    aDialogColor = False
    Exit Function
  Else
    ' Normal processing
     prop = CS.rgbResult
  End If
  aDialogColor = True
End Function
' ********* Code End ***********

点击这里给我发消息

5#
发表于 2002-11-26 01:28:00 | 只看该作者

回复

呵呵,中午不方便传,刚要传,你已找到,其实这个已经有人传过了,我暂时找不到地址。
文件下载
6#
 楼主| 发表于 2002-11-26 01:40:00 | 只看该作者
谢谢,你这个我也下了,应该是个好例子,不过挺大的(500K),呵呵.

点击这里给我发消息

7#
发表于 2002-11-26 01:48:00 | 只看该作者
2000开发版里的很全面的例子,如果有时间全都能了解,会发现有很多东西有用,一二年前我就有了(公司里买了一套开发版),真正看起来才近一年的事,不过才看了一点点。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2025-1-6 06:30 , Processed in 0.275535 second(s), 30 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表