x
This website is using cookies. We use cookies to ensure that we give you the best experience on our website. More info. That's Fine
HPC:Factor Logo 
 
Latest Forum Activity

Display a taskbar icon for your eVB applications

WinCEDev Page Icon Posted 2023-02-10 10:47 PM
#
Avatar image of WinCEDev
Factorite (Senior)

Posts:
76
Location:
Europe
Status:
Hello again! So this is mostly something for fellow eVB programmers to play with. This is a module and accompanying example project that enables your eVB program to have an icon in the CE taskbar.

Usage is very simple, just add the module and an ImageList to your project and add the image(s) to the ImageList as per normal. Add a form-level variable to hold the icon(s), and then call the TaskbarIcon_Let function from Form_Load or anytime you want to change the icon. When your application ends, make sure to call TaskbarIcon_Destroy specifying the variables you created to hold the icons to allow Windows to free them from memory.

A complete application could look like this:

Option Explicit Private LargeIcon As Long Private SmallIcon As Long Private Sub Form_Load() ImageList.Add "icon_small.bmp" ImageList.Add "icon_large.bmp" SmallIcon = TaskbarIcon_Let(hwnd, ImageList.hImageList, 0, tbSmallIcon) LargeIcon = TaskbarIcon_Let(hwnd, ImageList.hImageList, 1, tbLargeIcon) End Sub Private Sub Form_Unload(Cancel As Integer) TaskbarIcon_Destroy LargeIcon TaskbarIcon_Destroy SmallIcon End Sub



Currently this is bound to the same limitations as other icons represented by the eVB ImageList, most notably, transparency is not allowed. I am however working on a lightweight ImageList replacement to hopefully solve these issues.

I have attached a screenshot of the example application with the icon visible in the taskbar.

Links:

GitHub Repo

Edited by WinCEDev 2023-02-10 10:57 PM




(CAPT0000.png)



Attachments
----------------
Attachments CAPT0000.png (2KB - 1 downloads)
 Top of the page
I dunk for bananas Page Icon Posted 2023-02-10 11:49 PM
#
Avatar image of I dunk for bananas
H/PC Elite

Posts:
702
Location:
Europe
Status:
That's awesome! Do you know if something like that is possible for the tray too?
 Top of the page
WinCEDev Page Icon Posted 2023-02-11 12:29 AM
#
Avatar image of WinCEDev
Factorite (Senior)

Posts:
76
Location:
Europe
Status:
Yes I think that is possible as well, Shell_NotifyIcon is a bit unusual in that it lets us specify which message it should send to our window to indicate the user clicked on your app's system tray icon. This is actually perfect for eVB since there's no built-in way to subclass the form and process messages ourselves, so instead we could handle the events from MouseMove. This is the same way it's usually done for classic VB on the desktop, too. The code for getting the icon handle from the ImageList would be the same so it could be reused as-is.

I'll check it out and post a sample project if I can get it to work.

(I used Bitly for the link because the forum seems to accidentally modify the original in a way where it no longer works.)

Edited by WinCEDev 2023-02-11 12:57 AM
 Top of the page
Citgo Page Icon Posted 2023-02-11 8:16 AM
#
Avatar image of Citgo
Factorite (Elite)

Posts:
178
Location:
Germany 
Status:
Fantastic!
Thank you for that!
 Top of the page
I dunk for bananas Page Icon Posted 2023-02-11 11:20 AM
#
Avatar image of I dunk for bananas
H/PC Elite

Posts:
702
Location:
Europe
Status:
Quote
WinCEDev - 2023-02-11 12:29 AM

Yes I think that is possible as well, Shell_NotifyIcon is a bit unusual in that it lets us specify which message it should send to our window to indicate the user clicked on your app's system tray icon. This is actually perfect for eVB since there's no built-in way to subclass the form and process messages ourselves, so instead we could handle the events from MouseMove. This is the same way it's usually done for classic VB on the desktop, too. The code for getting the icon handle from the ImageList would be the same so it could be reused as-is.

I'll check it out and post a sample project if I can get it to work.

(I used Bitly for the link because the forum seems to accidentally modify the original in a way where it no longer works.)


I'm trying to make an application that sits in the tray forever, and when clicked opens a certain executable
 Top of the page
WinCEDev Page Icon Posted 2023-02-12 1:41 AM
#
Avatar image of WinCEDev
Factorite (Senior)

Posts:
76
Location:
Europe
Status:
Quote
I dunk for bananas - 2023-02-11 12:20 PM

I'm trying to make an application that sits in the tray forever, and when clicked opens a certain executable


I wrote a module to let eVB applications use the system tray, the topic for it is here.
Let me know if it works for you.
 Top of the page
Jump to forum:
Seconds to generate: 0.140 - Cached queries : 63 - Executed queries : 10