-1

I've spent many hours on google and haven't found any relevent results on this particular subject.

I have an application I am wanting to be minimized when the user clicks on it in the taskbar (if it's not already minimized). The problem seems to be related to the fact the window is borderless. When I set it to have a border, it minimizes just fine when clicking it in the taskbar, without any code intervention. But I need the window borderless because I'm making a "custom border" using the client area.

tl;dr how do I check if the current application is being clicked in the taskbar?

Many thanks! Samuel

  • 2
    Wrong question. You are interested in knowing, that your window should minimize (or why it doesn't minimize automatically), but are asking about your solution instead. That's called the [XY problem](https://meta.stackexchange.com/q/66377/205381). – IInspectable Jun 02 '17 at 15:50
  • Clicking on the Taskbar button sends normal `WM_SYSCOMMAND` notifications to the window, like `SC_MINIMIZE` and `SC_RESTORE`. The border (or lack of one) should not affect that. Is your code handling those messages correctly when you remove the border? – Remy Lebeau Jun 02 '17 at 18:41
  • Not sure why I got negative two reputation from this. It's a perfectly valid question. Is there no place on the internet I'm not attacked by trolls? Well, at least I got my question answered and got my application to minimize. That's what's important. –  Jun 03 '17 at 00:13
  • First comment explains, why this is **not** a *"perfectly valid question"*. It's asking about your solution rather than your problem. And while the answer solves *your* issue, it doesn't answer the question that was asked. It's not the answer, that's at fault, though, but your question, hence the down-votes. – IInspectable Jun 03 '17 at 08:23

1 Answers1

3

There is no need to tinker with the taskbar.

Just make sure you have the WS_MINIMIZEBOX|WS_MAXIMIZEBOX styles set for your window. Otherwise your window won't handle WM_SYSCOMMAND with a wParam of SC_MINIMIZE and SC_RESTORE.

Some resource editors like the one in Visual Studio make it impossible to set WS_MINIMIZEBOX|WS_MAXIMIZEBOX when you remove the standard window border. You may programmatically add the styles back like this:

DWORD style = GetWindowLong( hwnd, GWL_STYLE ); 
SetWindowLong( hwnd, GWL_STYLE, style | WS_MINIMIZEBOX | WS_MAXIMIZEBOX );
zett42
  • 25,437
  • 3
  • 35
  • 72