像Microsoft Access(VBA)的通知一样非阻塞“吐司”
我要去ASK并回答我认为对MS Access中一些很酷的UI功能感兴趣的人有用的问题.
Answering own question 题:
我的朋友问我关于ms访问的非阻塞吐司通知.我的第一个想法是,检查谷歌你会发现大量的样本.他对他得到的样品不满意.
他想要(JQuery)非阻塞通知.用户需要知道但不一定需要互动的东西. 由于在VBA中无法进行线程化,我想,如果你能编写自己的.dll怎么办?所以我最终编写了一个.NET DLL,可以通过(windows)VBA代码访问并显示Toast通知. 现在,您可以从这里下载我创建的DLL: 编辑:以上下载链接和GitHub链接已更新为我认为属于作者的工作链接. 如果您担心下载未知的DLL:VirusTotal Scan report 将DLL添加到应用程序的根文件夹,并将以下代码添加到您的应用程序. 'Module level public variable Public gTOASTER As Object ' to save window metrics Public Type RECT Left As Long ' x1 Top As Long ' y1 Right As Long ' x2 Bottom As Long ' y2 End Type #If VBA7 Then Public Declare PtrSafe Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As LongPtr Public Declare PtrSafe Function KRISH_VBA_TOOLS Lib "VBA_TOOLS.dll" () As Object Public Declare PtrSafe Function GetWindowRect Lib "user32" (ByVal hWnd As LongPtr,ByRef lpRect As RECT) As LongPtr #Else Public Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal strFilePath As String) As Long Public Declare Function KRISH_VBA_TOOLS Lib "VBA_TOOLS.dll" () As Object Public Declare Function GetWindowRect Lib "user32" (ByVal hWnd As LongPtr,ByRef lpRect As RECT) As LongPtr #End If Public Function FN_TOAST_DLL(iMessage As String,Optional iCLOSE_DURATION As Long = 3000,Optional iType As String = "success",Optional iANIME_DURATION As Long = 1000,Optional iFONT_COLOR As String = "#FFFFFF",Optional iX As Long = 0,Optional iY As Long = 0,Optional iANIME_DIRECTION As Integer = 1,Optional iPARENT_HWND As Long = 0) On Error GoTo LABEL_EXIT_ROUTINE: If gTOASTER Is Nothing Then LoadLibrary (FN_APP_GET_BASE_PATH & "VBA_TOOLS.dll") Set gTOASTER = KRISH_VBA_TOOLS() GoTo LABEL_TOAST Else GoTo LABEL_TOAST End If On Error GoTo 0 Exit Function LABEL_EXIT_ROUTINE: msgbox iMessage & vbnewline & err.description Exit Function LABEL_TOAST: 'set background color. (pass any html color code) Select Case iType Case "error" iType = "#F76160" Case "success" iType = "#26ad82" Case Else iType = "#26ad82" End Select 'if parent object is provided show the toast on top of the parent. if custom x,y is provided use x,y coordinated. if none provided use access app's locaiton. Dim mRect As RECT If iPARENT_HWND <= 0 Then If iX = 0 And iY = 0 Then GetWindowRect Application.hWndAccessApp,mRect iANIME_DIRECTION = 0 'anim direction 0 to down and 1 to up End If Else ' iPARENT_HWND > 0 Then 'parent_hwnd is null GetWindowRect iPARENT_HWND,mRect End If 'set up some offsets iX = mRect.Left + 360 iY = mRect.Top + 1 On Error Resume Next gTOASTER.FN_SHOW_TOAST iMessage,iCLOSE_DURATION,iType,iANIME_DURATION,iFONT_COLOR,iX,iY,iANIME_DIRECTION End Function Public Function FN_APP_GET_BASE_PATH() Dim FN As String FN = Application.CurrentProject.path If VBA.Right(Application.CurrentProject.path,1) <> "" Then FN = FN & "" FN_APP_GET_BASE_PATH = FN End Function 如果要自定义fn_toast_dll函数,则从DLL中获取参数列表: ' /// <summary> ' /// ' /// </summary> ' /// <param name="iMessage">Message to display</param> ' /// <param name="iDuration">Duration in Milliseconds to keep the toast before fading out..</param> ' /// <param name="iBG_COLOR">HTML color code for your toast background...</param> ' /// <param name="iANIME_DURATION">Millisecond value used to for fading in and out the Toast.. 1/4 is used to fade in rest to fade out..</param> ' /// <param name="iFONT_COLOR">HTML Color code for the font..</param> ' /// <param name="iX">x position on the screen. where the toast should appear</param> ' /// <param name="iY">y position on the screen where the toast should appear</param> ' /// <param name="iANIM_DIRECTION">{0,1} 0 will show/add further notifications downwards and 1 upwards.</param> ' /// <returns></returns> 显示通知调用此方法: FN_TOAST_DLL "hello this is a green test" ' By default a success message with 3 seconds will be "toasted" FN_TOAST_DLL "hello this is an error",15000,"error" 用法: 您可以将此用于任何非交互式警报,例如登录成功,操作取消警报或任何用户无需按OK确认您的消息. 目标 这是我的GitHub链接:GitHub 一个样品: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 如何将第三方Windows DLL组织到应用程序文件夹中的子文件夹
- windows-8 – Windows 8中listview(WinJS)中的动态模板
- Windows server 2016 活动目录备份及恢复
- 将Windows 8主题仪表板应用于我在ASP.NET中设计的网站
- 如何从Win32中的func ptr获取Module HANDLE?
- windows-7 – 如何准备更换/升级主板
- windows – QueryPerformanceCounter和线程安全
- 如何在Windows Server上获取本地连接的IP地址?
- Windows应用程序体验服务
- Windows 2012安装mysql 5.7.22 企业版
- windows – 对于使用共享上的单个工作副本的多个
- 创建唯一的文件名Windows批处理
- win10 无法安装/启用 .net framework 3.5
- windows-server-2003 – Windows域控制器是否向通
- windows-server-2003 – 尝试更改为Active Direc
- windows-8 – 无法从主机ping本地VM
- .net – 如何在Windows中登录用户的全名?
- Windows中的PrivCopyFileExW错误?
- active-directory – Microsoft Active Director
- 使用基于Windows的RADIUS(NPS)的SuperMicro IPMI