Thread: Need Help using the system tray

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    23

    Question Need Help using the system tray

    I'm trying to create a simple program that when executed will place an icon in the system tray and whenever I double clicked the icon a dialog would appear. I have no idea how to do it so could someone edit the files below to do this. (resource.h/resource.rc/main.c)

    resource.h
    Code:
    #define IDD_MAIN 101
    #define IDC_OK     102
    resource.rc
    Code:
    #include <windows.h>
    #include "resource.h"
    
    IDD_MAIN DIALOG DISCARDABLE  0, 0, 150, 60
    STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
    CAPTION "DIALOG"
    FONT 8, "MS Sans Serif"
    BEGIN
    CTEXT                  "CONTENT",IDC_STATIC,5,12,145,20 
    DEFPUSHBUTTON "&OK",IDC_OK,48,43,50,15
    END
    main.c
    Code:
    #include <windows.h>
    #include "resource.h"
    
    BOOL CALLBACK MainDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
    {
    switch(Message)
    {
    	case WM_CLOSE:
    	EndDialog(hwnd, IDC_OK);
    	break;
    	case WM_INITDIALOG:
    	return TRUE;
    	case WM_COMMAND:
    	switch(LOWORD(wParam))
    {
    	case IDC_OK:
    	EndDialog(hwnd, IDC_OK);
    	break;
    }
    break;
    default:
    return FALSE;
    }
    return TRUE;
    }
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    	LPSTR lpCmdLine, int nCmdShow)
    {
    return DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, MainDlgProc);
    }

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>so could someone edit the files below to do this<<

    No, it doesn't work quite like that unless someone is feeling particularly bored and/or generous.

    This should get you started:

    Shell_NotifyIcon, msdn.

    CodeProject example.

    If you have specific problems regarding your code after that then ask away.

    [edit]Removed windows board search link because it's annoyingly ephemeral; search the windows board for 'shell_notifyicon' for previous discussions.[/edit]
    Last edited by Ken Fitlike; 09-01-2004 at 06:44 AM. Reason: original 'Shell_NotifyIcon, windows board search' link useless
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-05-2009, 10:25 AM
  2. Replies: 3
    Last Post: 06-13-2005, 07:28 AM
  3. Why Can't C++ Be Used to Develop Operating System?
    By Antigloss in forum C++ Programming
    Replies: 7
    Last Post: 05-27-2005, 06:16 AM
  4. System Tray = Notification Area
    By JasonD in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 09-12-2003, 12:55 PM