Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 64793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:50:44+00:00 2026-05-10T18:50:44+00:00

I have a WPF app which snaps to screen edges (I just set the

  • 0

I have a WPF app which snaps to screen edges (I just set the .Top or .Left of the window if you’re within 20 pixels of the screen edge), but I recently added some code provided by the WPF SDK Team to ‘mess’ with the window chrome, and although it’s working great (screenshot), it’s causing the ‘snapto’ to move the window unexpectedly (e.g.: it jumps to the left when it should be snapping straight down to the bottom)

I’ve narrowed it down to their handling of the WM_NCCALCSIZE … which is really odd because they basically don’t do anything, they just say they handle it, and return 0.

According to the documentation of WM_NCCALCSIZE, this should just result in the whole window being treated as client (having no non-client edge), but somehow it also means that whenever my snap-to code moves the window down to the bottom of the screen, it also moves left about 134 pixels … (moving to the other edges has similar side effects) and as long as I hold the mouse to drag it, it flickers back and forth from where it’s supposed to be. If I comment the WM_NCCALCSIZE handling out, the snap-to works the way it should (but the form doesn’t look right).

I’ve tried everything I can thing of in the WM_NCCALCSIZE handler, but I can’t stop it from jumping left … and of course, WM_NCCALCSIZE only gets called when the window size changes, so I don’t understand how it causes this in the first place!

P.S. If you want to actually see the code, it’s already on CodePlex, in two files, look for _HandleNCCalcSize and OnWindowLocationChanged

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T18:50:44+00:00Added an answer on May 10, 2026 at 6:50 pm

    The reason this happens is that handling the WM_NCCALCSIZE changes the overall size of the window … but if you’re moving the window, changing your position during WM_MOVE or WM_WINDOWPOSCHANGED (which corresponds to the WPF WindowPositionChanged event) causes another WM_NCCALCSIZE message …

    Making changes during WM_NCCALCSIZE (even just asserting that you handled the message) causes another call to WM_MOVE … which puts you into a loop where the "FROM" part of the positionchanged message stays the same (making the window "jump" from where it started to the position you adjust it to during WM_MOVE over and over as it changes back after WM_NCCALCSIZE).

    The Correct Way

    What you have to do is to obey Raymond Chen and handle WM_WINDOWPOSCHANGING instead. It happens before these other messages, and that way they do not interfere with each other!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 96k
  • Answers 97k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer to use ident_current or any of the other functions to… May 11, 2026 at 7:18 pm
  • Editorial Team
    Editorial Team added an answer This is what I ended up doing: Hashtable t =… May 11, 2026 at 7:18 pm
  • Editorial Team
    Editorial Team added an answer The best way is to use it! Write a simple… May 11, 2026 at 7:18 pm

Related Questions

Background: I have a little video playing app with a UI inspired by the
I have a WPF App which is grinding to a halt after running out
Context: I have a WPF App that uses certain unmanaged DLLs in the D:\WordAutomation\MyApp_Source\Executables\MyApp
I'm creating a WPF app and have a system tray icon with a context

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.