MFC error in MoveWindow and Create with large int
-
This is to document a solution with CWnd::MoveWindow and CWnd::Create when you have to position your window at a point larger than 32768 in the parent view. A little background first: I was trying to position my CmyView objects in a CScrollView object and everything worked as expected up until the point that the vertical location of the new CmyView object was going to be larger than 32768. At this point all the rest of the CmyView objects were being placed on top of themselves. The first 1800 or so CmyViews were placed in the CSrollview correctly but the last 1800 were just drawing on top of each other. After at least 3 days of trying to figure out what I was doing wrong I came to the conclusion that the MS code is wrong. I can trace the calls through ::CreateEx, ::MoveWindow but I not no nothing about debugging assembled code so that is as far as I could trace it. If you tell the window to move to a vertical position of say 40,000, this is passed all the way through what I can follow in the code through CWnd::MoveWindow. But if you get the position of the window as the next call (and adjust it for screen coordinates) you find that the actual moveWindow call didn't place the window correctly. At first I thought it was because all the calls use int as the "lowest" level type, but even an int can be larger than 32768. Workaround: I had to create a "Holder view" and place that in the CSrollView prior to placing all the CmyView objects into the CHolderView. BUT (this is the important part) the CWnd::Create call to create the Holder (which is a CWnd object) has to be large enough to hold all the CmyView object INITIALLY! If you try to resize it with MoveWindow it also fails to resize correctly. Workaround: I had to create a "Holder view" and place that in the CSrollView prior to placing all the CmyView objects into the CHolderView. BUT (this is the important part) the CWnd::Create call to create the Holder (which is a CWnd object) has to be large enough to hold all the CmyView object INITIALLY! If you try to resize it with MoveWindow it also fails to resize correctly. Chris
-
This is to document a solution with CWnd::MoveWindow and CWnd::Create when you have to position your window at a point larger than 32768 in the parent view. A little background first: I was trying to position my CmyView objects in a CScrollView object and everything worked as expected up until the point that the vertical location of the new CmyView object was going to be larger than 32768. At this point all the rest of the CmyView objects were being placed on top of themselves. The first 1800 or so CmyViews were placed in the CSrollview correctly but the last 1800 were just drawing on top of each other. After at least 3 days of trying to figure out what I was doing wrong I came to the conclusion that the MS code is wrong. I can trace the calls through ::CreateEx, ::MoveWindow but I not no nothing about debugging assembled code so that is as far as I could trace it. If you tell the window to move to a vertical position of say 40,000, this is passed all the way through what I can follow in the code through CWnd::MoveWindow. But if you get the position of the window as the next call (and adjust it for screen coordinates) you find that the actual moveWindow call didn't place the window correctly. At first I thought it was because all the calls use int as the "lowest" level type, but even an int can be larger than 32768. Workaround: I had to create a "Holder view" and place that in the CSrollView prior to placing all the CmyView objects into the CHolderView. BUT (this is the important part) the CWnd::Create call to create the Holder (which is a CWnd object) has to be large enough to hold all the CmyView object INITIALLY! If you try to resize it with MoveWindow it also fails to resize correctly. Workaround: I had to create a "Holder view" and place that in the CSrollView prior to placing all the CmyView objects into the CHolderView. BUT (this is the important part) the CWnd::Create call to create the Holder (which is a CWnd object) has to be large enough to hold all the CmyView object INITIALLY! If you try to resize it with MoveWindow it also fails to resize correctly. Chris
ChrisLang wrote:
Workaround: [...] Workaround: [...]
twice ? :wtf::omg: hum, yeah, ok... and the question is ?!:confused:
TOXCCT >>> GEII power
[toxcct][VisualCalc 2.20][VisualCalc 3.0] -
This is to document a solution with CWnd::MoveWindow and CWnd::Create when you have to position your window at a point larger than 32768 in the parent view. A little background first: I was trying to position my CmyView objects in a CScrollView object and everything worked as expected up until the point that the vertical location of the new CmyView object was going to be larger than 32768. At this point all the rest of the CmyView objects were being placed on top of themselves. The first 1800 or so CmyViews were placed in the CSrollview correctly but the last 1800 were just drawing on top of each other. After at least 3 days of trying to figure out what I was doing wrong I came to the conclusion that the MS code is wrong. I can trace the calls through ::CreateEx, ::MoveWindow but I not no nothing about debugging assembled code so that is as far as I could trace it. If you tell the window to move to a vertical position of say 40,000, this is passed all the way through what I can follow in the code through CWnd::MoveWindow. But if you get the position of the window as the next call (and adjust it for screen coordinates) you find that the actual moveWindow call didn't place the window correctly. At first I thought it was because all the calls use int as the "lowest" level type, but even an int can be larger than 32768. Workaround: I had to create a "Holder view" and place that in the CSrollView prior to placing all the CmyView objects into the CHolderView. BUT (this is the important part) the CWnd::Create call to create the Holder (which is a CWnd object) has to be large enough to hold all the CmyView object INITIALLY! If you try to resize it with MoveWindow it also fails to resize correctly. Workaround: I had to create a "Holder view" and place that in the CSrollView prior to placing all the CmyView objects into the CHolderView. BUT (this is the important part) the CWnd::Create call to create the Holder (which is a CWnd object) has to be large enough to hold all the CmyView object INITIALLY! If you try to resize it with MoveWindow it also fails to resize correctly. Chris
Wow, you must have a massive screen to be able to display that many windows and still be able to read them. I think you should rethink how you are displaying your data to your user. there is absolutely no need to keep that many windows around. One solution would be to create only as many 'CmyView's as you can display in the parent view at one time, then simply swap the data in and out depending on the position of the scroll bar. Even with the 16 bit limit of the WM_VSCROLL message that would give you a limit of 32767 views, if you used Get/SetScrollInfo() instead of WM_VSCROLL you could have a limit of 2^31 views without the problems you are encountering with more than a mere 1800 views.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04 "There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05 Within you lies the power for good - Use it!