Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to create a view larger than Max Int

How to create a view larger than Max Int

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    ChrisLang
    wrote on last edited by
    #1

    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

    G 1 Reply Last reply
    0
    • C ChrisLang

      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

      G Offline
      G Offline
      Gary R Wheeler
      wrote on last edited by
      #2

      In your WM_HSCROLL handler, call GetScrollInfo instead of using the values passed directly to the handler. This lets you circumvent the 16-bit limitation in the WM_HSCROLL message.

      ChrisLang wrote:

      CWnd is limited to CRect which only handles int's

      CRect is based on RECT, 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")]

      C 1 Reply Last reply
      0
      • G Gary R Wheeler

        In your WM_HSCROLL handler, call GetScrollInfo instead of using the values passed directly to the handler. This lets you circumvent the 16-bit limitation in the WM_HSCROLL message.

        ChrisLang wrote:

        CWnd is limited to CRect which only handles int's

        CRect is based on RECT, 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")]

        C Offline
        C Offline
        ChrisLang
        wrote on last edited by
        #3

        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

        G 1 Reply Last reply
        0
        • C ChrisLang

          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

          G Offline
          G Offline
          Gary R Wheeler
          wrote on last edited by
          #4

          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")]

          C 1 Reply Last reply
          0
          • G Gary R Wheeler

            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")]

            C Offline
            C Offline
            ChrisLang
            wrote on last edited by
            #5

            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

            C 1 Reply Last reply
            0
            • C ChrisLang

              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

              C Offline
              C Offline
              ChrisLang
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups