Access编程交流网
  • 设为首页|收藏本站|繁体中文|手机版
  •     
  • Access培训-Access开发平台-Access行业开发

  • 首页
  • 资讯
  • 技巧
  • 源码
  • 行业
  • 资源
  • 活动
  • 关于

技巧

ACCESS数据库

启动/设置/选项/背景

修复/压缩

安全/加密/解密

快捷键

版本升级/其它等

数据表

命名方式/设计规范

表设计

查询

Sql语言基础

选择查询

更新查询

删除查询

追加查询

生成表查询

交叉表查询

SQL特定查询

查询参数

查询综合应用

界面/窗体/控件

标签

文本框

命令按钮

组合框/列表框

选项组/复选框/选项按钮

选项卡

子窗体

窗体本身/综合应用

其它

报表打印

报表设计

高级报表

模块/函数/VBA/API/系统

VBA基础

内置函数

调试/跟踪/Debug

模块/类模块

API/COM/系统相关

字符数字日期

网络通信游戏

加密解密安全

文件处理

经典算法

宏/菜单/工具栏/功能区

宏/脚本

菜单/工具栏

功能区/Ribbon

图表/图形/图像/多媒体

图表

图形/图像

音频

视频/动画

DAO/链接表/ADO/ADP

DAO/链接表/ODBC

ADO/RDO

ADP

ActiveX/第三方控件/插件

Treeview树控件

ListView列表控件

Toolbar工具栏控件

微软其它控件

Dbi-Tech

CodeJock

Grid++Report

FastReport

ComponentOne

加载项/插件/Addin

OFFICE集成/导入导出/交互

Excel导入导出/交互

Word导入导出/交互

PPT交互

Outlook控制/邮件

Text文本文件/INI/CSV

PDF/SWF/XML格式

CAD格式

Sharepoint/其它Office

SqlServer/其它数据库

表

视图

存储过程/触发器

函数

用户/权限/安全

调试/维护

SqlServer其它/综合

发布/打包/文档/帮助

开发版/运行时

打包/发布/部署

开发文档/帮助制作

Access完整行业系统

采购管理系统

销售管理系统

仓库管理系统

人力资源管理HRM

CRM管理系统

MRP/ERP管理系统

BRP/流程优化

其它管理系统

心得/经验/绝招
其它/杂项
Excel技巧

Excel应用与操作

Excel开发编程

Word技巧

Word应用与操作

Word开发编程

Outlook技巧

Outlook应用与操作

Outlook开发编程

热门文章

  • [技巧分享]多条Shell..
  • 一种比GetTickCou..
  • Access获取网卡物理地..
  • API函数详解(转载自红尘..
  • 隐藏Access主窗口之二
  • API实现的延时函数

最新文章

  • Access API函数分..
  • Access VBA 注册..
  • Access Excel ..
  • 毫秒级和纳秒级计时的API..
  • 一种比GetTickCou..
  • VB用PrevInstan..

联系方式

Access交流网(免费Access交流)

QQ:18449932 

网  址:www.access-cn.com

当前位置:首页 > 技巧 > 模块/函数/VBA/API/系统 > API/COM/系统相关
API/COM/系统相关

Access判断组合框是否处于下拉状态

1)  通过类名来判断是否已经打开

'******* Code Start *********
' This code was originally written by Dev Ashish.
' 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.
'
' Code Courtesy of
' Dev Ashish
'
'  retrieves the name of the class to which the specified window belongs.
Private Declare Function apiGetClassName Lib "user32" _
    Alias "GetClassNameA" _
    (ByVal hwnd As Long, _
    ByVal lpClassname As String, _
    ByVal nMaxCount As Long) _
    As Long

'  retrieves a handle to the specified child window's parent window.
Private Declare Function apiGetParent Lib "user32" _
    Alias "GetParent" _
    (ByVal hwnd As Long) _
    As Long

'  retrieves information about the specified window. The function also
'  retrieves the 32-bit (long) value at the specified offset into the
'  extra window memory of a window.
Private Declare Function apiGetWindowLong Lib "user32" _
    Alias "GetWindowLongA" _
    (ByVal hwnd As Long, _
    ByVal nIndex As Long) _
    As Long

