Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - how to scroll window in xtpreportctrl
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

how to scroll window in xtpreportctrl

 Post Reply Post Reply
Author
Message
yangyanhui View Drop Down
Senior Member
Senior Member


Joined: 20 August 2020
Status: Offline
Points: 131
Post Options Post Options   Thanks (0) Thanks(0)   Quote yangyanhui Quote  Post ReplyReply Direct Link To This Post Topic: how to scroll window in xtpreportctrl
    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?
Back to Top
yangyanhui View Drop Down
Senior Member
Senior Member


Joined: 20 August 2020
Status: Offline
Points: 131
Post Options Post Options   Thanks (0) Thanks(0)   Quote yangyanhui Quote  Post ReplyReply Direct Link To This Post 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;
}
}
Back to Top
yangyanhui View Drop Down
Senior Member
Senior Member


Joined: 20 August 2020
Status: Offline
Points: 131
Post Options Post Options   Thanks (0) Thanks(0)   Quote yangyanhui Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
yangyanhui View Drop Down
Senior Member
Senior Member


Joined: 20 August 2020
Status: Offline
Points: 131
Post Options Post Options   Thanks (0) Thanks(0)   Quote yangyanhui Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 1.125 seconds.