How to draw custom button in Window Titlebar with Windows Forms?

前端 未结 3 1947
礼貌的吻别
礼貌的吻别 2020-11-30 06:28

How do you draw a custom button next to the minimize, maximize and close buttons within the Titlebar of the Form?

I know you need to use Win32 API calls and override

3条回答
  •  臣服心动
    2020-11-30 06:50

    Drawing seems to be the easy part, the following will do that:

    [Edit: Code removed, see my other answer]

    The real problem is changing the state and detecting clicks on the button... for that you'll need to hook into the global message handler for the program, .NET seems to hide the mouse events for a form while not in the actual container areas (ie. mouse moves and clicks on the title bar). I'm looking for info on that, found it now, I'm working on it, shouldn't be too hard... If we can figure out what these messages are actually passing.

提交回复
热议问题