Problem while horizontal scrolling
-
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
-
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 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 -
-
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 -
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.
-
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.
-
Can you please show some relevant code snippet of CYAxis creation, region creation and setting, and positioning of CYAxis?
- ns ami -
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.
-
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
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...
-
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.
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 -
-
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
Thanks Ami and Iain for your replies..I am trying in all ways possible.
modified on Monday, February 23, 2009 3:02 AM