示例#1
0
BOOL SetScrollRangeEx (HWND hWnd, int iSBar, int iMinPos, int iMaxPos)	/* jmt: iSBar not used */
{
    PMWSCROLLBARINFO pSBar;
    HWND pWin;
    RECT rcBar;
    
    DWORD dwStyle;	/* jmt:2k0820 */

    pWin = (HWND)hWnd;
    
    if ( !(pSBar = wndGetScrollBar (pWin)) )
        return FALSE;

    pSBar->minPos = (iMinPos < iMaxPos)?iMinPos:iMaxPos;
    pSBar->maxPos = (iMinPos > iMaxPos)?iMinPos:iMaxPos;
    
    /* validate parameters. */
    if (pSBar->curPos < pSBar->minPos)
        pSBar->curPos = pSBar->minPos;

    if (pSBar->pageStep <= 0)
        pSBar->pageStep = 0;
    else if (pSBar->pageStep > (pSBar->maxPos - pSBar->minPos + 1))
        pSBar->pageStep = pSBar->maxPos - pSBar->minPos + 1;
    
    {
        int max = pSBar->maxPos;
        max -= ((pSBar->pageStep - 1) > 0)?(pSBar->pageStep - 1):0;

        if (pSBar->curPos > max)
            pSBar->curPos = max;
    }

    dwStyle = (GetWindowStyle (hWnd) & SBS_TYPEMASK);	/* jmt: 2k0820 */

    if (dwStyle == SBS_VERT)
    {
        wndGetVScrollBarRect (pWin, &rcBar);
    	rcBar.left --;
      	rcBar.right --;
    }
    else
    {
        wndGetHScrollBarRect (pWin, &rcBar);
    	rcBar.top  --;
    	rcBar.bottom --;
    }
    wndScrollBarPos (pWin, dwStyle == SBS_HORZ, &rcBar);

#if 0
    SendMessage (hWnd, WM_NCPAINT, 0, (LPARAM)(&rcBar));
#else
    MwPaintScrollbars(hWnd,NULL,dwStyle);	/* a must */
#endif

    return TRUE;
}
示例#2
0
BOOL  SetScrollRange (HWND hWnd, int iSBar, int iMinPos, int iMaxPos)
{
    PMWSCROLLBARINFO pSBar;
    HWND pWin;
    RECT rcBar;
    
    pWin = (HWND)hWnd;
    
    if ( !(pSBar = wndGetScrollBar (pWin, iSBar)) )
        return FALSE;

    pSBar->minPos = (iMinPos < iMaxPos)?iMinPos:iMaxPos;
    pSBar->maxPos = (iMinPos > iMaxPos)?iMinPos:iMaxPos;
    
    // validate parameters.
    if (pSBar->curPos < pSBar->minPos)
        pSBar->curPos = pSBar->minPos;

    if (pSBar->pageStep <= 0)
        pSBar->pageStep = 0;
    else if (pSBar->pageStep > (pSBar->maxPos - pSBar->minPos + 1))
        pSBar->pageStep = pSBar->maxPos - pSBar->minPos + 1;
    
    {
        int max = pSBar->maxPos;
        max -= ((pSBar->pageStep - 1) > 0)?(pSBar->pageStep - 1):0;

        if (pSBar->curPos > max)
            pSBar->curPos = max;
    }

    if (iSBar == SB_VERT)
    {
        wndGetVScrollBarRect (pWin, &rcBar);
    	rcBar.left --;
      	rcBar.right --;
    }
    else
    {
        wndGetHScrollBarRect (pWin, &rcBar);
    	rcBar.top  --;
    	rcBar.bottom --;
    }
    wndScrollBarPos (pWin, iSBar == SB_HORZ, &rcBar);

#if 0
    SendMessage (hWnd, WM_NCPAINT, 0, (LPARAM)(&rcBar));
#else
    MwPaintNCScrollbars(hWnd,NULL);//a must
#endif

    return TRUE;
}
示例#3
0
BOOL  SetScrollPos (HWND hWnd, int iSBar, int iNewPos)//ok
{
    PMWSCROLLBARINFO pSBar;
    HWND pWin;
    RECT rcBar;
    
    pWin = (HWND)hWnd;
    
    if ( !(pSBar = wndGetScrollBar (pWin, iSBar)) )
        return FALSE;

    if (iNewPos < pSBar->minPos)
        pSBar->curPos = pSBar->minPos;
    else
        pSBar->curPos = iNewPos;

    {
        int max = pSBar->maxPos;
        max -= ((pSBar->pageStep - 1) > 0)?(pSBar->pageStep - 1):0;

        if (pSBar->curPos > max)
            pSBar->curPos = max;
    }
    
    if (iSBar == SB_VERT)
    {
        wndGetVScrollBarRect (pWin, &rcBar);
        rcBar.left --;
        rcBar.right --;
    }
    else
    {
        wndGetHScrollBarRect (pWin, &rcBar);
        rcBar.top  --;
        rcBar.bottom --;
    }

    wndScrollBarPos (pWin, iSBar == SB_HORZ, &rcBar);

#if 0
    SendMessage (hWnd, WM_NCPAINT, 0, (LPARAM)(&rcBar));
#else
    MwPaintNCScrollbars(hWnd,NULL);//a must
#endif
    return TRUE;
}
示例#4
0
static LRESULT CALLBACK
ScrollbarControlProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)	/* jmt:2k0820 */
{
    	DWORD dwStyle;
    	MWSCROLLBARINFO* pData;

	int moveRange;
	RECT rcBar;

	dwStyle = (GetWindowStyle (hwnd) & SBS_TYPEMASK);
    	switch (message) 
	{
        case WM_CREATE:
            	if (!(pData = malloc (sizeof (MWSCROLLBARINFO)))) 
		{
                	fprintf(stderr, "Create scroll bar control failure!\n");
                	return -1;
            	}

		pData->minPos=0;           /* min value of scroll range.*/
		/* max value of scroll range.*/
		pData->maxPos=0;     
		if  (dwStyle==SBS_VERT)
			moveRange=((hwnd->winrect.bottom-hwnd->winrect.top)
				-((hwnd->winrect.right-hwnd->winrect.left)<<1));
		else
			moveRange=((hwnd->winrect.right-hwnd->winrect.left)
				-((hwnd->winrect.bottom-hwnd->winrect.top)<<1));
		if (moveRange > MWM_MINBARLEN)
		{


			pData->maxPos=moveRange / MWM_MINBARLEN;
			if( (moveRange % MWM_MINBARLEN) )
				pData->maxPos++;
		}     
		printf("maxPos=%d\n",pData->maxPos);

		pData->curPos=0;             /* current scroll pos.*/

		/* steps per page.*/
		pData->pageStep=1;
		if ( (pData->maxPos - 2) > 1)
			pData->pageStep = pData->maxPos - 2;
		printf("pageStep=%d\n",pData->pageStep);

		pData->barStart=0;           /* start pixel of bar.*/
		pData->barLen=MWM_MINBARLEN; /* length of bar.*/
		pData->status=SBS_UNKNOWN;   /* status of scroll bar.*/
#if 0	/* jmt: must handle WM_MOVE */
		pData->rc=hwnd->winrect;   /* screen coordinates position*/
#endif
            	hwnd->userdata = (DWORD)pData;

		if (dwStyle == SBS_VERT)
		{
		    wndGetVScrollBarRect (hwnd, &rcBar);
		    rcBar.left --;
		    rcBar.right --;
		}
		else
		{
		    wndGetHScrollBarRect (hwnd, &rcBar);
		    rcBar.top --;
		    rcBar.bottom --;
		}
		/* adjust pData->barLen */
		wndScrollBarPos (hwnd, dwStyle == SBS_HORZ, &rcBar);

        	break;
            
        case WM_DESTROY: 
            	free ((void *)(hwnd->userdata));
            	break;

        case WM_PAINT:
		MwPaintScrollbars(hwnd,NULL,dwStyle);
            	break;
	
	case WM_NCLBUTTONDOWN:
	case WM_NCLBUTTONDBLCLK:
	case WM_NCMOUSEMOVE:
	case WM_NCLBUTTONUP:
		MwHandleMessageScrollbar(hwnd, wParam, lParam, message, dwStyle);
		break;

        case WM_HSCROLL:
        case WM_VSCROLL:
        {
            int newTop,itemCount,itemVisibles;

	    pData = (MWSCROLLBARINFO *)hwnd->userdata;
            newTop = pData->curPos;
	    itemCount = pData->maxPos - pData->minPos + 1;
	    itemVisibles = pData->pageStep;

            switch(wParam)
            {
                case SB_LINEDOWN:
#define ITEM_BOTTOM(x)  (x->curPos + itemVisibles - 1)
                    if (ITEM_BOTTOM (pData) < (itemCount - 1 )) 
		    {
                        newTop ++;
                    }
                break;
                
                case SB_LINEUP:
                    if (pData->curPos > 0) 
		    {
                        newTop --;
                    }
                break;
                
                case SB_PAGEDOWN:
                    if ((pData->curPos + (itemVisibles << 1)) <=
                            itemCount)
                        newTop += itemVisibles;
                    else
                        newTop = itemCount - itemVisibles;

                    if (newTop < 0)
                        return 0;

                break;

                case SB_PAGEUP:
                    if (pData->curPos >= itemVisibles)
                        newTop -= itemVisibles;
                    else
                        newTop = 0;

                break;

                case SB_THUMBTRACK:
                    newTop = (int)lParam;
                break;
            }
            
            pData->curPos = newTop;

            SendMessage (hwnd, WM_PAINT, 0, 0);

            sbSetScrollInfo (hwnd, pData, TRUE);

            return 0;
        }
        break;

        default:
    		return DefWindowProc (hwnd, message, wParam, lParam);
    	}
    	return 0;
}
示例#5
0
BOOL SetScrollInfoEx (HWND hWnd, int iSBar, 
                LPCSCROLLINFO lpsi, BOOL fRedraw)	/* jmt: iSBar not used */
{
    PMWSCROLLBARINFO pSBar;
    HWND pWin;
    RECT rcBar;
    
    DWORD dwStyle;	/* jmt:2k0820 */

    pWin = (HWND)hWnd;
    
    if ( !(pSBar = wndGetScrollBar (pWin)) )
        return FALSE;
        
    if( lpsi->fMask & SIF_RANGE )
    {
        pSBar->minPos = (lpsi->nMin < lpsi->nMax)?lpsi->nMin:lpsi->nMax;
        pSBar->maxPos = (lpsi->nMin < lpsi->nMax)?lpsi->nMax:lpsi->nMin;
    }
    
    if( lpsi->fMask & SIF_POS )
        pSBar->curPos = lpsi->nPos;
    
    if( lpsi->fMask & SIF_PAGE )
        pSBar->pageStep = lpsi->nPage;

    /* validate parameters. */
    if (pSBar->curPos < pSBar->minPos)
        pSBar->curPos = pSBar->minPos;

    if (pSBar->pageStep <= 0)
        pSBar->pageStep = 0;
    else if (pSBar->pageStep > (pSBar->maxPos - pSBar->minPos + 1))
        pSBar->pageStep = pSBar->maxPos - pSBar->minPos + 1;
    
    {
        int max = pSBar->maxPos;
        max -= ((pSBar->pageStep - 1) > 0)?(pSBar->pageStep - 1):0;

        if (pSBar->curPos > max)
            pSBar->curPos = max;
    }

    dwStyle = (GetWindowStyle (hWnd) & SBS_TYPEMASK);	/* jmt: 2k0820 */

    if(fRedraw)
    {
        if (dwStyle == SBS_VERT)
	{
            wndGetVScrollBarRect (pWin, &rcBar);
            rcBar.left --;
            rcBar.right --;
	}
        else
	{
            wndGetHScrollBarRect (pWin, &rcBar);
            rcBar.top --;
            rcBar.bottom --;
	}
        wndScrollBarPos (pWin, dwStyle == SBS_HORZ, &rcBar);

#if 0
        SendMessage (hWnd, WM_NCPAINT, 0, (LPARAM)(&rcBar));
#else
	MwPaintScrollbars(hWnd,NULL,dwStyle);	/* a must */
#endif
    }
    
    return TRUE;
}
示例#6
0
BOOL  SetScrollInfo (HWND hWnd, int iSBar, 
                LPCSCROLLINFO lpsi, BOOL fRedraw)//ok
{
    PMWSCROLLBARINFO pSBar;
    HWND pWin;
    RECT rcBar;
    
    pWin = (HWND)hWnd;
    
    if ( !(pSBar = wndGetScrollBar (pWin, iSBar)) )
        return FALSE;
        
    if( lpsi->fMask & SIF_RANGE )
    {
        pSBar->minPos = (lpsi->nMin < lpsi->nMax)?lpsi->nMin:lpsi->nMax;
        pSBar->maxPos = (lpsi->nMin < lpsi->nMax)?lpsi->nMax:lpsi->nMin;
    }
    
    if( lpsi->fMask & SIF_POS )
        pSBar->curPos = lpsi->nPos;
    
    if( lpsi->fMask & SIF_PAGE )
        pSBar->pageStep = lpsi->nPage;

    // validate parameters.
    if (pSBar->curPos < pSBar->minPos)
        pSBar->curPos = pSBar->minPos;

    if (pSBar->pageStep <= 0)
        pSBar->pageStep = 0;
    else if (pSBar->pageStep > (pSBar->maxPos - pSBar->minPos + 1))
        pSBar->pageStep = pSBar->maxPos - pSBar->minPos + 1;
    
    {
        int max = pSBar->maxPos;
        max -= ((pSBar->pageStep - 1) > 0)?(pSBar->pageStep - 1):0;

        if (pSBar->curPos > max)
            pSBar->curPos = max;
    }

    if(fRedraw)
    {
        if (iSBar == SB_VERT)
	{
            wndGetVScrollBarRect (pWin, &rcBar);
            rcBar.left --;
            rcBar.right --;
	}
        else
	{
            wndGetHScrollBarRect (pWin, &rcBar);
            rcBar.top --;
            rcBar.bottom --;
	}
        wndScrollBarPos (pWin, iSBar == SB_HORZ, &rcBar);

#if 0
        SendMessage (hWnd, WM_NCPAINT, 0, (LPARAM)(&rcBar));
#else
	MwPaintNCScrollbars(hWnd,NULL);//a must
#endif
    }
    
    return TRUE;
}