473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Relationship between a window and its associated taskbar button

Hi,

This is really just a theoretical question for my own interest, and not for
any nefarious purpose... :-)

Say we have three applications running - Notepad, Wordpad and Excel - and
each window is in its "normal" state i.e. not maximised, and not minimised
to the taskbar.

We click each of the three taskbar buttons in turn and, of course, the three
applications receive focus one after the other... We click on the Notepad
taskbar button, and Notepad receives focus. Obviously!

Similarly, if we click each of the applications in turn, their associated
taskbar button appears indented, i.e. as if it has been clicked.

My question is, how does Windows relate an application to its associated
taskbar button? I.e. when you click on Notepad, how does Windows "know"
which of the taskbar buttons to indent? I'm assuming it must use a hWnd...?

Assuming it does, is there any way to discover an application's taskbar
button's hWnd from the hWnd of the application itself?

Any assistance gratefully received.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 30 '08 #1
10 2482
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
My question is, how does Windows relate an application to its associated
taskbar button? I.e. when you click on Notepad, how does Windows "know"
which of the taskbar buttons to indent? I'm assuming it must use a
hWnd...?

Assuming it does, is there any way to discover an application's taskbar
button's hWnd from the hWnd of the application itself?
Hmmm, unfortunately there's no microsoft.public.win32.programmer.shell
group, so the closest thing might be microsoft.public.win32.programmer.ui.
I've seen tray questions there, so perhaps a taskbar question would be
well-suited there too. I definitely think you need to ask outside of the
..NET groups on this one. But please report your findings! I, too, find this
interesting on a theoretical level. I can't even think of how I might ever
use it, but it'd be cool to know.

However, my prediction is that the info is stored in an internal structure
and is not exposed. A cursory glance of the appbar-related stuff doesn't
reveal any functions or messages that relate to buttons.
Oct 30 '08 #2
"Jeff Johnson" <i.***@enough.spamwrote in message
news:OG**************@TK2MSFTNGP03.phx.gbl...
>My question is, how does Windows relate an application to its associated
taskbar button? I.e. when you click on Notepad, how does Windows "know"
which of the taskbar buttons to indent? I'm assuming it must use a
hWnd...?

Assuming it does, is there any way to discover an application's taskbar
button's hWnd from the hWnd of the application itself?

Hmmm, unfortunately there's no microsoft.public.win32.programmer.shell
group, so the closest thing might be microsoft.public.win32.programmer.ui.
I've seen tray questions there, so perhaps a taskbar question would be
well-suited there too. I definitely think you need to ask outside of the
.NET groups on this one. But please report your findings! I, too, find
this interesting on a theoretical level. I can't even think of how I might
ever use it, but it'd be cool to know.
OK - I'll try a more appropriate newsgroup...
However, my prediction is that the info is stored in an internal structure
and is not exposed. A cursory glance of the appbar-related stuff doesn't
reveal any functions or messages that relate to buttons.
Getting the taskbar button for any running application is (relatively)
easily achievable through a whole slew of p/invoke calls and a bit of unsafe
code:
http://www.codeproject.com/KB/shell/taskbarsorter.aspx

I just can't imagine that Windows is going through all of this every time
someone clicks a taskbar button or a running application's window...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 30 '08 #3
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:uU**************@TK2MSFTNGP03.phx.gbl...
>However, my prediction is that the info is stored in an internal
structure and is not exposed. A cursory glance of the appbar-related
stuff doesn't reveal any functions or messages that relate to buttons.

Getting the taskbar button for any running application is (relatively)
easily achievable through a whole slew of p/invoke calls and a bit of
unsafe code:
http://www.codeproject.com/KB/shell/taskbarsorter.aspx
Egad. I regularly use a utility called TaskArrange, which does just this! I
can't believe I forgot about that. Well, that's cool then.
Oct 30 '08 #4
"Jeff Johnson" <i.***@enough.spamwrote in message
news:uY**************@TK2MSFTNGP03.phx.gbl...
>>However, my prediction is that the info is stored in an internal
structure and is not exposed. A cursory glance of the appbar-related
stuff doesn't reveal any functions or messages that relate to buttons.

Getting the taskbar button for any running application is (relatively)
easily achievable through a whole slew of p/invoke calls and a bit of
unsafe code:
http://www.codeproject.com/KB/shell/taskbarsorter.aspx

Egad. I regularly use a utility called TaskArrange, which does just this!
I use this: http://taskix.robustit.com/
I can't believe I forgot about that. Well, that's cool then.
That certainly allows me to drill down into the taskbar's button collection
(for want of a better term) and find one whose title is the same or similar
to the title of an application's window - it doesn't get me any closer to
finding an "association" between a window and its taskbar button, though...

AAMOI, do you know how a C# WinForms app "suppresses" a form's taskbar
button when its ShowInTaskbar property is set to false...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 30 '08 #5
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:e1**************@TK2MSFTNGP03.phx.gbl...
AAMOI, do you know how a C# WinForms app "suppresses" a form's taskbar
button when its ShowInTaskbar property is set to false...?
No, but since VB6 offers the same capability I'd say there's defintely a
Windows API method of doing it, i.e., it's not a .NET-specific thing.
Oct 30 '08 #6
"Jeff Johnson" <i.***@enough.spamwrote in message
news:ez****************@TK2MSFTNGP05.phx.gbl...
>AAMOI, do you know how a C# WinForms app "suppresses" a form's taskbar
button when its ShowInTaskbar property is set to false...?

