示例#1
0
void ExtFrame::IncrementSpin(CSpinButtonCtrl& spin, CEdit& edit, unsigned int val)
{
    char num[33];
    _ultoa_s(val, num, sizeof(num), 10);
    spin.SetPos(val);
    edit.SetWindowText(num);
    ScrollEnd(edit);
}   
示例#2
0
BOOL ScrollImage( HWND hWnd, BOOL fVScroll, UINT code, int pos )
/************************************************************************/
{
int fy, dy, fx, dx;
RECT rScroll;
BOOL bScrollWindow;
#define SCROLLPIXELS 10
LPIMAGE lpImage;
LPDISPLAY lpDisplay;

lpImage = GetImagePtr(hWnd);
lpDisplay = GetDisplayPtr(hWnd);

if (IsIconic(hWnd))
    return( NO );

bScrollWindow = NO;
rScroll = lpDisplay->DispRect;
rScroll.bottom++; rScroll.right++;
if (fVScroll &&
    ( lpImage->nlin - RectHeight( &lpDisplay->FileRect ) > 0 ) )
    {
    switch ( code )
        {
        case SB_ENDSCROLL:
        ScrollEnd( hWnd );
        break;

        case SB_TOP:
        case SB_BOTTOM:
        MessageBeep(0);
        break;

        case SB_PAGEUP:
        case SB_PAGEDOWN:
        case SB_LINEUP:
        case SB_LINEDOWN:
        fy = SCROLLPIXELS;
        if ( code == SB_PAGEUP || code == SB_PAGEDOWN )
            fy *= 10;
        if ( !(fy = FMUL( fy, lpDisplay->FileRate )) )
            fy = 1;
        if ( code == SB_LINEDOWN || code == SB_PAGEDOWN )
            {
            fy = -fy;
            dy = lpDisplay->FileRect.bottom - lpImage->nlin + 1;
            }
        else
        // ( code == SB_LINEUP || code == SB_PAGEUP )
            dy = lpDisplay->FileRect.top;
        if ( !dy )
            break;
        if ( abs(fy) > abs(dy) )
            fy = dy;
        if ( !(dy = FMUL( fy, lpDisplay->DispRate )) )
            break;
        ScrollStart( hWnd );
        lpDisplay->FileRect.top -= fy;
        lpDisplay->FileRect.bottom -= fy;
        lpDisplay->yDiva -= dy;
        ScrollWindow( hWnd, 0 /*x*/, dy, &rScroll, &rScroll );
        AstralUpdateWindow(hWnd);
        bScrollWindow = YES;
        break;

        case SB_THUMBPOSITION:
        case SB_THUMBTRACK:
        if ( !(fy = GetDisplayScrollDelta( hWnd, lpDisplay, SB_VERT, pos) ) )
            break;
        if ( !(dy = FMUL( fy, lpDisplay->DispRate )) )
            break;
        ScrollStart( hWnd );
        lpDisplay->FileRect.top -= fy;
        lpDisplay->FileRect.bottom -= fy;
        lpDisplay->yDiva -= dy;
        ScrollWindow( hWnd, 0 /*x*/, dy, &rScroll, &rScroll );
        AstralUpdateWindow(hWnd);
        bScrollWindow = YES;
        break;
        }
    }

if (!fVScroll &&
    ( lpImage->npix - RectWidth( &lpDisplay->FileRect ) > 0 ) )
    {
    switch ( code )
        {
        case SB_ENDSCROLL:
        ScrollEnd( hWnd );
        break;

        case SB_TOP:
        case SB_BOTTOM:
        MessageBeep(0);
        break;

        case SB_PAGEUP:
        case SB_PAGEDOWN:
        case SB_LINEUP:
        case SB_LINEDOWN:
        fx = SCROLLPIXELS;
        if ( code == SB_PAGEUP || code == SB_PAGEDOWN )
            fx *= 10;
        if ( !(fx = FMUL( fx, lpDisplay->FileRate )) )
            fx = 1;
        if ( code == SB_LINEDOWN || code == SB_PAGEDOWN )
            {
            fx = -fx;
            dx = lpDisplay->FileRect.right - lpImage->npix + 1;
            }
        else
        // ( code == SB_LINEUP || code == SB_PAGEUP )
            dx = lpDisplay->FileRect.left;
        if ( !dx )
            break;
        if ( abs(fx) > abs(dx) )
            fx = dx;
        if ( !(dx = FMUL( fx, lpDisplay->DispRate )) )
            break;
        ScrollStart( hWnd );
        lpDisplay->FileRect.left -= fx;
        lpDisplay->FileRect.right -= fx;
        lpDisplay->xDiva -= dx;
        ScrollWindow( hWnd, dx, 0 /*y*/, &rScroll, &rScroll );
        AstralUpdateWindow(hWnd);
        bScrollWindow = YES;
        break;

        case SB_THUMBPOSITION:
        case SB_THUMBTRACK:
        if ( !(fx = GetDisplayScrollDelta( hWnd, lpDisplay, SB_HORZ, pos )) )
            break;
        if ( !(dx = FMUL( fx, lpDisplay->DispRate )) )
            break;
        ScrollStart( hWnd );
        lpDisplay->FileRect.left -= fx;
        lpDisplay->FileRect.right -= fx;
        lpDisplay->xDiva -= dx;
        ScrollWindow( hWnd, dx, 0 /*y*/, &rScroll, &rScroll );
        AstralUpdateWindow(hWnd);
        bScrollWindow = YES;
        break;
        }
    }

return( bScrollWindow );
}