예제 #1
0
void touchmind::util::ScrollBarHelper::UpdateScrollInfo(HWND hWnd) {
  SCROLLINFO scrollInfoHorz;
  GetHScrollInfo(&scrollInfoHorz);
  ::SetScrollInfo(hWnd, SB_HORZ, &scrollInfoHorz, TRUE);

  SCROLLINFO scrollInfoVert;
  GetVScrollInfo(&scrollInfoVert);
  ::SetScrollInfo(hWnd, SB_VERT, &scrollInfoVert, TRUE);
}
예제 #2
0
void MScrollView::HScroll(int nSB_, int nPos)
{
    SCROLLINFO si;
    si.cbSize = sizeof(si);
    si.fMask = SIF_ALL;
    GetHScrollInfo(&si);

    switch (nSB_)
    {
    case SB_TOP:
        SetHScrollPos(0);
        break;

    case SB_BOTTOM:
        SetHScrollPos(si.nMax - si.nPage);
        break;

    case SB_LINELEFT:
        SetHScrollPos(si.nPos - 16);
        break;

    case SB_LINERIGHT:
        SetHScrollPos(si.nPos + 16);
        break;

    case SB_PAGELEFT:
        SetHScrollPos(si.nPos - si.nPage);
        break;

    case SB_PAGERIGHT:
        SetHScrollPos(si.nPos + si.nPage);
        break;

    case SB_THUMBPOSITION:
    case SB_THUMBTRACK:
        SetHScrollPos(nPos);
        break;
    }

    ScrollPos().x = GetHScrollPos();
    UpdateAll();
}
예제 #3
0
파일: pwindow.cpp 프로젝트: garyqinyu/abv
/*--------------------------------------------------------------------------*/
BOOL PegWindow::CheckAutoScroll(void)
{
    PegScrollInfo mInfo;
    PegMessage NewMessage;

    BOOL bChange = FALSE;

    if (muScrollMode & WSM_AUTOHSCROLL)
    {
        GetHScrollInfo(&mInfo);
        if (mInfo.wMax - mInfo.wMin >= mInfo.wVisible)
        {
            // we need a horizontal scroll

            if (!mpHScroll)
	        {
	            mpHScroll = new PegHScroll();
	            mClient.wBottom -= PEG_SCROLL_WIDTH;
                Add(mpHScroll, FALSE);

                if (mpVScroll && StatusIs(PSF_VISIBLE))
                {
                    NewMessage.wType = PM_PARENTSIZED;
                    mpVScroll->Message(NewMessage);
                }
                bChange = TRUE;
            }
            else
            {
                if (mInfo.wCurrent + mInfo.wVisible > mInfo.wMax)
                {
                    NewMessage.wType = PM_HSCROLL;
                    NewMessage.lData = mInfo.wMax - mInfo.wVisible + 1;
                    NewMessage.iData = mInfo.wCurrent;
                    NewMessage.pTarget = this;
                    MessageQueue()->Push(NewMessage);
                    mInfo.wCurrent = (SIGNED) NewMessage.lData;
                }
                mpHScroll->Reset(&mInfo);
            }      
        }
        else
        {
            // we don't need an HScroll:
            if (mpHScroll)
            {
                mClient.wBottom += PEG_SCROLL_WIDTH;
	            Remove(mpHScroll, FALSE);
	            MessageQueue()->Purge(mpHScroll);
	            delete mpHScroll;
	            mpHScroll = NULL;
                bChange = TRUE;

                if (mpVScroll && StatusIs(PSF_VISIBLE))
                {
                     NewMessage.wType = PM_PARENTSIZED;
                     mpVScroll->Message(NewMessage);
                }

                NewMessage.wType = PM_HSCROLL;
                NewMessage.lData = mInfo.wMin;
                NewMessage.iData = mInfo.wCurrent;
                NewMessage.pTarget = this;
                MessageQueue()->Push(NewMessage);
            }
        }
    }

    if (muScrollMode & WSM_AUTOVSCROLL)
    {
        GetVScrollInfo(&mInfo);
        if (mInfo.wMax - mInfo.wMin >= mInfo.wVisible)
        {
            // we need a vertical scroll

            if (!mpVScroll) // don't have one?
            {
	            mpVScroll = new PegVScroll();
	            mClient.wRight -= PEG_SCROLL_WIDTH;
	            Add(mpVScroll, FALSE);

                if (mpHScroll && StatusIs(PSF_VISIBLE))
                {
                    NewMessage.wType = PM_PARENTSIZED;
                    mpHScroll->Message(NewMessage);
                }
                mpVScroll->Reset(&mInfo);
                bChange = TRUE;
            }
            else
            {
                if (mInfo.wCurrent + mInfo.wVisible > mInfo.wMax)
                {
                    NewMessage.wType = PM_VSCROLL;
                    NewMessage.lData = mInfo.wMax - mInfo.wVisible + 1;
                    NewMessage.iData = mInfo.wCurrent;
                    NewMessage.pTarget = this;
                    MessageQueue()->Push(NewMessage);
                    mInfo.wCurrent = (SIGNED) NewMessage.lData;
                }
                mpVScroll->Reset(&mInfo);
            }      
        }
        else
        {
            // here if we don't need a vertical scroll

            if (mpVScroll)  // do we have one?
            {
	            mClient.wRight += PEG_SCROLL_WIDTH;
	            Remove(mpVScroll, FALSE);
	            MessageQueue()->Purge(mpVScroll);
	            delete mpVScroll;
	            mpVScroll = NULL;
                bChange = TRUE;

                if (mpHScroll && StatusIs(PSF_VISIBLE))
                {
                    NewMessage.wType = PM_PARENTSIZED;
                    mpHScroll->Message(NewMessage);
                }

                NewMessage.wType = PM_VSCROLL;
                NewMessage.lData = mInfo.wMin;
                NewMessage.iData = mInfo.wCurrent;
                NewMessage.pTarget = this;
                MessageQueue()->Push(NewMessage);
            }
        }
    }
    if (bChange)
    {
        CheckAutoScroll();
    }
    return bChange;
}