Solved

Show program only at startbar as an icon

Posted on 1998-11-06
7
172 Views
Last Modified: 2010-04-02
Hi.
How do I make my Borland C++ Builder program
(one Form) show up only at the same place where the
time is shown at Win95.
0
Comment
Question by:boel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 1177108
This is quite simple:
1. Don't call 'ShowWindow()'
2. Use the following code to add an icon:
BOOL TaskBarAddIcon     (   HWND    hwnd,
                            UINT    uID,
                            HICON   hicon,
                            LPSTR   lpszTip
                        )
{
    BOOL            bRC;
    NOTIFYICONDATA  nid;
 
    nid.cbSize              =   sizeof  (   NOTIFYICONDATA);
    nid.hWnd                =   hwnd;
    nid.uID                 =   uID;
    nid.uFlags              =   NIF_MESSAGE | NIF_ICON | NIF_TIP;
    nid.uCallbackMessage    =   WM_USER +   uID;
    nid.hIcon               =   hicon;

    if  (   lpszTip)
            lstrcpyn    (   nid.szTip,  lpszTip,    sizeof  (   nid.szTip));
    else
            nid.szTip[ 0]   =   '\0';
 
    bRC     =   Shell_NotifyIcon(   NIM_ADD,    &nid);
 
    if  (   hicon)
            DestroyIcon (   hicon);
 
    return( bRC);
}

Make sure to handle the callback messages (at least, return somethin that's non-zero), otherwise the icon will be deleted...
0
 

Author Comment

by:boel
ID: 1177109
Where do I put the code, in my Unit1.cpp
---------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop

#include "Unit1.h"
#pragma resource "*.dfm"
TForm1 *Form1;
__fastcall TForm1::TForm1(TComponent* Owner)
      : TForm(Owner)
{
}
-------------------------------------------

or in my project1.cpp

WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
      try
      {
            Application->Initialize();
            Application->CreateForm(__classid(TForm1),&Form1);
            Application->Run();
      }
      catch (Exception &exception)
      {
            Application->ShowException(&exception);
      }
      return 0;
}-----------------------------
BOEL

0
 
LVL 86

Expert Comment

by:jkr
ID: 1177110
Well, it depends on when you want to show up the icon - in a plain Win32 program, i'd add the icons immediatly after the call to 'CreateWindow()', just before entering the main message loop.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:viktornet
ID: 1177111
after Application->CreateForm() you put this one...

Application->ShowMainForm = false;

The function should be executed at OnCreate() of the form.....

Cheers,
Viktor
0
 

Author Comment

by:boel
ID: 1177112
Well, it nearly work, but I dont see any icon,
just an empty space where the icon should be.
How about the parameter to TaskBarAddIcon()
The first one "hwnd", which handle shall I pass to that one
 Application->Handle or Form->Handle?
The last one "lpszTip" is the text that show up when the mouse-
-pointer is over the icon I think.
But what about the second and third paramter
"uID", "hicon" ?  
And how shall I handle the callback messages that "jkr" told me in the proposed answer??
One more question, (that maybe not included in the start question), how do I do to make the Icon response to mouseclick??
Boel
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1177113
You need to pass the Application->Handle.... and you need to assigne something to the icon, if you want to have an icon in the emprty space...

for example...

AddICon.... (..... , Application->Icon,.........);

to have the icon of the app in the task bar...

and remember that you need to remove the taken space by the your procedure....That procedure puts it in the task bar, but it needs to realese it in OnDestroy() of your application...

Cheers,
Viktor
0
 

Expert Comment

by:zouying
ID: 1177114
You can also get help about taskbar in help file. Search Win32 SDK.
As far as I know, there is no MFC support like CTaskbar, you should use Win32 SDK to implement.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question