我添了一个scroll bar控件,但是不知道怎么给这个控件添加相应的函数,打开classwizard,对于这个控件的ID没有相应的消息响应。
我是想点一下scroll bar控件的上下箭头,实现上下翻页的功能

解决方案 »

  1.   

    case WM_VSCROLL: 
            switch(LOWORD (wParam)) 
            { 
                // User clicked the shaft above the scroll box. 
     
                case SB_PAGEUP: 
                     yInc = min(-1, -yClient / yChar); 
                     break; 
     
                // User clicked the shaft below the scroll box. 
     
                case SB_PAGEDOWN: 
                     yInc = max(1, yClient / yChar); 
                     break; 
     
                // User clicked the top arrow. 
     
                case SB_LINEUP: 
                     yInc = -1; 
                     break; 
     
                // User clicked the bottom arrow. 
     
                case SB_LINEDOWN: 
                     yInc = 1; 
                     break; 
     
                // User dragged the scroll box. 
     
                case SB_THUMBTRACK: 
                     yInc = HIWORD(wParam) - yPos; 
                     break; 
     
                default: 
                     yInc = 0; 
     
            } 
     
            // If applying the vertical scrolling increment does not 
            // take the scrolling position out of the scrolling range, 
            // increment the scrolling position, adjust the position 
            // of the scroll box, and update the window. UpdateWindow 
            // sends the WM_PAINT message. 
     
            if (yInc = max(-yPos, min(yInc, yMax - yPos))) 
            { 
                yPos += yInc; 
                ScrollWindow(hwnd, 0, -yChar * yInc, 
                    (CONST RECT *) NULL, (CONST RECT *) NULL, 
                    (HRGN) NULL, (LPRECT) NULL, SW_INVALIDATE); 
                si.cbSize = sizeof(si); 
                si.fMask  = SIF_POS; 
                si.nPos   = YPos; 
                SetScrollInfo(hwnd, SB_VERT, &si, TRUE); 
                UpdateWindow (hwnd); 
            }