'  retrieves a handle to the top-level window whose class name and
'  window name match the specified strings. This function does not search
'  child windows. This function does not perform a case-sensitive search.
Private Declare Function apiFindWindow Lib "user32" _
    Alias "FindWindowA" _
    (ByVal lpClassname As String, _
    ByVal lpWindowName As String) _
    As Long

'  retrieves a handle to a window that has the specified relationship
'  (Z order or owner) to the specified window
Private Declare Function apiGetWindow Lib "user32" _
    Alias "GetWindow" _
    (ByVal hwnd As Long, _
    ByVal wCmd As Long) _
    As Long

'  The class name for an access combo's drop down listbox window
Private Const ACC_CBX_LISTBOX_CLASS = "OGrid"
'  Class name for the access window
Private Const ACC_MAIN_CLASS = "OMain"
'  Class name for an access combo's drop down listbox's parent window
Private Const ACC_CBX_LISTBOX_PARENT_CLASS = "ODCombo"
'  class name for an access form's client window
Private Const ACC_FORM_CLIENT_CLASS = "OFormSub"
'  class name for Edit controls in access
Private Const ACC_CBX_EDIT_CLASS = "OKttbx"
'  class name for VB combo's drop down listbox's parent window (SDI)
Private Const VB_CBX_LISTBOX_PARENT_CLASS = "#32769" ' // Desktop
'  class name for VB combo's drop down listbox window
Private Const VB_CBX_LISTBOX_CLASS = "ComboLBox"
'  handle identifies the child window at the top of the Z order,
'  if the specified window is a parent window
Private Const GW_CHILD = 5
'  Retrieves the window styles.
Private Const GWL_STYLE = (-16)
'  flag denoting that a window is visible
Private Const WS_VISIBLE = &H10000000

Function fIsComboOpen() As Boolean
'  returns true if a combo box on the form is dropped down
'  only one combo can have the focus => only one drop down
'
Static hwnd As Long
Static hWndCBX_LBX As Long

   hwnd = 0: hWndCBX_LBX = 0

   '  Start with finding the window with "ODCombo" class name
   hwnd = apiFindWindow(ACC_CBX_LISTBOX_PARENT_CLASS, _
                                vbNullString)
   '  Parent window of ODCombo is the access window
   If apiGetParent(hwnd) = hWndaccessApp Then
         '  Child window of ODCombo window is the
         '  drop down listbox associated with a combobox
         hWndCBX_LBX = apiGetWindow(hwnd, GW_CHILD)
         '  another check to confirm that we're looking at the right window
         If fGetClassName(hWndCBX_LBX) = _
                        ACC_CBX_LISTBOX_CLASS Then
            '  Finally, if this window is visible,
            If apiGetWindowLong(hwnd, GWL_STYLE) And WS_VISIBLE Then
               '  the Combo must be open
               fIsComboOpen = True
            End If
         End If
      End If
End Function

Private Function fGetClassName(hwnd As Long)
Dim strBuffer As String
Dim lngLen As Long
Const MAX_LEN = 255
    strBuffer = Space$(MAX_LEN)
    lngLen = apiGetClassName(hwnd, strBuffer, MAX_LEN)
    If lngLen > 0 Then fGetClassName = Left$(strBuffer, lngLen)
End Function
'******* Code End *********

2)  通过坐标来判断是否已经打开

'******* Code Start *********
' This code was originally written 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.
'
' Code Courtesy of
' Stephen Lebans
'
Private Declare Function MapWindowPoints Lib "user32" _
   (ByVal hwndFrom As Long, ByVal hwndTo As Long, _
   lppt As Any, ByVal cPoints As Long) As Long
Private Declare Function WindowFromPoint Lib "user32" _
   (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function ChildWindowFromPoint Lib "user32" _
   (ByVal hwnd As Long, ByVal xPoint As Long, _
   ByVal yPoint As Long) As Long

Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, _
   lpPoint As POINTL) As Long
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, _
   lpPoint As POINTL) As Long

Private Declare Function apiCreateIC Lib "gdi32" Alias "CreateICA" _
   (ByVal lpDriverName As String, ByVal lpDeviceName As String, _
   ByVal lpOutput As String, lpInitData As Any) As Long
Private Declare Function apiDeleteDC Lib "gdi32" Alias "DeleteDC" _
   (ByVal hdc As Long) As Long
