静态控制滚动条不工作Win32

时间:2012-12-08 06:13:33

标签: c++ c winapi scrollbar

    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);

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

1 个答案:

答案 0 :(得分:1)

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