Solved

Show program only at startbar as an icon

Posted on 1998-11-06
7
173 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

623 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