• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

Make systray Icon

Hi

I'm trying to write to write a very simple windows program in C.

All I want it to do is run, and as long as its running display an icon of my choice in the system tray.

Unfortunately, I've never written a visual program in C before, I need some pointers on where to start and maybe some example code.

PS I don't want to use any other language

-Mike
0
nerdmike
Asked:
nerdmike
1 Solution
 
XestrixCommented:
0
 
nerdmikeAuthor Commented:
Sorry, I should have mentioned I want to use API, not MFC

0
 
cookreCommented:

#include <shellapi.h>

// This will probably work, but may not.
// WM_USER used to be inviolate, but, according to some, may not be.
// The 'proper' way now-a-days is to use RegisterWindowMessage()
#define WM_TRAY_NOTIFY   WM_USER+ComethingUniqueToYourApp

NOTIFYICONDATA SysTray;
HICON          ICOGO;

// Install tray icon
ICOGO=LoadIcon(hInst,MAKEINTRESOURCE(ResourcenameOfIcon));
SysTray.cbSize=sizeof(NOTIFYICONDATA);
SysTray.hWnd  =hWnd;
SysTray.uID   =217;
SysTray.hIcon=ICOGO;
SysTray.uCallbackMessage=WM_TRAY_NOTIFY;
strcpy(SysTray.szTip,"ToolTip");
SysTray.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP;
Shell_NotifyIcon(NIM_ADD,&SysTray);


// Remove tray icon
Shell_NotifyIcon(NIM_DELETE,&SysTray);


// events in WndProc
switch (message)
       {
       ...
       case WM_TRAY_NOTIFY:
            // whatever
            break;
       }
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now