MoveWindow Exception in x64 but not in x86

Posted on 2011-10-12
Last Modified: 2012-05-12
I have a program that builds and runs fine under Visual Studio 2010 on Windows Server 2008 (32 bit). However, when I compile it for 64 bit, it fails on MoveWindow(). Here's a snippet of the code:

      // Set the size
      if(iWinTop < 0)
   = 0;
   = iWinTop;

      if(iWinLeft < 0)
            rectWindow.left = 0;
            rectWindow.left = iWinLeft;

      if(iWinBottom < 0)
            rectWindow.bottom += iWinTop;
            rectWindow.bottom = iWinBottom;

      if(iWinRight < 0)
            rectWindow.right  += iWinLeft;
            rectWindow.right = iWinRight;

      // Place the window
      MoveWindow(&rectWindow, TRUE);

The error that is returned is:
"Unhandled exception at 0x3fac6760 in Myprog.exe 0xC000041D: An unhandled exception was encountered during a user callback."
Question by:goondoo27
    LVL 8

    Expert Comment

    Somewhere I read that, "adding the linker setting: /SECTION:.rsrc,rw" will resolve the problem.
    Can you also try it and see if that solves your problem?
    LVL 8

    Accepted Solution

    LVL 8

    Expert Comment

    If your problem is not solved with the above suggestions, try to disable hardware acceleration in Visual Studio. You can look at this page regarding how to do that:

    Also, somebody has seen that the problem occurs when Aero effects are turned on. Try to turn off Aero effects and check.

    Author Closing Comment

    ssnkumar, thanks for all of the suggestions. It turns out that the problem was in a call back function:


    In this function I was using the routine PtrToLong(SizingProc) which was stripping the upper 32 bits from the 64 bit handle. Instead of that routine I used: reinterpret_cast<LONG_PTR>(SizigProc), and it works great on both 32 bit and 64 bit OSs.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
    This tutorial is posted by Aaron Wojnowski, administrator at  To view more iPhone tutorials, visit This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
    The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
    Video by: Grant
    The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now