开发者

How to add a custom button to windows' minimize/maximize/close (x)

开发者 https://www.devze.com 2023-01-22 08:07 出处:网络
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/ma

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:

How to add a custom button to windows' minimize/maximize/close (x)

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 lon开发者_运维问答g 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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号