Use system tray & icons in VBA (Access)

ぐ巨炮叔叔 提交于 2019-12-24 07:18:44

问题


I've found a few tutorials that explain how to use the windows API to get a custom icon in the system tray.

These are all for Visual Basic, and they don't seem to be scaling to VBA well.

I'm following this short tutorial: http://atchoo.org/vb/systray.php

Basically, you have to set the hIcon value (a 'long' variable) but it does not work. I've tried to use the LoadPicture() function, which does not give me any errors, but also fails to add a new icon.

I can't supply Me.Icon, nor can I set it on Form_Load.

Does anyone have any experience with this?


回答1:


Using loadpicture was the right approach, but not directly. I had to define a new variable first, and load that.

Like this:

Dim myPicture As IPictureDisp
strPath = "F:\Databank\Icons\stone.ico"
Set myPicture = LoadPicture(strPath)

And then, somewhere along the way, I could set hIcon without problems:

.hIcon = myPicture

When I change the trayicon (like, say, adding a balloontip) I have to supply the icon information again, too.



来源:https://stackoverflow.com/questions/2402242/use-system-tray-icons-in-vba-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!