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 6112099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:42:22+00:00 2026-05-23T14:42:22+00:00

I’m trying move a window partially off the top of the screen. However, Windows’

  • 0

I’m trying move a window partially off the top of the screen. However, Windows’ default behavior will pop it back down after I’m done moving it. Yes, I understand why this particular functionality exists; however, I still don’t want it for my window. Then I notice that I can use SetWindowPos to set a window partially off the top of the screen, and it won’t pops back down. For example SetWindowPos(...., -100, -100, ....) will set my window above the screen 100 pixels, and it will stay there.

So, instead of moving my window normally (like sending SendMessage(hwnd, WM_SYSCOMMAND, SC_MOVE | 0x0002, 0);, I want to use SetWindowPos to move. My idea is to handle WM_MOUSEMOVE and check the left mouse button is down. If the left mouse button is down, I call SetWindowPos with some math done to current mouse position, previous mouse positions, and pass it through SetWindowPos.

So far I have it working but not very well. First, if the mouse is move fast, it won’t work at all. Second, when the mouse moves slowly, the window would shakes as it moves.

Here is my WinProc:

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static int lastMouseX = 0; 
    static int lastMouseY = 0; 
    switch (message)         /* handle the messages */
    {
    case WM_LBUTTONDOWN:
        lastMouseX = LOWORD(lParam); 
        lastMouseY = HIWORD(lParam); 
        break;
    //case WM_NCMOUSEMOVE: 
    case WM_MOUSEMOVE: 
        if(wParam == MK_LBUTTON)
        {
            int currentMouseX = LOWORD(lParam); 
            int currentMouseY = HIWORD(lParam); 
            int deltaX = currentMouseX - lastMouseX; 
            int deltaY = currentMouseY - lastMouseY; 
            RECT prc; 
            GetWindowRect(hwnd, &prc);
            SetWindowPos(hwnd, NULL, prc.left + deltaX, prc.top + deltaY, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
            lastMouseX = currentMouseX; 
            lastMouseY = currentMouseY;
        }
        break; 
    case WM_DESTROY:
        PostQuitMessage (0);    /* send a WM_QUIT to the message queue */
        break;

    default:           /* for messages that we don't deal with */
        return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}

Here is the full code http://pastebin.com/9A8iV5GW

Further inspecting windows messages, I see exactly where Windows moves the window back down but I still don’t know what I need to do. I know it can be done, because I have seen it done in other apps.

<--I stop moving here with WM_LBUTTONUP -->  
<windowMessage id="514" name="WM_LBUTTONUP">
  <wParam>0x00000000</wParam>
  <lParam>0x0049009E</lParam>
  <returnValue>0x00000000</returnValue>
<-- And here is when windows moves it back down -->  
</windowMessage><windowMessage id="534" name="WM_MOVING">
  <wParam>0x00000009</wParam>
  <lParam>0x003FF220</lParam>
  <returnValue>0x00000000</returnValue>
</windowMessage><windowMessage id="70" name="WM_WINDOWPOSCHANGING">
  <wParam>0x00000000</wParam>
  <lParam>0x003FEF98</lParam>
  <returnValue>0x00000000</returnValue>
</windowMessage><windowMessage id="36" name="WM_GETMINMAXINFO">
  <wParam>0x00000000</wParam>
  <lParam>0x003FEC20</lParam>
  <returnValue>0x00000000</returnValue>
</windowMessage><windowMessage id="71" name="WM_WINDOWPOSCHANGED">
  <wParam>0x00000000</wParam>
  <lParam>0x003FEF98</lParam>
  <returnValue>0x00000000</returnValue>
</windowMessage><windowMessage id="533" name="WM_CAPTURECHANGED">
  <wParam>0x00000000</wParam>
  <lParam>0x00000000</lParam>
  <returnValue>0x00000000</returnValue>
</windowMessage><windowMessage id="70" name="WM_WINDOWPOSCHANGING">
  <wParam>0x00000000</wParam>
  <lParam>0x003FF210</lParam>
  <returnValue>0x00000000</returnValue>
</windowMessage><windowMessage id="562" name="WM_EXITSIZEMOVE">
  <wParam>0x00000000</wParam>
  <lParam>0x00000000</lParam>
  <returnValue>0x00000000</returnValue>
</windowMessage>
  • 1 1 Answer
  • 0 Views
  • 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. Editorial Team
    Editorial Team
    2026-05-23T14:42:22+00:00Added an answer on May 23, 2026 at 2:42 pm

    This works for me (designed using your captured window messages):

        case WM_ENTERSIZEMOVE:
            in_movesize_loop = true;
            inhibit_movesize_loop = false;
            break;
    
        case WM_EXITSIZEMOVE:
            in_movesize_loop = false;
            inhibit_movesize_loop = false;
            break;  
    
        case WM_CAPTURECHANGED:
            inhibit_movesize_loop = in_movesize_loop;
            break;  
    
        case WM_WINDOWPOSCHANGING:
            if (inhibit_movesize_loop) {
                WINDOWPOS* wp = reinterpret_cast<WINDOWPOS*>(lParam);
                wp->flags |= SWP_NOMOVE;
                return 0;
            }
            break;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I need a function that will clean a strings' special characters. I do NOT

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.