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. Problem while horizontal scrolling

Problem while horizontal scrolling

Scheduled Pinned Locked Moved C / C++ / MFC
helpgraphicsdata-structures
8 Posts 3 Posters 1 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.
  • D Offline
    D Offline
    Deepu Antony
    wrote on last edited by
    #1

    Hi everybody I am drawing a graph.The Y Axis of the graph is derived from CWnd and is attached to the left end of my view class which is derived from CSrollView. So while horizontal scrolling of my view class i want to keep the Y Axis stationary. Can anybody help me to prevent this particular portion of the view from being updated while horizontal scrolling. Thanks and regards Deepu

    N I D 3 Replies Last reply
    0
    • D Deepu Antony

      Hi everybody I am drawing a graph.The Y Axis of the graph is derived from CWnd and is attached to the left end of my view class which is derived from CSrollView. So while horizontal scrolling of my view class i want to keep the Y Axis stationary. Can anybody help me to prevent this particular portion of the view from being updated while horizontal scrolling. Thanks and regards Deepu

      N Offline
      N Offline
      Nishad S
      wrote on last edited by
      #2

      I haven't tried, but I felt that it will work. (It's a little bit complicated.) Make a region with a rectangular hole for the Y Axis window and set it to the scrollview. So you will get space to place the Y Axis window. The parent of Y Axis window should be the same of that of scrollview. Position the Y Axis window right there. Steps to make such a region can be as follows 1. Create a rect-region with size of scrollview. 2. Create another rect-region with size and position of Y Axis window. 3. Combine both regions Apply this combined region to scrollview.

      - ns ami -

      D 1 Reply Last reply
      0
      • N Nishad S

        I haven't tried, but I felt that it will work. (It's a little bit complicated.) Make a region with a rectangular hole for the Y Axis window and set it to the scrollview. So you will get space to place the Y Axis window. The parent of Y Axis window should be the same of that of scrollview. Position the Y Axis window right there. Steps to make such a region can be as follows 1. Create a rect-region with size of scrollview. 2. Create another rect-region with size and position of Y Axis window. 3. Combine both regions Apply this combined region to scrollview.

        - ns ami -

        D Offline
        D Offline
        Deepu Antony
        wrote on last edited by
        #3

        Thanks for the reply I did the same before. I am having a class CGraphicsView derived from CScrollview Then CYAxis derived from CWnd Then i am dynamically creating the CYAxis to CGraphicsView in OnCreate function. Then in OnDraw function i am displaying the CYAxis. But the problem i am facing is that while horizontal scrolling the YAxis values is getting disturbed ie is not aligned properly.

        N 1 Reply Last reply
        0
        • D Deepu Antony

          Thanks for the reply I did the same before. I am having a class CGraphicsView derived from CScrollview Then CYAxis derived from CWnd Then i am dynamically creating the CYAxis to CGraphicsView in OnCreate function. Then in OnDraw function i am displaying the CYAxis. But the problem i am facing is that while horizontal scrolling the YAxis values is getting disturbed ie is not aligned properly.

          N Offline
          N Offline
          Nishad S
          wrote on last edited by
          #4

          Can you please show some relevant code snippet of CYAxis creation, region creation and setting, and positioning of CYAxis?

          - ns ami -

          D 1 Reply Last reply
          0
          • N Nishad S

            Can you please show some relevant code snippet of CYAxis creation, region creation and setting, and positioning of CYAxis?

            - ns ami -

            D Offline
            D Offline
            Deepu Antony
            wrote on last edited by
            #5

            YAxis is created inside CGraphicsView as follwing int CGraphicsView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CScrollView::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here //CYAxis m_wndYAxis2; if (!m_wndYAxis2.Create(0,0,WS_BORDER|WS_CHILD, CRect(0,0,50,150), this, 0 )) { TRACE0("Failed to create Power Bar\n"); return -1; // fail to create } m_wndYAxis2.InitializeVariables(); return 0; } Positioning of YAxis is done inside OnDraw() function void CGraphicsView::OnDraw(CDC* pDC) { //------------------- my code --------------------------- CChildFrame* pChildFrame = NULL; pChildFrame = (CChildFrame* )this->GetActiveWindow(); CSize size = GetTotalSize(); if ( pChildFrame!=NULL ) { CRect rectFrm; pChildFrame->GetWindowRect( rectFrm ); m_wndYAxis2.SetWindowPos(&wndTop, rectFrm.left, rectFrm.top,rectFrm.right/12, size.cy, SWP_SHOWWINDOW ); } } Please help me if u get any clue.

            N 1 Reply Last reply
            0
            • D Deepu Antony

              Hi everybody I am drawing a graph.The Y Axis of the graph is derived from CWnd and is attached to the left end of my view class which is derived from CSrollView. So while horizontal scrolling of my view class i want to keep the Y Axis stationary. Can anybody help me to prevent this particular portion of the view from being updated while horizontal scrolling. Thanks and regards Deepu

              I Offline
              I Offline
              Iain Clarke Warrior Programmer
              wrote on last edited by
              #6

              Your problem has an easy solution... In your CMyScrollView::OnDraw function, just call GetScrollPosition, and add the ptScroll.x value to your drawing code for the Y scale. I might be 100% wrong and you need to subtract the ptScroll.x value instead, but you can find that out faster than I can! It won't be flicker free, but it will help. For a flicker free solution, you'll have to get more complicated. I use my own view class and handle scrolling myself, and also make a non-zero nonclient area around the edge for a scale / ruler. But that's too much for a quick forum reply! Good luck, Iain.

              Codeproject MVP for C++, I can't believe it's for my lounge posts...

              1 Reply Last reply
              0
              • D Deepu Antony

                YAxis is created inside CGraphicsView as follwing int CGraphicsView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CScrollView::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here //CYAxis m_wndYAxis2; if (!m_wndYAxis2.Create(0,0,WS_BORDER|WS_CHILD, CRect(0,0,50,150), this, 0 )) { TRACE0("Failed to create Power Bar\n"); return -1; // fail to create } m_wndYAxis2.InitializeVariables(); return 0; } Positioning of YAxis is done inside OnDraw() function void CGraphicsView::OnDraw(CDC* pDC) { //------------------- my code --------------------------- CChildFrame* pChildFrame = NULL; pChildFrame = (CChildFrame* )this->GetActiveWindow(); CSize size = GetTotalSize(); if ( pChildFrame!=NULL ) { CRect rectFrm; pChildFrame->GetWindowRect( rectFrm ); m_wndYAxis2.SetWindowPos(&wndTop, rectFrm.left, rectFrm.top,rectFrm.right/12, size.cy, SWP_SHOWWINDOW ); } } Please help me if u get any clue.

                N Offline
                N Offline
                Nishad S
                wrote on last edited by
                #7

                But you are not using a region clip as I suggest. In that case you need to create the CYAxis window with parent as scrollview's parent (Instead of 'this', you need to pass 'GetParent()'). As I said earlier my solution would be complicated. You can try for the other reply too that you got... :)

                - ns ami -

                1 Reply Last reply
                0
                • D Deepu Antony

                  Hi everybody I am drawing a graph.The Y Axis of the graph is derived from CWnd and is attached to the left end of my view class which is derived from CSrollView. So while horizontal scrolling of my view class i want to keep the Y Axis stationary. Can anybody help me to prevent this particular portion of the view from being updated while horizontal scrolling. Thanks and regards Deepu

                  D Offline
                  D Offline
                  Deepu Antony
                  wrote on last edited by
                  #8

                  Thanks Ami and Iain for your replies..I am trying in all ways possible.

                  modified on Monday, February 23, 2009 3:02 AM

                  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