No, but since VB6 offers the same capability I'd say there's defintely a
Windows API method of doing it, i.e., it's not a .NET-specific thing.
That was an incomplete answer. Now for the second part: I recommend creating
a couple of windows, identical in all ways except for ShowInTaskbar being
true in one and false in the other and then checking out their window styles
via Spy++.
Oct 30 '08 #7
"Jeff Johnson" <i.***@enough.spamwrote in message
news:O7**************@TK2MSFTNGP05.phx.gbl...
>>AAMOI, do you know how a C# WinForms app "suppresses" a form's taskbar
button when its ShowInTaskbar property is set to false...?

No, but since VB6 offers the same capability I'd say there's defintely a
Windows API method of doing it, i.e., it's not a .NET-specific thing.

That was an incomplete answer. Now for the second part: I recommend
creating a couple of windows, identical in all ways except for
ShowInTaskbar being true in one and false in the other and then checking
out their window styles via Spy++.
Reflector shows that the ShowInTaskbar property controls a bit in a
BitVector32 instance, so I'm really willing to bet it corresponding to a
window style now. Perhaps I should just look up some window styles....

Hmmm, nothing's jumping out at me, but is might be the extended style
WS_EX_APPWINDOW. When ShowInTaskbar is true the bit in the BitVector is set
to 1, so that could corresponding to turning on this flag.
Oct 30 '08 #8
"Jeff Johnson" <i.***@enough.spamwrote in message
news:uF*************@TK2MSFTNGP05.phx.gbl...
>>>AAMOI, do you know how a C# WinForms app "suppresses" a form's taskbar
button when its ShowInTaskbar property is set to false...?

No, but since VB6 offers the same capability I'd say there's defintely a
Windows API method of doing it, i.e., it's not a .NET-specific thing.

That was an incomplete answer. Now for the second part: I recommend
creating a couple of windows, identical in all ways except for
ShowInTaskbar being true in one and false in the other and then checking
out their window styles via Spy++.

Reflector shows that the ShowInTaskbar property controls a bit in a
BitVector32 instance, so I'm really willing to bet it corresponding to a
window style now. Perhaps I should just look up some window styles....

Hmmm, nothing's jumping out at me, but is might be the extended style
WS_EX_APPWINDOW. When ShowInTaskbar is true the bit in the BitVector is
set to 1, so that could corresponding to turning on this flag.
Interesting - thanks.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 30 '08 #9


"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:u9**************@TK2MSFTNGP04.phx.gbl...
"Jeff Johnson" <i.***@enough.spamwrote in message
news:uF*************@TK2MSFTNGP05.phx.gbl...
>>>>AAMOI, do you know how a C# WinForms app "suppresses" a form's taskbar
button when its ShowInTaskbar property is set to false...?

No, but since VB6 offers the same capability I'd say there's defintely
a Windows API method of doing it, i.e., it's not a .NET-specific thing.

That was an incomplete answer. Now for the second part: I recommend
creating a couple of windows, identical in all ways except for
ShowInTaskbar being true in one and false in the other and then checking
out their window styles via Spy++.

Reflector shows that the ShowInTaskbar property controls a bit in a
BitVector32 instance, so I'm really willing to bet it corresponding to a
window style now. Perhaps I should just look up some window styles....

Hmmm, nothing's jumping out at me, but is might be the extended style
WS_EX_APPWINDOW. When ShowInTaskbar is true the bit in the BitVector is
set to 1, so that could corresponding to turning on this flag.

Interesting - thanks.

http://msdn.microsoft.com/en-us/libr...80(VS.85).aspx
WS_EX_APPWINDOW
Forces a top-level window onto the taskbar when the window is visible.
>

--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Oct 31 '08 #10
"Ben Voigt [C++ MVP]" <rb*@nospam.nospamwrote in message
news:78**********************************@microsof t.com...
http://msdn.microsoft.com/en-us/libr...80(VS.85).aspx
WS_EX_APPWINDOW
Forces a top-level window onto the taskbar when the window is visible.
Now here's the question: does the LACK of this flag always PREVENT a window
from displaying on the task bar?

What messes with me is the use of the word "force." "Force" suggests to me
that "sometimes apps MAY appear on the taskbar without this flag, but using
it ENSURES that the app will display on the taskbar." See what I mean about
the wording?
Oct 31 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Juan Garcia | last post by:
Subject says it all. Given: Window A with text field. Window B with a button (onClick opens Window C) Window C with a button (onClick I want it to modify text fields of Window A) I have...
18
by: D Witherspoon | last post by:
I developed this module, examples on the internet seem to be much longer.. Can someone explain to me why my solution doesn't work? Module modAPI Declare Function SetForegroundWindow Lib...
4
by: google | last post by:
Hi there, I've searched high and low for this, but it seems most people are looking to establish (and control) the relationship between a parent browser window and it's associated child window...
29
by: wayne | last post by:
Hey there... I'm having some problems passing url parameters with an open.window command. I'm not terribly familiar with java script but here is the code below. When executed it opens the...
8
by: Andante.in.Blue | last post by:
Hello, I have just inherited a legacy Access 97 database. While going through it, I noticed something strange... its Relationships window (the one accessed by Tools --> Relationships) is almost...
4
by: Blaine | last post by:
Does anyone know how I can hide a form from the TaskManager? I've set the ShowInTaskbar to False, but when using Alt-TAB to switch between applications, it appears as a blank icon. I can set it...
4
by: Hutch | last post by:
I also un-checked all of the check boxes in the database's Startup options menu. I then added a button to the form so that the user can close the database, and another button so that the form can...
3
by: Andrew Poulos | last post by:
There's a HTA application that's running on a local computer (not from a URL) and the user can open a new HTML window by clicking a button The first time the user clicks the button the window...
3
by: BlackShadow33p1 | last post by:
I'm trying to write a program in C++ that gets the handles of all the visible entries in the windows taskbar. The method I've used so far is to send the TB_GETBUTTON message to the taskbar. ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.