Thread: Console App minimized into system tray

  1. #1
    Registered User Liam Battle's Avatar
    Join Date
    Jan 2002
    Posts
    114

    Console App minimized into system tray

    Was wondering, could any one throw me some code on how to maky my console app minimize into the system tray?

    ive never had to do it before, and was wondering how i could take care of that?

    i searched the board and didnt find anything matching my needs...
    im not using the WIN API or MFC, its just a console application...

    I want to be able to do it on the NT kernel.

    Thanks for any help in advance...
    LB0: * Life once school is done
    LB1: N <- WakeUp;
    LB2: N <- C++_Code;
    LB3: N >= Tired : N <- Sleep;
    LB4: JMP*-3;

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    Your gonna need to use API functions. Search MSDN.

  3. #3
    Registered User Liam Battle's Avatar
    Join Date
    Jan 2002
    Posts
    114
    I know how to do it in the WIN API...

    but i dont want to use it... there must be a shell command i can call inside my prog
    LB0: * Life once school is done
    LB1: N <- WakeUp;
    LB2: N <- C++_Code;
    LB3: N >= Tired : N <- Sleep;
    LB4: JMP*-3;

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    12
    // you can use the win api in your console program.

    // the window will minimize into the system tray for 5 seconds and reappear

    #include<shellapi.h>
    #include "stdafx.h"
    #include<windows.h>
    #include<iostream.h>


    NOTIFYICONDATA Tray;
    HWND hWnd;


    int main(int argc, char* argv[])
    {

    cout<<"Window will be minimised in system tray for 5 seconds and reappear.";
    Sleep(2000);

    //window handle
    hWnd=FindWindow("ConsoleWindowClass",NULL);

    //hide the window
    ShowWindow(hWnd,0);

    //tray info
    Tray.cbSize=sizeof(Tray);
    Tray.hIcon=LoadIcon(NULL,IDI_WINLOGO);
    Tray.hWnd=hWnd;
    strcpy(Tray.szTip,"My Application");
    Tray.uCallbackMessage=WM_LBUTTONDOWN;
    Tray.uFlags=NIF_ICON | NIF_TIP | NIF_MESSAGE;
    Tray.uID=1;

    //set the icon in tasbar tray
    Shell_NotifyIcon(NIM_ADD, &Tray);


    Sleep(5000);

    //remove the icon
    Shell_NotifyIcon(NIM_DELETE, &Tray);
    ShowWindow(hWnd,1);

    return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 05-06-2006, 03:34 PM
  2. Using C++ to run a Console APP?
    By anon2222 in forum C++ Programming
    Replies: 4
    Last Post: 01-10-2006, 08:07 AM
  3. Hiding Another Progs System Tray Icon
    By (TNT) in forum Windows Programming
    Replies: 2
    Last Post: 04-29-2002, 01:20 PM
  4. System Tray
    By genghis in forum Windows Programming
    Replies: 2
    Last Post: 01-21-2002, 11:15 AM
  5. System Tray Icons
    By ExDigit in forum Windows Programming
    Replies: 5
    Last Post: 01-08-2002, 05:26 PM