System tray?

How do I have my program minimize to the Windows 95 System tray (I think that is what it is called, it holds the volume control and a few other apps) anyway.  How do I do it??  I am very new to C++ so if you have Borland C++ Builder, please show it to me visually (have my use their visual option instead of typing a bunch of codes.)

thanks
LVL 1
stevenc317Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jhanceCommented:
You can't do this "visually", you must write a "bunch of codes".  Here, however, is how you do it:

First you must define the NOTITYICONDATA structure with information about your application and what message to send it when the user does something to it in the tray (i.e. TRAY_MSG)

#define TRAY_MSG WM_USER+1

    NOTIFYICONDATA nid;
    nid.cbSize = sizeof(NOTIFYICONDATA);
    nid.hWnd = m_hWnd;
    nid.uID = 8376;
    nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
    nid.uCallbackMessage = TRAY_MSG;
    nid.hIcon = hIcon;
    strcpy(nid.szTip, "My Application");

Then you call Shell_NotifyIcon() to tell the shell to add it to the tray:

    if(!Shell_NotifyIcon(NIM_ADD, &nid)){
        AfxMessageBox("Shell_NotifyIcon() returned FALSE", MB_OK, 0);
    }

Now when the user clicks on the tray icon, Windows will send a TRAY_MSG message to your application.  You might deal with it like this:

    const MSG *mp = GetCurrentMessage();
    if(mp->lParam == WM_LBUTTONDBLCLK){
        if(WasIconic){
            WasIconic = FALSE;
            ShowWindow(SW_RESTORE);
            BringWindowToTop();
        }
        else{
            WasIconic = TRUE;
            ShowWindow(SW_HIDE);
        }
    }

When you app ends, be sure to remove it from the tray:

    nid.uFlags = 0;

    if(!Shell_NotifyIcon(NIM_DELETE, &nid)){
        AfxMessageBox("Shell_NotifyIcon() returned FALSE", MB_OK, 0);
    }
stevenc317Author Commented:
sorry I can't find out where to put it..  Here is my source code for the main window..

