2
    case WM_VSCROLL: //in switch(message) in WinProc
            wmId = GetWindowLong((HWND) lParam, GWL_ID);
                        //only one scroll bar so don't check it
            switch(LOWORD(wParam))
            {
            case SB_THUMBPOSITION:
            case SB_THUMBTRACK:
                nScrollPos = HIWORD(wParam);
                break;
            default:
                break;
            }
            SetScrollPos (hDirectives, SB_CTL, nScrollPos, TRUE);
            break;
    //where 
    hDirectives = CreateWindow(TEXT("static"), NULL, 
WS_CHILD | WS_BORDER | WS_VISIBLE | SS_RIGHT | SS_SUNKEN | WS_VSCROLL, 
                20, 20, 300, 300, hWnd, 
(HMENU) ID_DIRECTIVE, ((LPCREATESTRUCT) lParam) ->hInstance, NULL);

窗口显示,我可以输入文本,但滚动条没有响应。

4

1 回答 1

1

当窗口具有WS_VSCROLL/WS_HSCROLL样式时,滚动条消息将发送到窗口,而不是其父窗口。在上面的示例中,您需要对静态控件进行子类化以处理滚动消息。

于 2012-12-08T06:45:39.423 回答