473,729 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2510
"Mark Rae [MVP]" <ma**@markNOSPA Mrae.netwrote in message
news:%2******** ********@TK2MSF TNGP05.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.publi c.win32.program mer.shell
group, so the closest thing might be microsoft.publi c.win32.program mer.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.s pamwrote in message
news:OG******** ******@TK2MSFTN GP03.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.publi c.win32.program mer.shell
group, so the closest thing might be microsoft.publi c.win32.program mer.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**@markNOSPA Mrae.netwrote in message
news:uU******** ******@TK2MSFTN GP03.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.s pamwrote in message
news:uY******** ******@TK2MSFTN GP03.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 "associatio n" 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**@markNOSPA Mrae.netwrote in message
news:e1******** ******@TK2MSFTN GP03.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.s pamwrote in message
news:ez******** ********@TK2MSF TNGP05.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.s pamwrote in message
news:O7******** ******@TK2MSFTN GP05.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.s pamwrote in message
news:uF******** *****@TK2MSFTNG P05.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
ShowInTaskba r 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**@markNOSPA Mrae.netwrote in message
news:u9******** ******@TK2MSFTN GP04.phx.gbl...
"Jeff Johnson" <i.***@enough.s pamwrote in message
news:uF******** *****@TK2MSFTNG P05.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
ShowInTaskb ar 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_APPWINDO W. 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

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

Similar topics

2
2192
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 tried storing the handle of Window A ( var winHandle = this; ) in a global variable/file ( globals.js ) and then accessing it from
18
9818
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 "user32" (ByVal hwnd As Long) As Long
4
3382
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 created with window.open. I would like to break this connection. Why? Because there is an application that I want to open in a new window, but no matter what I do it will close the window and redirect the original (parent) window to its location...
29
5021
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 window properly but does not pass the parameter. (this is part of a coldfusion template) <a href="##"
8
7435
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 empty. Now, as I ponder how a relation database could work without any relationships, I noticed that the queries of the database defined some relationships between the source tables and queries. Which leads me to the question, what is the...
4
4389
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 as a SizableToolWindow, but then I no longer have the minimize button on the caption. Is there a way to mimic a (FormBorder) sizable tool window (so it doesn't appear in the tasklist) and still show the Min, Max and Close control buttons? (Or...
4
7210
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 minimized. I made the minimize button so that when it was used, something would show-up on the taskbar and not on the desktop (above the Start button). I figured the users would get confused when they had multiple windows open and couldn't find the...
3
10257
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 opens. Any subsequent click causes this dialog, with this error, to appear: "Error: The remote server machine does not exist or is unavailable" The relevant code is
3
8747
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. Supposedly the window handle for an entry is in the dwData structure in the TBBUTTON structure but I'm having a hard time retrieving the handle from the structure correctly. It seems when I look at the data I've retrieved, it is not a handle (negative...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9281
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.