//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include <ShellApi.h>
#include "Search.h"
#include "About.h"
#include "Yahoo.h"
#include "Title.h"
#include "Header.h"
#include "Alt.h"
#include "Splash.h"
#include "Credits.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
      : TForm(Owner)
{  StatusBar1->Panels->Items[1]->Text = Time().FormatString("h:nn:ss ampm        ");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::About1Click(TObject *Sender)
{
AboutBox->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Exit1Click(TObject *Sender)
{
Application->Terminate();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N1GethigherinYahoo1Click(TObject *Sender)
{
Yahoo1->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N2Fourtitletags1Click(TObject *Sender)
{
Title1->ShowModal();      
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N3Headertips1Click(TObject *Sender)
{
Header1->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N4Addkeywordstoalttags1Click(TObject *Sender)
{
Alt1->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SplashClick(TObject *Sender)
{
SplashScreen1->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::StatusBar1Click(TObject *Sender)
{
StatusBar1->Panels->Items[1]->Text = Time().FormatString("h:nn:ss ampm        ");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::StevensWebDevelopment1Click(TObject *Sender)
{
ShellExecute(NULL, "open", "http://html.tou.com/webdev/",NULL, NULL, SW_SHOWNORMAL);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::StevensWebHosting1Click(TObject *Sender)
{
ShellExecute(NULL, "open", "http://html.tou.com/hosting/",NULL, NULL, SW_SHOWNORMAL);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::StevensWebPage1Click(TObject *Sender)
{
ShellExecute(NULL, "open", "http://html.tou.com/",NULL, NULL, SW_SHOWNORMAL);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::HtmlGoodies1Click(TObject *Sender)
{
ShellExecute(NULL, "open", "http://htmlgoodies.com",NULL, NULL, SW_SHOWNORMAL);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BigNoseBird1Click(TObject *Sender)
{
ShellExecute(NULL, "open", "http://www.bignosebird.com",NULL, NULL, SW_SHOWNORMAL);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FreeHelpBannerNetwork1Click(TObject *Sender)
{
ShellExecute(NULL, "open", "http://free-help.com",NULL, NULL, SW_SHOWNORMAL);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Credits1Click(TObject *Sender)
{
CreditsPage1->ShowModal();
}
//---------------------------------------------------------------------------
stevenc317Author Commented:
There HAS to be a easier way!
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

jhanceCommented:
As far as I'm concerned, you're on you own.  The data I posted earlier IS the way you do it.  I'm sorry you feel it's too complicated, perhaps you should write a letter of complaint to Microsoft and have them simplify the process.
nigel5Commented:
TForm1 has a constructor, put the first bit of jhance' code in there. It should have destructor, put the last bit in there. put in a handle to trap the minimize command and set ShowWindow(SW_HIDE). The middle bit of code is just a handler for when the user clicks on the icon in the tray with the left button, and will bring the window you just hid to the front. Unfortunately, it is the only way to do it without trapping mouse movement, and hacking screen bits, which is a whole lot harder.

You could add a sytem menu to take care of all the buttons you seem to have, so that when the user clicks on the icon, a menu will appear instead of the window.
vmpnCommented:
I am a begginner in this also and I have a source code for it. I'll post it when I'll get home.
vmpnCommented:
----Systray.cpp
#include <windows.h>
#include "systray.h"

// MyTaskBarAddIcon - adds an icon to the taskbar notification area.  
// Returns TRUE if successful or FALSE otherwise.
// hwnd - handle of the window to receive callback messages
// uID - identifier of the icon
// hicon - handle of the icon to add
// lpszTip - tooltip text
BOOL MyTaskBarAddIcon(HWND hwnd, UINT uID, HICON hicon, LPSTR lpszTip)
{
    BOOL res;
    NOTIFYICONDATA tnid;
 
    tnid.cbSize = sizeof(NOTIFYICONDATA);
    tnid.hWnd = hwnd;
    tnid.uID = uID;
    tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
    tnid.uCallbackMessage = MYWM_NOTIFYICON;
    tnid.hIcon = hicon;
    if (lpszTip)
        lstrcpyn(tnid.szTip, lpszTip, sizeof(tnid.szTip));
    else
        tnid.szTip[0] = '\0';
 
    res = Shell_NotifyIcon(NIM_ADD, &tnid);
 
    if (hicon)
        DestroyIcon(hicon);
 
    return res;
}
 
// MyTaskBarDeleteIcon - deletes an icon from the taskbar  
//     notification area.
// Returns TRUE if successful or FALSE otherwise.
// hwnd - handle of the window that added the icon
// uID - identifier of the icon to delete
BOOL MyTaskBarDeleteIcon(HWND hwnd, UINT uID)
{
      BOOL res;
      NOTIFYICONDATA tnid;
 
      tnid.cbSize = sizeof(NOTIFYICONDATA);
      tnid.hWnd = hwnd;
      tnid.uID = uID;
             
      res = Shell_NotifyIcon(NIM_DELETE, &tnid);
      return res;
}
 
// MyTaskBarAddIcon - adds an icon to the taskbar notification area.  
// Returns TRUE if successful or FALSE otherwise.
// hwnd - handle of the window to receive callback messages
// uID - identifier of the icon
// hicon - handle of the icon to add
// lpszTip - tooltip text
BOOL MyTaskBarModifyIcon(HWND hwnd, UINT uID, HICON hicon, LPSTR lpszTip)
{
    BOOL res;
    NOTIFYICONDATA tnid;
 
    tnid.cbSize = sizeof(NOTIFYICONDATA);
    tnid.hWnd = hwnd;
    tnid.uID = uID;
      tnid.uFlags = 0;
      if(hicon)
            tnid.uFlags |= NIF_ICON;
      if(lpszTip)
             tnid.uFlags |= NIF_TIP;

    tnid.uCallbackMessage = MYWM_NOTIFYICON;
    tnid.hIcon = hicon;
    if (lpszTip)
        lstrcpyn(tnid.szTip, lpszTip, sizeof(tnid.szTip));
    else
        tnid.szTip[0] = '\0';
 
    res = Shell_NotifyIcon(NIM_MODIFY, &tnid);
 
    if (hicon)
        DestroyIcon(hicon);
 
    return res;
}
-----------end

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vmpnCommented:
------------systray.h
#include <windows.h>

const UINT MYWM_NOTIFYICON = WM_USER;

BOOL MyTaskBarAddIcon(HWND hwnd, UINT uID, HICON hicon, LPSTR lpszTip);
BOOL MyTaskBarDeleteIcon(HWND hwnd, UINT uID);

--------end
vmpnCommented:
Here is the main function
---------start
#include <windows.h>
#include <stdlib.h>
#include "vaolrc.h"
#include "systray.h"
#include "aol_proc.h"

void Menu_Call(HWND hwnd, WPARAM wParam, LPARAM lParam);
void Icon_Message(HWND hwnd, WPARAM wParam, LPARAM lParam);
void ShowStatus();
BOOL InitApp();
BOOL InitSysIcon();


LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);

char szWinName[] = "BAOL100C"; /* Name of windows class */

//HWND our_hwnd;
char *IconLoadTip="BAOL Loading ...";
char *wndTitle = "Log - Be Always On Line (BAOL)";
char *prgTitle = "Be Always On Line";

const int window_height = 300;
const int window_width = 370;
const UINT MYuID = 1;

HMENU our_menu;

HWND wndStatus = 0, wndMain = 0;
HWND wndStatusMsgs = 0;
HINSTANCE prgThisInst;

double waiting_period = 20000;
char aol_path;

int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst,
                              LPSTR lpszArgs, int nWinMode)
{
//      HWND hwnd;
      MSG       msg;
      WNDCLASS wc1;

      /* Define window class */
      wc1.hInstance = hThisInst; /* handle to this instance */
      wc1.lpszClassName = szWinName; /* window class name */
      wc1.lpfnWndProc = WindowFunc; /* window function */
      wc1.style = 0; /* default style */

      wc1.hIcon = LoadIcon(hThisInst, "icon_main"); /* icon style */
      wc1.hCursor = LoadCursor(NULL, IDC_ARROW); /* cursor style */
      wc1.lpszMenuName = NULL; /* no menu */

      wc1.cbClsExtra = 0; /* no extra */
      wc1.cbWndExtra = 0; /* information needed */

      /* Make the window background white. */
      wc1.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);

      /* Register the window class. */
      if(!RegisterClass (&wc1)) return 0;

      prgThisInst = hThisInst;

      if(!InitApp())
            return 0;
      if(!InitSysIcon());
            return 0;

      /* Create the message loop */
      while(GetMessage(&msg, NULL, 0, 0))
      {
            TranslateMessage(&msg); /* allow use of keyboard */
            DispatchMessage(&msg); /* return control to Windows */
      }
      MyTaskBarDeleteIcon(wndMain, MYuID);
      return msg.wParam;
}

/* This function is called by Windows 95 and is passed
      messages from the message queue.
*/
LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
            

      if (wndMain ==  hwnd)      
      {
            switch(message)
            {
                  case WM_DESTROY: /* terminate the program */
                        PostQuitMessage(0);
                        break;
                  case WM_COMMAND:
                        Menu_Call(hwnd, wParam, lParam);
                        break;
                  case MYWM_NOTIFYICON:
                        Icon_Message(hwnd, wParam, lParam);
                        break;
                  default:
                  
                        /* Let Windows 95 process any messages not specified in
                              the preceding switch statement. */
                        return DefWindowProc(hwnd, message, wParam, lParam);
            }
      }
      else if(wndStatus == hwnd)
      {
//            MessageBox(hwnd, "wndStatus", "GOT IT", MB_OK);
            
            switch(message)
            {
                  case WM_DESTROY: /* terminate the program */
                  case WM_CLOSE: /* terminate the program */
                        ShowWindow(wndStatus, SW_HIDE);
                        break;
                  default:
                        /* Let Windows 95 process any messages not specified in
                              the preceding switch statement. */
                        return DefWindowProc(hwnd, message, wParam, lParam);
            }
            
      }
      else
            switch(message)
            {
                  default:
                        /* Let Windows 95 process any messages not specified in
                              the preceding switch statement. */
                        return DefWindowProc(hwnd, message, wParam, lParam);
            }
      return 0;
}
 
void Menu_Call(HWND hwnd, WPARAM wParam, LPARAM lParam)
{

      HWND control;
      control = (HWND) lParam;
      switch(LOWORD(wParam))
      {
            case MENU_ShowStatus:
                  ShowStatus();
            
                  break;
            case MENU_StopStart:
                  MessageBox(hwnd, "StopStart", "GOT IT", MB_OK);
                  break;
            case MENU_Exit:
                  PostQuitMessage(0);
                  //MessageBox(hwnd, "Exit", "GOT IT", MB_OK);
                  break;
            case MENU_About:
                  MessageBox(wndMain, "BAOL\n**********************************************\n!!!! INTERNAL DISTRIBUTION ONLY !!!!\n**********************************************\n\nCan cause serious damage to computer and its parts\n\nI WARNED YA!!!\n\n-------------------------------------------------------\nBAOL Copyright ? 1997 Vladimir Berezniker", "ABOUT ...", MB_OK | MB_ICONINFORMATION);
                  break;
            default:
                  MessageBox(hwnd, "Something unknown", "GOT IT", MB_OK);
                  break;
      }
}

void Icon_Message(HWND hwnd, WPARAM wParam, LPARAM lParam)
{
    UINT uID;
    UINT uMouseMsg;
      POINT MouseCoords;
       static BOOL MouseDown=FALSE;
      BOOL track_ret;
    uID = (UINT) wParam;
    uMouseMsg = (UINT) lParam;
//      static BOOL aval = TRUE;
 
//      if (!aval)
//            return;

      switch(uMouseMsg)
      {
      case WM_RBUTTONDOWN:
      //      MessageBox(hwnd, "RIGHT BUTTON CLICK", "MOUSE", MB_OK);
            MouseDown = TRUE;
            break;
      case WM_RBUTTONUP:
            if (MouseDown)
            {
                  MouseDown =FALSE;
                  if(GetCursorPos(&MouseCoords))
                  {

                        SetForegroundWindow(hwnd);
                        track_ret = TrackPopupMenu(GetSubMenu(our_menu,0), TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON, MouseCoords.x-1, MouseCoords.y,0,hwnd, NULL);
                        PostMessage(hwnd, WM_USER, 0, 0);

                        if(!track_ret)
                              MessageBox(hwnd, "ERROR POPING UP", "MOUSE", MB_OK);
                  }      
            }
            break;
      case WM_LBUTTONDBLCLK:
//            aval = FALSE;
//            SetForegroundWindow(hwnd);
//            MessageBox(hwnd, "LEFT BUTTON DOUBLE CLICK", "MOUSE", MB_OK);
//            aval = TRUE;
            ShowStatus();
            break;
      }

    return;
 }

void ShowStatus()
{
      ShowWindow(wndStatus, SW_SHOWNORMAL);
      UpdateWindow(wndStatus);
}

BOOL LoadValues()
{
      return TRUE;
}

BOOL InitApp()
{
      BOOL ret_val = TRUE;
      /* Now that a window class has been registered, a window can be created. */
      wndMain = CreateWindow(
                  szWinName, /* name of window class */
                  "0", /* title*/
                  WS_OVERLAPPED | WS_SYSMENU | WS_DLGFRAME, /* window style - normal */
                  CW_USEDEFAULT, /* X coordinate - let Windows decide */
                  CW_USEDEFAULT, /* Y coordinate - let Windows decide */
                  window_width, /* width - let Windows decide */
                  window_height, /* height - let Windows decide */
                  HWND_DESKTOP, /* No parent window */
                  NULL, /* no menu */
                  prgThisInst, /* handle of this instance of the program */
                  NULL /* no additional arguments */
                  );

      wndStatus = CreateWindow(
                  szWinName, /* name of window class */
                  wndTitle, /* title*/
                  WS_OVERLAPPED | WS_SYSMENU | WS_DLGFRAME, /* window style - normal */
                  CW_USEDEFAULT, /* X coordinate - let Windows decide */
                  CW_USEDEFAULT, /* Y coordinate - let Windows decide */
                  window_width, /* width - let Windows decide */
                  window_height, /* height - let Windows decide */
                  HWND_DESKTOP, /* No parent window */
                  NULL, /* no menu */
                  prgThisInst, /* handle of this instance of the program */
                  NULL /* no additional arguments */
                  );


      wndStatusMsgs = CreateWindow(
                  "Edit",
                  "", /* title*/
            WS_CHILD | WS_VISIBLE | WS_BORDER
                  | ES_AUTOHSCROLL | ES_AUTOVSCROLL
                  | ES_LEFT | ES_MULTILINE | ES_READONLY
                  | WS_EX_CLIENTEDGE | DS_3DLOOK
                  | WS_VSCROLL,
                  0, /* X coordinate - let Windows decide */
                  0, /* Y coordinate - let Windows decide */
                  window_width-6, /* width - let Windows decide */
                  window_height-30, /* height - let Windows decide */
                  wndStatus, /* No parent window */
                  NULL, /* no menu */
                  prgThisInst, /* handle of this instance of the program */
                  NULL /* no additional arguments */
                  );
      /* Display the window. */
//      our_hwnd = hwnd;

      our_menu = LoadMenu(prgThisInst, "main_menu");
      ShowWindow(wndStatus, SW_HIDE);
      UpdateWindow(wndStatus);
      UpdateWindow(wndStatusMsgs);

      if(!LoadValues())
            return FALSE;

      if(!Is_AOL3())
      {
            MessageBox(wndMain, "Sorry, but AOL 3.0 is not loaded.\nPlease load it first and then try again.\nThank you.\nBAOL", prgTitle, MB_OK | MB_ICONERROR);
            ret_val = FALSE      ;
      }
      UpdateWindow(wndMain);


      return ret_val;
}

BOOL InitSysIcon()
{
      BOOL ret_val = TRUE;
      if (!MyTaskBarAddIcon(wndMain, MYuID, LoadIcon(prgThisInst, "icon_yellow"), IconLoadTip))
      {
            MessageBox(wndMain, "Unable to create icon!", "BAOL - ERROR", MB_OK | MB_ICONSTOP);
            ret_val=FALSE;
      }

// EXIT
      if (!ret_val)            // If not initialized clean up
      {
            MyTaskBarDeleteIcon(wndMain, MYuID);
      }

      return ret_val;
}
-end
vmpnCommented:
Here is the main function
---------start
#include <windows.h>
#include <stdlib.h>
#include "vaolrc.h"
#include "systray.h"
#include "???_proc.h"

void Menu_Call(HWND hwnd, WPARAM wParam, LPARAM lParam);
void Icon_Message(HWND hwnd, WPARAM wParam, LPARAM lParam);
void ShowStatus();
BOOL InitApp();
BOOL InitSysIcon();


LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);

char szWinName[] = "????????????????"; /* Name of windows class */

//HWND our_hwnd;
char *IconLoadTip="????? Loading ...";
char *wndTitle = "Log - ?????????";
char *prgTitle = "???????????";

const int window_height = 300;
const int window_width = 370;
const UINT MYuID = 1;

HMENU our_menu;

HWND wndStatus = 0, wndMain = 0;
HWND wndStatusMsgs = 0;
HINSTANCE prgThisInst;

double waiting_period = 20000;
char aol_path;

int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst,
                              LPSTR lpszArgs, int nWinMode)
{
//      HWND hwnd;
      MSG       msg;
      WNDCLASS wc1;

      /* Define window class */
      wc1.hInstance = hThisInst; /* handle to this instance */
      wc1.lpszClassName = szWinName; /* window class name */
      wc1.lpfnWndProc = WindowFunc; /* window function */
      wc1.style = 0; /* default style */

      wc1.hIcon = LoadIcon(hThisInst, "icon_main"); /* icon style */
      wc1.hCursor = LoadCursor(NULL, IDC_ARROW); /* cursor style */
      wc1.lpszMenuName = NULL; /* no menu */

      wc1.cbClsExtra = 0; /* no extra */
      wc1.cbWndExtra = 0; /* information needed */

      /* Make the window background white. */
      wc1.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);

      /* Register the window class. */
      if(!RegisterClass (&wc1)) return 0;

      prgThisInst = hThisInst;

      if(!InitApp())
            return 0;
      if(!InitSysIcon());
            return 0;

      /* Create the message loop */
      while(GetMessage(&msg, NULL, 0, 0))
      {
            TranslateMessage(&msg); /* allow use of keyboard */
            DispatchMessage(&msg); /* return control to Windows */
      }
      MyTaskBarDeleteIcon(wndMain, MYuID);
      return msg.wParam;
}

/* This function is called by Windows 95 and is passed
      messages from the message queue.
*/
LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
            

      if (wndMain ==  hwnd)      
      {
            switch(message)
            {
                  case WM_DESTROY: /* terminate the program */
                        PostQuitMessage(0);
                        break;
                  case WM_COMMAND:
                        Menu_Call(hwnd, wParam, lParam);
                        break;
                  case MYWM_NOTIFYICON:
                        Icon_Message(hwnd, wParam, lParam);
                        break;
                  default:
                  
                        /* Let Windows 95 process any messages not specified in
                              the preceding switch statement. */
                        return DefWindowProc(hwnd, message, wParam, lParam);
            }
      }
      else if(wndStatus == hwnd)
      {
//            MessageBox(hwnd, "wndStatus", "GOT IT", MB_OK);
            
            switch(message)
            {
                  case WM_DESTROY: /* terminate the program */
                  case WM_CLOSE: /* terminate the program */
                        ShowWindow(wndStatus, SW_HIDE);
                        break;
                  default:
                        /* Let Windows 95 process any messages not specified in
                              the preceding switch statement. */
                        return DefWindowProc(hwnd, message, wParam, lParam);
            }
            
      }
      else
            switch(message)
            {
                  default:
                        /* Let Windows 95 process any messages not specified in
                              the preceding switch statement. */
                        return DefWindowProc(hwnd, message, wParam, lParam);
            }
      return 0;
}
 
void Menu_Call(HWND hwnd, WPARAM wParam, LPARAM lParam)
{

      HWND control;
      control = (HWND) lParam;
      switch(LOWORD(wParam))
      {
            case MENU_ShowStatus:
                  ShowStatus();
            
                  break;
            case MENU_StopStart:
                  MessageBox(hwnd, "StopStart", "GOT IT", MB_OK);
                  break;
            case MENU_Exit:
                  PostQuitMessage(0);
                  //MessageBox(hwnd, "Exit", "GOT IT", MB_OK);
                  break;
            case MENU_About:
                  MessageBox(wndMain, "?????\n**********************************************\n!!!! INTERNAL DISTRIBUTION ONLY !!!!\n**********************************************\n\nCan cause serious damage to computer and its parts\n\nI WARNED YA!!!\n\n-------------------------------------------------------\nBAOL Copyright ? 1997 Vladimir Berezniker", "ABOUT ...", MB_OK | MB_ICONINFORMATION);
                  break;
            default:
                  MessageBox(hwnd, "Something unknown", "GOT IT", MB_OK);
                  break;
      }
}

void Icon_Message(HWND hwnd, WPARAM wParam, LPARAM lParam)
{
    UINT uID;
    UINT uMouseMsg;
      POINT MouseCoords;
       static BOOL MouseDown=FALSE;
      BOOL track_ret;
    uID = (UINT) wParam;
    uMouseMsg = (UINT) lParam;
//      static BOOL aval = TRUE;
 
//      if (!aval)
//            return;

      switch(uMouseMsg)
      {
      case WM_RBUTTONDOWN:
      //      MessageBox(hwnd, "RIGHT BUTTON CLICK", "MOUSE", MB_OK);
            MouseDown = TRUE;
            break;
      case WM_RBUTTONUP:
            if (MouseDown)
            {
                  MouseDown =FALSE;
                  if(GetCursorPos(&MouseCoords))
                  {

                        SetForegroundWindow(hwnd);
                        track_ret = TrackPopupMenu(GetSubMenu(our_menu,0), TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON, MouseCoords.x-1, MouseCoords.y,0,hwnd, NULL);
                        PostMessage(hwnd, WM_USER, 0, 0);

                        if(!track_ret)
                              MessageBox(hwnd, "ERROR POPING UP", "MOUSE", MB_OK);
                  }      
            }
            break;
      case WM_LBUTTONDBLCLK:
//            aval = FALSE;
//            SetForegroundWindow(hwnd);
//            MessageBox(hwnd, "LEFT BUTTON DOUBLE CLICK", "MOUSE", MB_OK);
//            aval = TRUE;
            ShowStatus();
            break;
      }

    return;
 }

void ShowStatus()
{
      ShowWindow(wndStatus, SW_SHOWNORMAL);
      UpdateWindow(wndStatus);
}

BOOL LoadValues()
{
      return TRUE;
}

BOOL InitApp()
{
      BOOL ret_val = TRUE;
      /* Now that a window class has been registered, a window can be created. */
      wndMain = CreateWindow(
                  szWinName, /* name of window class */
                  "0", /* title*/
                  WS_OVERLAPPED | WS_SYSMENU | WS_DLGFRAME, /* window style - normal */
                  CW_USEDEFAULT, /* X coordinate - let Windows decide */
                  CW_USEDEFAULT, /* Y coordinate - let Windows decide */
                  window_width, /* width - let Windows decide */
                  window_height, /* height - let Windows decide */
                  HWND_DESKTOP, /* No parent window */
                  NULL, /* no menu */
                  prgThisInst, /* handle of this instance of the program */
                  NULL /* no additional arguments */
                  );

      wndStatus = CreateWindow(
                  szWinName, /* name of window class */
                  wndTitle, /* title*/
                  WS_OVERLAPPED | WS_SYSMENU | WS_DLGFRAME, /* window style - normal */
                  CW_USEDEFAULT, /* X coordinate - let Windows decide */
                  CW_USEDEFAULT, /* Y coordinate - let Windows decide */
                  window_width, /* width - let Windows decide */
                  window_height, /* height - let Windows decide */
                  HWND_DESKTOP, /* No parent window */
                  NULL, /* no menu */
                  prgThisInst, /* handle of this instance of the program */
                  NULL /* no additional arguments */
                  );


      wndStatusMsgs = CreateWindow(
                  "Edit",
                  "", /* title*/
            WS_CHILD | WS_VISIBLE | WS_BORDER
                  | ES_AUTOHSCROLL | ES_AUTOVSCROLL
                  | ES_LEFT | ES_MULTILINE | ES_READONLY
                  | WS_EX_CLIENTEDGE | DS_3DLOOK
                  | WS_VSCROLL,
                  0, /* X coordinate - let Windows decide */
                  0, /* Y coordinate - let Windows decide */
                  window_width-6, /* width - let Windows decide */
                  window_height-30, /* height - let Windows decide */
                  wndStatus, /* No parent window */
                  NULL, /* no menu */
                  prgThisInst, /* handle of this instance of the program */
                  NULL /* no additional arguments */
                  );
      /* Display the window. */
//      our_hwnd = hwnd;

      our_menu = LoadMenu(prgThisInst, "main_menu");
      ShowWindow(wndStatus, SW_HIDE);
      UpdateWindow(wndStatus);
      UpdateWindow(wndStatusMsgs);

      if(!LoadValues())
            return FALSE;

      if(!Is_????())
      {
            MessageBox(wndMain, "Sorry, but something??? is not loaded.\nPlease load it first and then try again.\nThank you.\n????", prgTitle, MB_OK | MB_ICONERROR);
            ret_val = FALSE      ;
      }
      UpdateWindow(wndMain);


      return ret_val;
}

BOOL InitSysIcon()
{
      BOOL ret_val = TRUE;
      if (!MyTaskBarAddIcon(wndMain, MYuID, LoadIcon(prgThisInst, "icon_yellow"), IconLoadTip))
      {
            MessageBox(wndMain, "Unable to create icon!", "BAOL - ERROR", MB_OK | MB_ICONSTOP);
            ret_val=FALSE;
      }

// EXIT
      if (!ret_val)            // If not initialized clean up
      {
            MyTaskBarDeleteIcon(wndMain, MYuID);
      }

      return ret_val;
}
-end
stevenc317Author Commented:
thanks
vmpnCommented:
no problem
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.