[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

MoveWindow Exception in x64 but not in x86

Posted on 2011-10-12
4
Medium Priority
?
1,182 Views
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)
            rectWindow.top = 0;
      else
            rectWindow.top = iWinTop;

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

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

      if(iWinRight < 0)
            rectWindow.right  += iWinLeft;
      else
            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."
0
Comment
Question by:goondoo27
  • 3
4 Comments
 
LVL 8

Expert Comment

by:ssnkumar
ID: 36960047
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?
0
 
LVL 8

Accepted Solution

by:
ssnkumar earned 2000 total points
ID: 36960060
0
 
LVL 8

Expert Comment

by:ssnkumar
ID: 36960076
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: http://support.microsoft.com/kb/2023207

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

Author Closing Comment

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

static LRESULT CALLBACK SizingProc(HWND, UINT, WPARAM, LPARAM);

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.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
Suggested Courses

830 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