WinAPI C++: Reprogramming Window Resize

后端 未结 5 1825
無奈伤痛
無奈伤痛 2020-12-30 16:15

I have a window, and I want to implement the borders as resizing borders, like any other window. Taking in suggestions from comments and answers, I have rewritten my code. F

5条回答
  •  一整个雨季
    2020-12-30 16:57

    This kind of code gets ugly in a hurry, you are changing the relative mouse position by changing the client area position. That requires you to update the *track_start* variable when you ignore the mouse move when the window gets too small. Not doing so produces an, ahem, interesting effect with the window jumping back and forth. Yes, "wriggles".

    Just don't do it this way, the feature you are looking for is already implemented. Write a message handler for WM_GETMINMAXINFO. Call DefWindowProc() first, then override the MINMAXINFO.ptMinTrackSize value. If the intent is to implement corner or edge dragging on a borderless window then implement a message handler for WM_NCHITTEST. That also permits implementing your BORDERWIDTH. Same recipe, call DefWindowProc() first, override the return value when appropriate.

提交回复
热议问题