|
Hi Stuart,
I using MoveTo and LineTo functions in OnPaint only... i have written remaining code in OnInitDialog. becuase i want to move the line across the images.
but still i am getting same problem..
Any clue regarding this..?
Thanks
Venkatesh.
|
|
|
|
|
As I said, you need to offset the endpoints of the line exactly the same as you offset the rectangles into which you blitted the images.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi Stuart,
I am using below code snippet in OnPaint method..
CRect rcLine1(baseSize_);
rcLine1.bottom /= 2;
rcLine1.SubtractRect(baseSize_, rcLine1);
rcLine1.OffsetRect(-offset_);
rcLine1.left += 15;
rcLine1.right = rcLine1.left;
rcLine1.top -= 700;
rcLine1.bottom -= 1300;
but still i am facing same problem...? kindly please look into this once..
Thanks
Venkatesh.
|
|
|
|
|
But you've not said what co-ordinates you're drawing the line with.
Or where you're trying to draw the line.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi Stuart,
I am using below code snippet in OnPaint method..
CRect rcLine1(baseSize_);
rcLine1.bottom /= 2;
rcLine1.SubtractRect(baseSize_, rcLine1);
rcLine1.OffsetRect(-offset_);
rcLine1.left += 15;
rcLine1.right = rcLine1.left;
rcLine1.top -= 700;
rcLine1.bottom -= 1300;
dc.MoveTo(rcLine1.left,rcLine1.right);
dc.LineTo(rcLine1.top,rcLine1.bottom);
this is how i am trying to draw the line..
still i am facing same problem...?
Thanks
Venkatesh
|
|
|
|
|
Your co-ordinate use looks messed up.
You've got MoveTo(left, right); followed by LineTo(top, bottom); . That just doesn't seem right.
I added a horizontal line between two images with
dc.MoveTo(rcImage1.left+15, rcImage1.bottom);
dc.MoveTo(rcImage1.right-15, rcImage1.bottom);
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi Stuart,
Thanks for your help, I am able to draw veritcal line successfully across the images, we have given static pixels information for drawing a line right..? but now i want to move line across the images whenever i have clicked on button..
Can you please tell me how can i achive this..?
Thanks
Venkatesh.
|
|
|
|
|
Hi Stuart,
I able to draw vertical line.. thanks for your help..
Thank you so much..
Thanks
Venki
|
|
|
|
|
Hi Stuart,
Can you please help me regarding line drawing.. I want to draw line with the slider thumb positions.
I am using below code snippet for drawing line..
GetClientRect( &deflatedClientRect );
deflatedClientRect.DeflateRect( TB_WIDTH, TB_WIDTH );
slider_bar1.GetThumbRect( &thumbRect );
slider_bar1.ClientToScreen( &thumbRect );
ScreenToClient(&thumbRect);
ptStart.x = thumbRect.CenterPoint().x;
ptStart.y = TB_WIDTH;
ptEnd.x = ptStart.x;
ptEnd.y = deflatedClientRect.bottom;
using this code i will get the slider bar thumb position in terms of pixels, so using MoveTo and LineTo funtions i am drawing line..
but here i am not offsetting the pixels, so the line is getting erasing while moving scroll bar down..
Can you please help me regarding this.. please kindly give me reply as i have to deliver this app by tomorro... please
thanks in advance...
|
|
|
|
|
venki502 wrote: but here i am not offsetting the pixels, so the line is getting erasing while moving scroll bar down
Ummm - so what behaviour are you trying to achieve?
Offsetting ptSDtart and ptEnd is easy enough....
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi Stuart,
Thanks responding on this.. actually i have two horizontal sliders in between them i need to draw vertical line..
so using that code snippet i am able to get starting position of the top slider,
so i am using that..actually i also want to move that line along with slider positions... so that's the reason i am using that..
can you please tell me how can i do that..
thanks in advance..
|
|
|
|
|
Seems pretty obvious to me that you need to get the thumb positions of the two sliders and draw between them:
slider_bar1.GetThumbRect( &thumbRect1 );
slider_bar1.ClientToScreen( &thumbRect1 );
ScreenToClient(&thumbRect1);
slider_bar2.GetThumbRect( &thumbRect2 );
slider_bar2.ClientToScreen( &thumbRect2 );
ScreenToClient(&thumbRect2);
ptStart.x = thumbRect1.CenterPoint().x;
ptStart.y = thumbRect1.bottom;
ptEnd.x = thumbRect2.CenterPoint().x;
ptEnd.y = thumbRect2.top;
?
[edit] changed slider_bar1 to slider_bar2 when manipulating thumbRect2 [/edit]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Okay, we don't need to offset the pixels is it..? do we get the vertical scroll proble here..?
i will check and i will update you..
Thanks in advance
|
|
|
|
|
venki502 wrote: we don't need to offset the pixels is it..?
No, you don't need to offset, as the line position is calculated using rectangles derived from child controls, which are correctly adjusted for the scroll position.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi stuart,
No the line is getting erasing.... i did the same thing whatever u have posted in the previous thread..
when i move vertical scroll bar down , the line is getting erasing..
For your information i have added that code in OnPaint function..
can you please tell me where i am doing wrong..?
thanks in advance..
modified on Thursday, February 19, 2009 1:23 PM
|
|
|
|
|
No idea - I implemented a line drawing thing, it worked fine.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi Stuart,
I am using below code snippet :
GetClientRect( &deflatedClientRect );
deflatedClientRect.DeflateRect( TB_WIDTH, TB_WIDTH );
slider_bar1.GetThumbRect( &thumbRect1);
slider_bar1.ClientToScreen( &thumbRect1);
ScreenToClient(&thumbRect1);
m_bottom_slider_control.GetThumbRect(&thumbRect2);
m_bottom_slider_control.ClientToScreen(&thumbRect2);
ScreenToClient(&thumbRect2);
ptStart.x = thumbRect1.CenterPoint().x;
ptStart.y = thumbRect1.bottom;
ptEnd.x = thumbRect2.CenterPoint().x;
ptEnd.y = thumbRect2.bottom;
x1 = ptStart.x; y1 = ptStart.y; x2 = ptEnd.x; y2 = ptEnd.y;
int nOldmode=dc.SetROP2(R2_NOTXORPEN);
dc.MoveTo(old_x1,old_y1);
dc.LineTo(old_x2,old_y2);
dc.MoveTo(x1,y1);
dc.LineTo(x2,y2);
old_x1 = x1;
old_y1 = y1;
old_x2 = x2;
old_y2 = y2;
I am writing below code in OnPaint function, when i moved vertical scroll bar down it is getting erasing ..
please tell me where i am going wrong..?
thanks in advance...
|
|
|
|
|
Don't know - can't see anything wrong with that.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
r u able to keep the line while verical bar moving.. with your code...? if so can you please send me the code total code snippet, so that i can get some thing..
|
|
|
|
|
Can't right now - the code's at work, I'm not, but I'll post it when I'm at work.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
OK thanks stuart i will be waiting for your response.
|
|
|
|
|
Here's the entirety of my OnPaint code. image1_ and image2_ are both member variables of type CImage . baseSize_ (also a member variable) is the initial size of the dialog. offset_ (also a member variable) is a CPoint holding the offset from the top-left point of the area on which I draw to the top-left of the visible area (i.e. the offset due to scrolling). slider_ is a member variable of type CSliderCtrl .
PAINTSTRUCT ps;
CDC* paintDC = BeginPaint(&ps);
CRect rcImage1(baseSize_);
rcImage1.bottom /= 2;
CRect rcImage2;
rcImage2.SubtractRect(baseSize_, rcImage1);
rcImage1.right -=100;
rcImage2.right -=100;
rcImage1.OffsetRect(-offset_);
rcImage2.OffsetRect(-offset_);
image1_.StretchBlt(*paintDC, rcImage1, SRCCOPY);
image2_.StretchBlt(*paintDC, rcImage2, SRCCOPY);
CPen redPen(PS_SOLID|PS_GEOMETRIC, 2, RGB(0xff, 0, 0));
CPen* oldPen = paintDC->SelectObject(&redPen);
CRect rcThumb;
slider_.GetThumbRect(&rcThumb);
slider_.MapWindowPoints(this, &rcThumb);
CPoint start(rcThumb.CenterPoint().x, rcThumb.bottom);
CPoint end(rcThumb.CenterPoint().x, rcImage2.bottom);
paintDC->MoveTo(start);
paintDC->LineTo(end);
paintDC->SelectObject(oldPen);
EndPaint(&ps);
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi Start,
based on your code snippet i came to know that i did small mistake in my code..., now i am able to get that.. but when i move scroll down the previous line is not getting erasing.. the previous line is still appearing..,
and one more thing.. when i move vertical bar scroll very down, then the line is also getting drawing on entire window..
Can you please help me regarding this..?
Thanks in advance..
|
|
|
|
|
Hi Stuart,
I got strucked in one place, for further move i need your help.
I am able to draw line in between two sliders with the help of your code, that's fine it is working fine. But when i move vertical scroll bar down I am getting the values of thubmRect are negative values.
So i am getting start and end points are also negative values.
that's the reason it is not able to erase previous line when i move vertical scroll bar down.
Can you please help me regarding this..?
Thanks in advance..
Your help will be appriciated..........
|
|
|
|
|
Well - negative co-ordinates say to me that the slider whose thumb you're retrieving the position of is outside the parent window's client area. That implies either that a) the line you're trying to erases is not in a visible area of the screen, or b) you're doing your calculations incorrectly.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|