views:

324

answers:

2

I'm want resize window using WinAPI. I use WinAPI function

SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);

Window is resized, but window content is not redrawed. If I resize this window using mouse, content redraws. How to resize window using WinAPI with content redrawing?

+3  A: 

Make sure you don't specify SWP_NOREDRAW in the uFlags parameter. If it's not set and you still get the problem, just call UpdateWindow(hwnd) manually.

Francis Gagné
This not work. May be send to window any resize message?
Evl-ntnt
+1  A: 

By default the window is not redrawn (more precisely - not invalidated) upon resize. If you shrink the window - it won't receive the WM_PAINT at all. And if you enlarge it - the update region will only include the added area.

If the contents of the window depend on its size - the window itself must decide to invalidate itself (via a call to InvalidateRect/InvalidateRgn) upon processing WM_SIZE message.

Nevertheless you can invalidate any window at any time by calling InvalidateRect/InvalidateRgn.

valdo
This not work. May be send to window any resize message?
Evl-ntnt
You may call InvalidateRect(hWnd, NULL, TRUE); This should redraw the window (asynchronously)
valdo
I test this, no effect. Which message sends to window when them resizing by mouse?
Evl-ntnt
Well, this should help IMHO, I can't imagine why this doesn't work without seeing what really happens there.In order to cause a window redraw itself all you have to do is call InvalidateRect/InvalidateRgn. After calling one of those functions you may call UpdateWindow so that the target window will repaint itself immediately (otherwise the painting may be postponed until the message queue of the target thread becomes idle).
valdo