Tray Icon without Taskbar Icon 
Author Message
 Tray Icon without Taskbar Icon

Hi Rick,

The best way to do this is to create a hidden window that will handle all
menu generated messages.  Set this window as the owner of the menu when you
call TrackPopupMenu.  The trick here is to create the hidden window as
follows:

// Create a dummy window.
if (!CWnd::CreateEx(
    NULL,                 // Extended window style.
    _T("STATIC"),      // Class name - use default CStatic settings.
    NULL,                 // Window name - do not care, invisible.
    WS_POPUP,      // Window style - make an invisible popup.
    0, 0, 0, 0,            // Window dimensions - do not care.
    NULL,                 // Parent window - make it the desktop.
    NULL,                 // Window ID.
    NULL))                // CREATESTRUCT information.
    return FALSE;

If you are using MFC, this is accomplished easily by deriving a class from
CWnd and creating a member function Create with no arguments.  This derived
class will receive all messages from the popup menu and you simply add
message handlers for each.

Also note that, if you are using MFC, it could become a bit tricky since
the framework expects to have a main window associated with the
application, otherwise the framework will force the application to
terminate.  To bypass this behavior, you simply create the main window to
be your CWnd-derived window and assign it to your CWinApp-derived
m_pMainWnd.  The trick here is that since the CWnd-derived window is not a
CFrameWnd-derived window, not only the creation but also the deletion is
your responsibility.  Make sure you create the main window as a member of
your CWinApp-derived object and delete it in the _dtor.

Hope this is what you're looking for.  If you want, I can give you some
sample source code.

G'd day!
Leo Vildosola



Quote:
> I need my dialog-based app to put an icon in the taskbar notification
> area without displaying anything in the main taskbar.  So far I've
> managed to put the icon in the tray and create a popup menu for it,
> but I'm not having much luck making the main taskbar icon to go away.

> I've used DejaNews to read through all the posts I could find, and I
> understand that my app should initiate an invisible dialog box which
> will pass control to the "real" dialog, but I can't get it right.  The
> closest I've come is when I designated the "real" dialog box as a
> child; the tray icon showed up, and the taskbar icon didn't - but then
> I couldn't make the "real" (child) dialog visible at all!

> I put everything back so that right now I have both the taskbar icon
> and the tray icon showing up.  Here's the code from the primary
> (invisible) dialog that initiates the "real" one:

> BOOL CZeroDlg::OnInitDialog()
> {
>         CDialog::OnInitDialog();

>         ShowWindow(SW_HIDE);
>         ModifyStyle(WS_VISIBLE,NULL,0);

>         CTheRealDlg dlg;
>         dlg.DoModal();

>         EndDialog(0);

>         return TRUE;
> }

> Can anyone show me what I'm doing wrong?

> Thanks for any help.

> --
> Rick Joseph

> To email me, remove the X



Fri, 03 Sep 1999 03:00:00 GMT  
 Tray Icon without Taskbar Icon

Quote:
>convert a modal dialog box to a non-modal dialog is a real joy, too.  
>I haven't had any success with any of those things as of yet.

Call Create in the dialog constructor, override PostNcDestroy and call
delete(this) in there, and when you need the dialog just new one up.

Bob Moore [MVP]

Any opinions expressed here are my own, and do
not relect those of my employer. Please note that
I do NOT work for Microsoft.



Sat, 04 Sep 1999 03:00:00 GMT  
 Tray Icon without Taskbar Icon



Quote:


> >lot of stuff easy, but other things are rather tough, should you ask
> >me. :)  When I set out to do the icon, I thought it would be a simple
> >two second job....

> I'm having a hard time understanding why certain things are so
> difficult to code, myself.  

> I don't know how many hours I've spent on things like trying to get
> an app to remove its icon from the task bar, or trying to get
> dialog-based menu items to check and uncheck - oh, and trying to
> convert a modal dialog box to a non-modal dialog is a real joy, too.  
> I haven't had any success with any of those things as of yet.

It took me a few days also, but right now I have an SDI program running
that pops up a modal dialog box when it's tray icon is double clicked or
upon selecting items from the tray's menu.  Here is what I did.

BOOL CYourApp::InitInstance()
{
// Normal stuff removed, important left behind

//This sets the App to hidden...
        m_nCmdShow = SW_HIDE;

//...and it must come before the OnFileNew() call.
        OnFileNew();                                            // Replaces ParsCommandLine
        if (m_pMainWnd == NULL)
        {
                return FALSE;
        }

        return TRUE;

Quote:
}

Then in the CMainFrames OnCreate function I add the icon, register
CMainFrame as the call back, and use the CMainFrame's file menu as the menu
for the tray icon's popup.

This took several days to figure out.

Joseph Hines
Software Engineer
Euclid Systems Corp.



Sat, 04 Sep 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Tray Icon without Taskbar Icon

2. Hide taskbar icon on application startup (show only task tray icon)

3. Manipulate Icons in the System Tray(Taskbar)

4. Tray Icon vs taskbar button

5. tray icon vs taskbar

6. Taskbar / System tray icon creation in MFC

7. Adding an icon to the Win95 icon tray.

8. Loading an icon in the taskbar (beside the time) -- like the volume icon

9. Loading an icon in the taskbar (beside the time) -- like the volume icon

10. Taskbar Icon of Dialog App without titlebar?

11. Splash Window Without Icon on TaskBar

12. CoolHide - Help you hide/minimize window to Tray and hide icons from the system tray

 

 
Powered by phpBB® Forum Software