I have a WPF application that snaps to the edges of the screen (I just installed a .Top or .Left window if you are within 20 pixels from the edge of the screen), but recently I added the code provided by the WPF SDK command to "mess up" the window chrome, and although it works fine ( screenshot ), which causes snapto to unexpectedly move the window (for example: it jumps to the left when it needs to be attached to the bottom)
I narrowed it down to processing WM_NCCALCSIZE ... which is really strange because they basically do nothing, they just say that they are processing it, and return 0.
According to the WM_NCCALCSIZE documentation, this should simply cause the whole window to be treated as a client (without an edge without a client), but somehow it also means that whenever my anchor code moves the window down the screen, it also moves to the left about 134 pixels ... (moving to other edges has similar side effects), and while I hold the mouse to drag it, it flickers back and forth from where it should be. If I comment on the processing of WM_NCCALCSIZE, then the binding will work as it should (but the form does not look right).
I tried everything I could in the WM_NCCALCSIZE handler, but I canβt stop it from jumping to the left ... and, of course, WM_NCCALCSIZE is called only when the window is resized, so I donβt understand how it causes this in the first place!
PS If you really want to see the code, it is already on CodePlex , in two files, look for _ HandleNCCalcSize and OnWindowLocationChanged
source share