Print Page | Close Window

how to scroll window in xtpreportctrl

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=24118
Printed Date: 25 April 2024 at 4:00pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: how to scroll window in xtpreportctrl
Posted By: yangyanhui
Subject: how to scroll window in xtpreportctrl
Date Posted: 21 December 2020 at 8:21pm
CryHI,I create a xtpreportctrl and a vertical scrollbar. When I add a record I need to scroll window to the top to show the latest record(the new record is inserted on the top).
I write the following code in onvscroll event:

SCROLLINFO scrollinfo;
GetScrollInfo(SB_VERT, &scrollinfo, SIF_ALL);
if (nSBCode == SB_TOP)
{
ScrollWindow(0, -(scrollinfo.nMax - scrollinfo.nMin) * 10);
scrollinfo.nPos = scrollinfo.nMin;
SetScrollInfo(SB_VERT, &scrollinfo, SIF_ALL);
}
VPos = nPos;
m_pScrollBarVer->SetScrollPos(nPos);
CXTPReportControl::OnVScroll(nSBCode, nPos, pScrollBar);

it do not work,what is wrong?



Replies:
Posted By: yangyanhui
Date Posted: 22 December 2020 at 1:34am
I find that the reportctrl try to scroll itself with header rows. When I use mousewheel to scroll, I can get the correct result.However, When I scroll with commands in the scrollbar and use ScrollWindow in ONVSCROLL, it try to scroll the whole window with header rows:

CXTPReportControl::OnVScroll(nSBCode, nPos, pScrollBar);
//}

switch (nSBCode)
{
case SB_LINEUP:
{
pScrollBar->SetScrollPos(pScrollBar->GetScrollPos() - 1);
ScrollWindow(0, -1);
break;
}
case SB_LINEDOWN:
{
pScrollBar->SetScrollPos(pScrollBar->GetScrollPos() + 1);
ScrollWindow(0, 1);
break;
}
case SB_PAGEUP:
{
pScrollBar->SetScrollPos(pScrollBar->GetScrollPos() - 5);
ScrollWindow(0, -5);
break;
}
case SB_PAGEDOWN:
{
pScrollBar->SetScrollPos(pScrollBar->GetScrollPos() + 5);
ScrollWindow(0, 5);
break;
}
case SB_THUMBTRACK:
{
ScrollWindow(0, nPos - pScrollBar->GetScrollPos());
pScrollBar->SetScrollPos(nPos);
break;
}
case SB_TOP:
{
pScrollBar->SetScrollPos(0);
ScrollWindow(0, -nPos);
break;
}
}


Posted By: yangyanhui
Date Posted: 22 December 2020 at 2:37am
void CSelfReportControl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
if (m_pScrollBarVer && pScrollBar == m_pScrollBarVer)
{
if (HavPud&&nPos == 0)
{
HavPud = false;
return;
}
HavPud = true;
VPos = nPos;
CXTPReportControl::OnVScroll(nSBCode, nPos, 0);
}
}
I find that when I operate with the scrollbar,it works well.
But when I operate outside scrollbar(for example,SendMessage(WM_VSCROLL, MAKEWPARAM(SB_TOP, 0), NULL);),the pScrollBar will be null and the operation will fail


Posted By: yangyanhui
Date Posted: 23 December 2020 at 12:46am
I use 
m_wndReportCtrlDir.SendMessage(WM_VSCROLL, SB_TOP, (LPARAM)m_wndReportCtrlDir.m_pScrollBarVer->GetSafeHwnd());

to send the message.When I track into the code, I found CXTPReportControl::OnVScroll(nSBCode, nPos, 0); is executed,but it did not work.What might be wrong?



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net