Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can H.NotifyIcon be used in Winform #96

Open
FreeVB opened this issue Jun 6, 2023 · 4 comments
Open

Can H.NotifyIcon be used in Winform #96

FreeVB opened this issue Jun 6, 2023 · 4 comments

Comments

@FreeVB
Copy link

FreeVB commented Jun 6, 2023

Can H.NotifyIcon be used in Winform?

@HavenDV
Copy link
Owner

HavenDV commented Jun 6, 2023

Yes, sure. There is no separate implementation under WindowsForms, but there is a general implementation suitable for any platform. Here's an example code:
https://github.com/HavenDV/H.NotifyIcon/blob/master/src/apps/H.NotifyIcon.Apps.Console/Program.cs

@FreeVB
Copy link
Author

FreeVB commented Jun 6, 2023

I tested this method but encountered an error as indicated in the image below.
WinFormsApp1.zip
error

@FreeVB
Copy link
Author

FreeVB commented Jun 6, 2023

It seems that the reason why the ICON attribute must be set is that if it is empty, an error will occur.

Is it due to thread settings? Although I started normally, the form did not display. If I manually add this. Show(); Forms can be displayed, but they are not operable.

Also, does it seem that each menu item cannot have icon properties set? It would be great if this feature could be added.

@HavenDV
Copy link
Owner

HavenDV commented Jun 6, 2023

Yes, there may be issues here using TrayIconWithContextMenu. This class assumes that the process does not have a window. Please take a look at this code and try using regular TrayIcon
https://github.com/HavenDV/H.NotifyIcon/blob/master/src/libs/H.NotifyIcon/PopupMenus/TrayIconWithContextMenu.cs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants