Use system tray & icons in VBA (Access)

2019-07-28 04:47发布

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条回答
We Are One
2楼-- · 2019-07-28 05:08

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.

查看更多
登录 后发表回答