Reputation: 11217
I have seen several tools adding a custom button and/or drawing on the title bar of all windows of all applications in Windows. How is that done? Extra points for an example in Delphi.
EDIT: I found something for dotNET that does this: http://www.thecodeking.co.uk/2007/09/adding-caption-buttons-to-non-client.html#.VdmioEDenqQ
Upvotes: 8
Views: 1540
Reputation: 13580
I haven't done this, so the following is what I would investigate if I were to try:
GetWindowLong
with GWL_STYLE
looking for WS_CAPTION
. The same call will also let you see the type of caption / frame, which you can combine with GetSystemMetrics
with, eg, SM_CYDLGFRAME
to figure out the right size for your button on this specific window's title bar.WS_EX_NOACTIVATE
window flag, something like: SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) or
WS_EX_NOACTIVATE
)
.EVENT_SYSTEM_MINIMIZESTART
and EVENT_SYSTEM_MINIMIZEEND
. This will allow you to keep track of all windows moving around onscreen, such that you can adjust the button-window position if necessary.That gives you a window which you can paint as a button (and respond to clicks etc), that visually is "attached" to other windows so it stays in the same place as the user drags the title bar, minimizes or maximises the app, etc, and that is in your own process without cross-process problems.
Upvotes: 3
Reputation: 937
How I see this job:
Upvotes: 5