0

Is it possible in a windows message handler for WM_SIZE to detect if the current size change is triggered by a user action (such as resizing by mouse or through system menu+keyboard)?

(Currently I'm setting/resetting a flag whether the resize is "because of my code" but this is quite unwieldy in some cases)


[edit] use case:
The purpose is to distinguish "the size user sets" from size changes triggered by other operations (also in control of the user).

In this particular case, I have a property sheet control where each page has a different minimum/default size.

The expected user behavior is as follows:

  • the minimum size of the sheet is no smaller than required by the current page (i.e. it changes when the page changes)
  • if the user sizes the sheet to "as small as possible" then switches to another page, it should be sized to "as small as possible for that page", too.

(informal first level usability testing - i.e. me toying around with it - has shown that this "use smalles size" is better tracked separately for X and Y)

Yes, this leads to sheet size jumping when page is changed. This is unfortunate but better than alternatives in this particular application.

In this case, Aero docking isn't supported for that wind since it's not top-level.


FWIW, having change messages fire always consistently for all controls, and having an indicator if this was triggered by a user action or programmatically ranks pretty high on my list of "essential for a UI control API".

peterchen
  • 40,917
  • 20
  • 104
  • 186
  • 2
    The system sends a [WM_ENTERSIZEMOVE](https://msdn.microsoft.com/en-us/library/windows/desktop/ms632622.aspx) message, when a sizing operation is initiated by the user. You could set a flag there (and reset it for `WM_EXITSIZEMOVE`). That way you won't have to set a flag when changing the window size through code. – IInspectable Mar 30 '15 at 13:16
  • 1
    Setting that flag is going to be a *lot* less unwieldy than trying to keep track of the numerous ways that the user can resize the window. And there is no notification at all for Aero Snap. – Hans Passant Mar 30 '15 at 13:25
  • @Hans: I'd assume that this question is about trying to implement a performance optimization (e.g. to inhibit costly updates during user-initiated resizing). A false negative would be admissible, particularly with Aero Snap, that doesn't expose **continuous** resizing. – IInspectable Mar 30 '15 at 13:37
  • My comment was directed at the OP, I didn't try to comment on your comment. I usually just try to read what it says and not infer too much. But yeah, it leans heavily towards the left of an XY question. I'll never understand why an SO user can't type more than 2 short paragraphs when he needs help. – Hans Passant Mar 30 '15 at 13:45
  • @HansPassant: I found writing more generally diminishes the attention. I've update the Q with a more detailed description of the use case. – peterchen Mar 30 '15 at 15:18
  • @IInspectable: see update, it's not just an optimization. But `ENTER/EXITSIZEMOVE` seems to work well, if you post as answer with the caveats given by Hans, I'd accept. – peterchen Mar 30 '15 at 15:19

0 Answers0