Private Declare Function apiGetDeviceCaps Lib "gdi32" _
   Alias "GetDeviceCaps" (ByVal hdc As Long, _
   ByVal nIndex As Long) As Long


Private Const LOGPIXELSX = 88        '  Logical pixels/inch in X
Private Const LOGPIXELSY = 90        '  Logical pixels/inch in Y

Private Type POINTL
        X As Long
        Y As Long
End Type


Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'If user has combo dropped and clicks into
'form we need to check and see if Combo is
'still dropped
'Save duplication of code simply call
'the COmbo's MouseMove Event directly
Call MyCombo_MouseMove(0, 0, 0, 0)
End Sub

Private Sub MyCombo_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Ok if we're here let's see if the Combo is dropped Down

'temp handle for ListBox hWnd
Dim ComboListhWnd As Long

'Let's calculate TwipsPerPixel
'Get Screen resolution
    Dim mypoint As POINTL
    Dim lngIC As Long
    Dim lngXdpi As Long
    Dim lngYdpi As Long
    Dim TwipsPerPixelX As Long
    Dim TwipsPerPixelY As Long
    Dim lngret As Long
    lngIC = apiCreateIC("DISPLAY", vbNullString, vbNullString, vbNullString)
    'If the call to CreateIC didn't fail, then get the Screen X resolution.
    If lngIC <> 0 Then
        lngXdpi = apiGetDeviceCaps(lngIC, LOGPIXELSX)
        lngYdpi = apiGetDeviceCaps(lngIC, LOGPIXELSY)
               
        'Release the information context.
        apiDeleteDC (lngIC)
    Else
        ' Something has gone wrong. Assume an average value.
        lngret = MsgBox("Error..invalid Display Device Context..Exiting", vbOKOnly)
        Exit Sub
    End If
    
    TwipsPerPixelX = 1440 \ lngXdpi
    TwipsPerPixelY = 1440 \ lngYdpi
    
    'adjust to the expected values
    'OK lets assume the Combo DropBox is at least 2 rows in height
    
    mypoint.X = ((Me.MyCombo.Left + Me.MyCombo.Width) \ 2) \ TwipsPerPixelX
    mypoint.Y = (Me.MyCombo.Top + (Me.MyCombo.Height * 2)) \ TwipsPerPixelY

    Call ClientToScreen(Me.hwnd, mypoint)
    ComboListhWnd = WindowFromPoint(mypoint.X, mypoint.Y)

    If ComboListhWnd = Me.hwnd Then
    Me.txtAPICombo = "The Combo has NOT Dropped"
    Else:
    Me.txtAPICombo = "The Combo has Dropped"
    End If

End Sub
'******* Code End *********
发布人:Dev Ashi…-TheAccessWeb  
分享到:
点击次数:  更新时间:2004-11-28 22:26:31  【打印此页】  【关闭】
上一条:Access丢失的菜单怎样找回来?  下一条:Access读取随机记录的例子



相关文章

  • • Access API函数分享
  • • Access VBA 注册表操作源码
  • • Access Excel VBA程序同时兼容32位和64位的解决办法
  • • 毫秒级和纳秒级计时的API--timeGetTime、GetTickCount、QueryPerformanceCounter
  • • 一种比GetTickCount 和Timer更精确的计时器
  • • VB用PrevInstance和DDE实现禁止多个实例同时打开并传递命令
  • • 获取版本号及判断是否运行版本
  • • API获取网卡地址

热门文章

  • [2003-12-20] 如何让你的程序在任务列表隐藏access数据库
  • [2004-11-26] Access设置数字/大写指示灯的API函数access数据库
  • [2004-11-23] Windows API 函数 for Visual Basic(资料)access数据库
  • [2004-01-04] 弹出选择目录对话框access数据库
  • [2004-11-23] 标准文件对话框access数据库
  • [2003-12-20] 在Access中获取本机ID地址、电脑名及登录用户名access数据库

热门产品

公司动态|在线留言|在线反馈|友情链接|会员中心|站内搜索|网站地图

中山市天鸣科技发展有限公司 版权所有 1999-2023 粤ICP备10043721号

QQ:18449932

Access应用 Access培训 Access开发 Access平台

access|数据库|access下载|access教程|access视频|access软件

Powered by MetInfo 5.3.12 ©2008-2025  www.metinfo.cn