Force Minimize to taskbar

M

Maka Sili

Hi,

My VC++ application does not have a titlebar (and therefore no System menu,
no minimize, no maximize
and no close button). We have a custom button for minimize and close.

When the app is in normal/maximized view, clickinng on the taskbar entry
does not minimize the
application. Normally (with apps with titlebar), the application would
minimize when you click on
the taskbar entry.

How do I trap the click event on the taskbar entry so I can minimize the
application?

Thanks for any help.
 
W

William DePalo [MVP VC++]

Maka Sili said:
My VC++ application does not have a titlebar (and therefore no System
menu,
no minimize, no maximize and no close button). We have a custom button
for minimize and close.
...
How do I trap the click event on the taskbar entry so I can minimize the
application?

The shell provides a single function for adding, modifying and updating the
icons in the tray. It is documented here:

http://msdn.microsoft.com/library/d...hell/reference/functions/shell_notifyicon.asp

VC++ v6.0 comes with (or is it the SDK that comes with?) a sample named
TRAYNOT, which demonstrates this "tray notification icon" stuff.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample98/html/vcsmptraynot.asp

Note two important things: Before you put up a context menu in response to a
click on such an icon of yours make sure that a window of yours is in the
foreground - i.e. call SetForegroundWindow(). In addition make sure you send
that Window a WM_NULL message when you take the menu down.

Regards,
Will
 
M

Maka Sili

I already have the function/menu in the system tray (no problem there).
The problem is in the taskbar entry (not icon): taskbar entry meaning one
of those list of running/active applications that you can "Alt-Tab" to.

Problem is "when the application is in the foreground and in normal view,
clicking on that "active application's entry in the taskbar" does not
minimize
the application. Supposedly, it should, just like if you minimize this
news readers window by clicking on the taskbar on the entry with caption
"Re: Force Minimize to..." or something like that.
 
W

William DePalo [MVP VC++]

Maka Sili said:
I already have the function/menu in the system tray (no problem there).
The problem is in the taskbar entry (not icon): taskbar entry meaning one
of those list of running/active applications that you can "Alt-Tab" to.
Problem is "when the application is in the foreground and in normal view,
clicking on that "active application's entry in the taskbar" does not
minimize
the application. Supposedly, it should, just like if you minimize this
news readers window by clicking on the taskbar on the entry with caption
"Re: Force Minimize to..." or something like that.

The shell sends a WM_SYSCOMMAND with the SC_MINIMIZE flag when you choose
that menu option, no? But it _does_ not know that you'd prefer to minimize
to a tray icon so you have to add a handler for that message, and in it
potentially hide your "main" window and insert the tray icon if it is not
already there.

Just by the way, some tray applications forego the "button" in the taskbar
altogether. If you don't want to do that you can stop reading here.
Otherwise note to do that there are a few options:

1) Hide your main (unowned) window and display your UI in
another window which is a child of the hidden main window

2) Give the (visible) main window the WS_EX_TOOLWINDOW style.
A side effect here is a more squat caption.

3) Use the shell's ITaskBarList interface

Regards,
Will
 
M

Maka Sili

This may sound weird to you but I did try to add event to receive
WM_SYSCOMMAND
but I do not receive it when clicking on the taskbar entry. On the tasktray
icon, yes, I may
receive notification, but on the taskbar entry for the running app, I don't
get it. I'm seeing
that the reason for that is the application does not have a TitleBar, nor
System Menu,
nor Minimize/Maximize button, nor the Close button. Somehow Windows do not
know
where to send the minimize message. I have tried to handle "WM_ACTIVATE"
but
it is not the right message to handle: it is called even when the window is
only losing
the focus.

I think I should put back the TitleBar/SystemMenu/Minimize/Maximize button.
But like
I said in the first message, that the spec requires a custom Minimize and
Close button.

Thanks for your continued help.
 
W

William DePalo [MVP VC++]

Maka Sili said:
This may sound weird to you but I did try to add event to receive
WM_SYSCOMMAND but I do not receive it when clicking on the taskbar
entry. On the tasktray icon, yes, I may receive notification, but on the
taskbar entry for the running app, I don't get it.

When you click the button in the taskbar the shell carries out the default
command on the menu that you can see if you right click the button. The
commands that the shell puts on that menu depend on the style of your window
and the ones that it enables depend on its state in the same way that the
system menu commands (the menu you see when you click in the upper left
corner of the window's caption) do.

So, right click the button to check what menu commands are there. If the
command that you want is not there you should probably post again in the UI
group

microsoft.public.win32.programmer.ui

Regards,
Will
 
M

Maka Sili

True, I will post in the other group.

As I right-click on the taskbar entry, there's no menu that comes out: no
pop-up window at all,
unlike others where they have Restore, Minimize, Maximize, etc.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top