How to create a view larger than Max Int
-
In my application I have a scroll view that I would like to insert other views. It all works wonderfully until the number of "other view" requires that the horizontal limit of the scroll view is exceeded (32768). At that point all any addtional other views are not placed in the scroll view correctly. I can resize the scroll view to a long int, but CWnd is limited to CRect which only handles int's. If anyone has any information it would be great. I'm using MM_TEXT as the map mode. Chris
-
In my application I have a scroll view that I would like to insert other views. It all works wonderfully until the number of "other view" requires that the horizontal limit of the scroll view is exceeded (32768). At that point all any addtional other views are not placed in the scroll view correctly. I can resize the scroll view to a long int, but CWnd is limited to CRect which only handles int's. If anyone has any information it would be great. I'm using MM_TEXT as the map mode. Chris
In your
WM_HSCROLL
handler, callGetScrollInfo
instead of using the values passed directly to the handler. This lets you circumvent the 16-bit limitation in theWM_HSCROLL
message.ChrisLang wrote:
CWnd is limited to CRect which only handles int's
CRect
is based onRECT
, which supports 32 bit position values.
Software Zen:
delete this; // [Fold With Us!](http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx)[[^](http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx "New Window")]
-
In your
WM_HSCROLL
handler, callGetScrollInfo
instead of using the values passed directly to the handler. This lets you circumvent the 16-bit limitation in theWM_HSCROLL
message.ChrisLang wrote:
CWnd is limited to CRect which only handles int's
CRect
is based onRECT
, which supports 32 bit position values.
Software Zen:
delete this; // [Fold With Us!](http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx)[[^](http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx "New Window")]
Gary, Thank you for your response. The problems stems from actually creating the view. I call new CmyView and then call CREATE for the CmyView object which is subclassed from CWnd. In one of the overridden methods of CWnd::Create you can specify the x and y position of the view. Initially I just use, 0, 0 for x and y. Then after reading more information from the file (CmyView is reading the file to create the window from the values in the file) I call the essentially call CWnd::MoveWindow (CmyView does not override this method of CWnd). Although the compiler allows me to actually pass in a number larger than 32768, the new view is placed at a value less than 32768. The scroll bar and displaying the correct portion of the scroll window is working fine. The problem is all CmyView objects which occur after 32768, are being drawn on top of each other. I had a work around by adding all CMyView into another layer and then placing that layer in the CScrollView. Basically what I was doing was creating 2 CWnd objects call them CMiddleView objects and making the height of the intial CMiddleView object as near 32768 as possible (if adding another CmyView made the bottom of the initial CMiddleView over 32768 then I add it to the second CMiddleView object). Next I'd position top the second CMiddleView at bottom of the initial view. Like I said the scroll view worked wonderfully and I could scroll basically 2*32768. But then the customer had MORE data, and now I need to postion CmyViews from 0 to somewhere up around 85000. Again, I'm not getting a compiler errors, but the CWnd derived objects are not being positioned correctly if the MoveWindow method is called with anything over 32768. Chris
-
Gary, Thank you for your response. The problems stems from actually creating the view. I call new CmyView and then call CREATE for the CmyView object which is subclassed from CWnd. In one of the overridden methods of CWnd::Create you can specify the x and y position of the view. Initially I just use, 0, 0 for x and y. Then after reading more information from the file (CmyView is reading the file to create the window from the values in the file) I call the essentially call CWnd::MoveWindow (CmyView does not override this method of CWnd). Although the compiler allows me to actually pass in a number larger than 32768, the new view is placed at a value less than 32768. The scroll bar and displaying the correct portion of the scroll window is working fine. The problem is all CmyView objects which occur after 32768, are being drawn on top of each other. I had a work around by adding all CMyView into another layer and then placing that layer in the CScrollView. Basically what I was doing was creating 2 CWnd objects call them CMiddleView objects and making the height of the intial CMiddleView object as near 32768 as possible (if adding another CmyView made the bottom of the initial CMiddleView over 32768 then I add it to the second CMiddleView object). Next I'd position top the second CMiddleView at bottom of the initial view. Like I said the scroll view worked wonderfully and I could scroll basically 2*32768. But then the customer had MORE data, and now I need to postion CmyViews from 0 to somewhere up around 85000. Again, I'm not getting a compiler errors, but the CWnd derived objects are not being positioned correctly if the MoveWindow method is called with anything over 32768. Chris
Chris - You might try a different mapping mode. It could get your scaling down to positions in the 0-32767 range. Unfortunately, I have a feeling you may need to re-architect how you're handling your views. Sorry I couldn't be more help; good luck.
Software Zen:
delete this; // [Fold With Us!](http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx)[[^](http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx "New Window")]
-
Chris - You might try a different mapping mode. It could get your scaling down to positions in the 0-32767 range. Unfortunately, I have a feeling you may need to re-architect how you're handling your views. Sorry I couldn't be more help; good luck.
Software Zen:
delete this; // [Fold With Us!](http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx)[[^](http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx "New Window")]
Gary, I thought about using a different mapping mode intitially but because the other mapping modes are "smaller" the actual placement on the screen is "larger" (i.e. 1 pixel in MM_TEXT is at least the larger than 1 in any of the other 4 modes). I'll continue to plug away at the problem and when I figure it out I'll post something because I'm certain that I'm not the first person that has had to deal with this. Chris
-
Gary, I thought about using a different mapping mode intitially but because the other mapping modes are "smaller" the actual placement on the screen is "larger" (i.e. 1 pixel in MM_TEXT is at least the larger than 1 in any of the other 4 modes). I'll continue to plug away at the problem and when I figure it out I'll post something because I'm certain that I'm not the first person that has had to deal with this. Chris
The answer seems to be that with my current versions (I down load updates regularly so I don't think the problem has been address just yet) that a CWnd object CANNOT handle MoveWindow and a value larger than 32768 (in a rect or specified as just integers). The code compiles but the window is not moved or resized as specified in the MSDN documentation. For me the solution was to create a new view of type CWnd (call it CHolderView) and place it in the CScrollView and then place the CmyView objects into the CHolderView. The key is to make the CHolderView initially large enough to hold all my CmyView objects. If you try to resize the CHolderView you can't make it bigger than 32768 after it is created. I'm also going to post this solution as its own message so others might be able to see it without having to follow this thread. Thanks again Gary for your attempts at solving this dilemma. Chris