[Solved] SetWindowPos corrupts borders

Windows specific forum
BarryG
Addict
Addict
Posts: 3268
Joined: Thu Apr 18, 2019 8:17 am

[Solved] SetWindowPos corrupts borders

Post by BarryG »

Hi, for some windows that I move with SetWindowPos, their borders get corrupted. I'm doing this:

Code: Select all

SetWindowPos_(hWnd,0,newx,newy,origw,origh,#SWP_NOSIZE)
If I do it on the following window, then after the move the window looks like the second image. How can I stop that? Thanks.

Note: I've tried UpdateWindow_(), InvalidateRect_(), and all that sort of thing after the movement. Didn't help (or I did it wrong?).

Image

Image

BTW, I got the test window by opening a command prompt and entering: msg * test

Here's some test code - do the command prompt thing above, then run this and click the test window:

Code: Select all

Sleep_(2000)
SetWindowPos_(GetForegroundWindow_(),0,100,100,0,0,#SWP_NOSIZE)
Last edited by BarryG on Sun Apr 25, 2021 12:43 pm, edited 1 time in total.
fryquez
Enthusiast
Enthusiast
Posts: 360
Joined: Mon Dec 21, 2015 8:12 pm

Re: SetWindowPos corrupts borders

Post by fryquez »

Don't see this here, try it with #SWP_FRAMECHANGED.

Code: Select all

Sleep_(2000)
SetWindowPos_(GetForegroundWindow_(),0,100,100,0,0,#SWP_NOSIZE | #SWP_FRAMECHANGED)
BarryG
Addict
Addict
Posts: 3268
Joined: Thu Apr 18, 2019 8:17 am

Re: SetWindowPos corrupts borders

Post by BarryG »

#SWP_FRAMECHANGED didn't make any difference (still corrupt). But, thanks to you I noticed a constant named #SWP_ASYNCWINDOWPOS that isn't in my Win32.hlp file! When I use that, the borders are correct again (like my first screenshot) and not corrupted. Thanks, fryquez!

This is what fixed it:

Code: Select all

Sleep_(2000)
SetWindowPos_(GetForegroundWindow_(),0,100,100,0,0,#SWP_NOSIZE|#SWP_ASYNCWINDOWPOS)
Post Reply