Draw Custom Buttons on Windows Vista/7 Aero Titlebar

后端 未结 3 1364
暗喜
暗喜 2020-12-14 23:26

I found this question on StackOverflow. Basically, the user wanted to draw custom buttons on the titlebar.

I tried the code and realised it works in vista/7 only whe

3条回答
  •  旧时难觅i
    2020-12-15 00:08

    I did some research into this as I implemented this too in my own multi-monitor solution. The way DisplayFusion and TeamViewer implemented this is overlaying a custom form over the desired window containing the buttons. You can use Spy++ to confirm this.

    This is the general idea:

    1. Write a DLL hook for getting notified when a window is created, removed, activated, repositioned or resized.
    2. Make a transparant form using transparancy key or using this alpha-PNG and GDI+ solution and simulate the button(s) by painting it your own.
    3. On window creation/removal you show/hide your titlebarbutton form for the desired window(s).
    4. On window resize/reposition messages you realign your titlebarbutton form.
    5. On window activation you set the Z position of the window so that it is on top of the desired window.

    Getting and setting the Z position through the GetWindow and SetWindowPos API's.
    Be aware that the DLL must be written in a native language. However you van use something like this to work around that problem: Using Window Messages to Implement Global System Hooks in C#

    And here is my result:

    enter image description here

提交回复
热议问题