how to scroll window in xtpreportctrl |
Post Reply |
Author | |
yangyanhui
Senior Member Joined: 20 August 2020 Status: Offline Points: 131 |
Post Options
Thanks(0)
Posted: 21 December 2020 at 8:21pm |
HI,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?
|
|
yangyanhui
Senior Member Joined: 20 August 2020 Status: Offline Points: 131 |
Post Options
Thanks(0)
|
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; } } |
|
yangyanhui
Senior Member Joined: 20 August 2020 Status: Offline Points: 131 |
Post Options
Thanks(0)
|
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
|
|
yangyanhui
Senior Member Joined: 20 August 2020 Status: Offline Points: 131 |
Post Options
Thanks(0)
|
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?
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |