views:

49

answers:

1

Hi,

I was wondering if there is a way to add (programatically, of course) an icon/button/whatever besides plain text to a window (Microsoft Windows window...)'s title bar or next to where the minimize/maximize/close buttons are. I could draw it myself and create an illusion it is a part of the window, but I wonder if in the user32 api there is such a method.

So far, I found a way to disable the minimize/maximize/close buttons but not a way to add a custom one to them. It seems strange to me.

Here is what I am trying to achieve: alt text

I have been wondering how it is done here, since drawing a button for every window using gdi/gdi+ and then detecting if it is overlapped by another window and then displaying only the non-overlapped part seems to me like an unlikely solution. Probably the button has been registered in the window class so that every window has this button. Any pointers what to do?

In addition, how do I create a button at all, assuming I DON'T have Unicode enabled. Then in the following piece of code:

HWND hwndCommandLink = CreateWindow(
L"BUTTON",  // Class; Unicode assumed.
L"",        // Text will be defined later.
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_COMMANDLINK,  // Styles.
10,         // x position. 
10,         // y position. 
100,        // Button width.
100,        // Button height.
hDlg,       // Parent window.
NULL,       // No menu.
(HINSTANCE)GetWindowLong(hDlg, GWL_HINSTANCE), 
NULL);      // Pointer not needed.
SendMessage(clHwnd, WM_SETTEXT, 0, (LPARAM)L"Command link");

SendMessage(clHwnd, BCM_SETNOTE, 0, (LPARAM)L"with note");

I have to substitute all the nice Windows constants with their long equivalent....However, when I search for them, all i get is this: http://msdn.microsoft.com/en-us/library/bb775951(v=VS.85).aspx

Any pointers?

A: 

This has been treated several times at SO. Before the advent of visual themes, this was really easy - you just draw on the title bar when told to (WM_NCPAINT) and responded to title bar events (WM_NCHITTEST, WM_NCLBUTTONDOWN, etc.). With Aero, this is a lot more difficult. But it is possible, and there are articles about it.

Andreas Rejbrand
Any pointers means actually a link or a piece of code I can get to. Of course it has been treated in the SO. I've sampled a lot of code but it still won't do what I want in both Vista and XP. In addition, as I am using Java Native Access, I am troubled by some other problems as well, like finding a way to override some stuff. So, again, any pointers ?
baba