Click here to Skip to main content
16,020,315 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Need help on how to create image on child window and have to move along with vertical scroll bar to my dialog box Pin
John50219-Feb-09 9:18
John50219-Feb-09 9:18 
GeneralRe: Need help on how to create image on child window and have to move along with vertical scroll bar to my dialog box Pin
Stuart Dootson19-Feb-09 9:59
professionalStuart Dootson19-Feb-09 9:59 
GeneralRe: Need help on how to create image on child window and have to move along with vertical scroll bar to my dialog box Pin
John50219-Feb-09 10:10
John50219-Feb-09 10:10 
GeneralRe: Need help on how to create image on child window and have to move along with vertical scroll bar to my dialog box Pin
Stuart Dootson20-Feb-09 2:17
professionalStuart Dootson20-Feb-09 2:17 
GeneralRe: Need help on how to create image on child window and have to move along with vertical scroll bar to my dialog box Pin
John50222-Feb-09 1:32
John50222-Feb-09 1:32 
GeneralRe: Need help on how to create image on child window and have to move along with vertical scroll bar to my dialog box Pin
John5021-Mar-09 19:07
John5021-Mar-09 19:07 
GeneralRe: Need help on how to create image on child window and have to move along with vertical scroll bar to my dialog box Pin
Stuart Dootson1-Mar-09 20:56
professionalStuart Dootson1-Mar-09 20:56 
GeneralRe: Need help on how to create image on child window and have to move along with vertical scroll bar to my dialog box Pin
John5021-Mar-09 21:58
John5021-Mar-09 21:58 
OnVScroll function i have written the following code snippet.
SCROLLINFO si = { sizeof(si), 0 };
GetScrollInfo(SB_VERT, &si, SIF_ALL);
CPoint newOffset(offset_);

switch (nSBCode)
{
case SB_LINEDOWN:
newOffset.y += si.nPage / 10;
break;
case SB_LINEUP:
newOffset.y -= si.nPage / 10;
break;
case SB_PAGEDOWN:
newOffset.y += si.nPage;
break;
case SB_THUMBTRACK:
case SB_THUMBPOSITION:
{
newOffset.y = nPos;
break;
}
case SB_PAGEUP:
{
newOffset.y -= si.nPage;
}
break;
default:
return;
}

LogMessage(__FILE__,__LINE__,TRACE_LOG_LEVEL,"VSroll bar clicked");
CRect currSize;
GetClientRect(&currSize);
const int maxOffset = baseSize_.Height() - currSize.Height();
newOffset.y = max(min(newOffset.y, maxOffset), 0);

SetScrollPos(SB_VERT,newOffset.y,TRUE);
ScrollWindow(0,offset_.y-newOffset.y);
offset_ = newOffset;

LogMessage(__FILE__,__LINE__,TRACE_LOG_LEVEL,"x = %d, y = %d",newOffset.x,newOffset.y);

CDialog::OnVScroll(nSBCode, nPos, pScrollBar);

And From OnTimer Function i am calling DrawLine function, that function contains the following code snippet:
CRect rect;
GetClientRect(&rect);
slider_bar1.GetThumbRect(&rcThumb1);
slider_bar1.MapWindowPoints(this, &rcThumb1);
m_bottom_slider_control.GetThumbRect(&rcThumb2);
m_bottom_slider_control.MapWindowPoints(this, &rcThumb2);
start.x = rcThumb1.CenterPoint().x;
start.y = rcThumb1.bottom;
if (start.y<0)
{
start.y = 0;
}
end.x = rcThumb1.CenterPoint().x;
end.y = rcThumb2.bottom;
if (end.y > rect.Height())
{
end.y = rect.Height();
}

CRect rc;
rc.left = start.x-10;
if (start.y >= 10)
rc.top = start.y-10;
else
rc.top = 0;
rc.right = end.x+10;
rc.bottom = end.y+10;

And OnPaint Contains the following code snippet:
int nOldmode=dc.SetROP2(R2_NOTXORPEN);
dc.MoveTo(old_x1,old_y1);
dc.LineTo(old_x2,old_y2);
dc.MoveTo(start);
dc.LineTo(end);
old_x1 = start.x;
old_y1 = start.y;
old_x2 = end.x;
old_y2 = end.y;

Still i am getting negative values,
Can you please see the code and let me know where i am going wrong..?

Thanks in advance..
GeneralRe: Need help on how to create image on child window and have to move along with vertical scroll bar to my dialog box Pin
Stuart Dootson1-Mar-09 22:06
professionalStuart Dootson1-Mar-09 22:06 
GeneralRe: Need help on how to create image on child window and have to move along with vertical scroll bar to my dialog box Pin
John5021-Mar-09 22:28
John5021-Mar-09 22:28 
GeneralRe: Need help on how to create image on child window and have to move along with vertical scroll bar to my dialog box Pin
Stuart Dootson1-Mar-09 23:14
professionalStuart Dootson1-Mar-09 23:14 
GeneralRe: Need help on how to create image on child window and have to move along with vertical scroll bar to my dialog box Pin
John5022-Mar-09 0:13
John5022-Mar-09 0:13 
GeneralRe: Need help on how to create image on child window and have to move along with vertical scroll bar to my dialog box Pin
Stuart Dootson2-Mar-09 0:39
professionalStuart Dootson2-Mar-09 0:39 
GeneralRe: Need help on how to create image on child window and have to move along with vertical scroll bar to my dialog box Pin
John50212-Feb-09 1:13
John50212-Feb-09 1:13 
QuestionHeap corruption probelm when i try to return std::string from function in dll Pin
dhpatil15-Feb-09 1:54
dhpatil15-Feb-09 1:54 
AnswerRe: Heap corruption probelm when i try to return std::string from function in dll Pin
Stuart Dootson5-Feb-09 2:47
professionalStuart Dootson5-Feb-09 2:47 
QuestionHow to execute other programs at the given time? Pin
fantasy12155-Feb-09 1:46
fantasy12155-Feb-09 1:46 
QuestionRe: How to execute other programs at the given time? Pin
CPallini5-Feb-09 2:02
mveCPallini5-Feb-09 2:02 
GeneralRe: How to execute other programs at the given time? Pin
fantasy12155-Feb-09 2:17
fantasy12155-Feb-09 2:17 
GeneralRe: How to execute other programs at the given time? [modified] Pin
CPallini5-Feb-09 2:39
mveCPallini5-Feb-09 2:39 
GeneralRe: How to execute other programs at the given time? Pin
Stuart Dootson5-Feb-09 2:42
professionalStuart Dootson5-Feb-09 2:42 
AnswerRe: How to execute other programs at the given time? Pin
Hamid Taebi5-Feb-09 20:55
professionalHamid Taebi5-Feb-09 20:55 
QuestionTree control collapsing problem Pin
angel.rover5-Feb-09 1:31
angel.rover5-Feb-09 1:31 
AnswerRe: Tree control collapsing problem Pin
Code-o-mat5-Feb-09 1:35
Code-o-mat5-Feb-09 1:35 
GeneralRe: Tree control collapsing problem Pin
angel.rover5-Feb-09 3:47
angel.rover5-Feb-09 3:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.