我是这样创建窗口:
m_hWindow = CreateWindow(m_szWindowClass, m_szTitle,WS_OVERLAPPEDWINDOW | WS_VSCROLL, iXWindowPos,iYWindowPos,iWindowWidth,iWindowHeight,NULL, NULL,m_hInstance,NULL);虽然有了滚动条,可并没有滚动功能.请问需要怎么实现呀?还有就是 参数里边没有水平滚动条的选项,水平滚动条的功能又怎么实现呢? !!谢谢
m_hWindow = CreateWindow(m_szWindowClass, m_szTitle,WS_OVERLAPPEDWINDOW | WS_VSCROLL, iXWindowPos,iYWindowPos,iWindowWidth,iWindowHeight,NULL, NULL,m_hInstance,NULL);虽然有了滚动条,可并没有滚动功能.请问需要怎么实现呀?还有就是 参数里边没有水平滚动条的选项,水平滚动条的功能又怎么实现呢? !!谢谢
case WM_CREATE :
hInstance = (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE) ;
// Create the white-rectangle window against which the
// scroll bars will be positioned. The child window ID is 9.
hwndRect = CreateWindow (TEXT ("static"), NULL,
WS_CHILD | WS_VISIBLE | SS_WHITERECT,
0, 0, 0, 0,
hwnd, (HMENU) 9, hInstance, NULL) ;
for (i = 0 ; i < 3 ; i++)
{
// The three scroll bars have IDs 0, 1, and 2, with
// scroll bar ranges from 0 through 255.
hwndScroll[i] = CreateWindow (TEXT ("scrollbar"), NULL,
WS_CHILD | WS_VISIBLE |
WS_TABSTOP | SBS_VERT,
0, 0, 0, 0,
hwnd, (HMENU) i, hInstance, NULL) ;
SetScrollRange (hwndScroll[i], SB_CTL, 0, 255, FALSE) ;
SetScrollPos (hwndScroll[i], SB_CTL, 0, FALSE) ;
// The three color-name labels have IDs 3, 4, and 5,
// and text strings "Red", "Green", and "Blue".
hwndLabel [i] = CreateWindow (TEXT ("static"), zColorLabel[i],
WS_CHILD | WS_VISIBLE | SS_CENTER,
0, 0, 0, 0,
hwnd, (HMENU) (i + 3),
hInstance, NULL) ;
// The three color-value text fields have IDs 6, 7,
// and 8, and initial text strings of "0".
hwndValue [i] = CreateWindow (TEXT ("static"), TEXT ("0"),
WS_CHILD | WS_VISIBLE | SS_CENTER,
0, 0, 0, 0,
hwnd, (HMENU) (i + 6),
hInstance, NULL) ;
OldScroll[i] = (WNDPROC) SetWindowLong (hwndScroll[i],
GWL_WNDPROC, (LONG) ScrollProc) ;
hBrush[i] = CreateSolidBrush (crPrim[i]) ;
}
hBrushStatic = CreateSolidBrush (
GetSysColor (COLOR_BTNHIGHLIGHT)) ;
cyChar = HIWORD (GetDialogBaseUnits ()) ;
return 0 ;
case WM_SIZE :
cxClient = LOWORD (lParam) ;
cyClient = HIWORD (lParam) ;
SetRect (&rcColor, cxClient / 2, 0, cxClient, cyClient) ;
MoveWindow (hwndRect, 0, 0, cxClient / 2, cyClient, TRUE) ;
for (i = 0 ; i < 3 ; i++)
{
MoveWindow (hwndScroll[i],
(2 * i + 1) * cxClient / 14, 2 * cyChar,
cxClient / 14, cyClient - 4 * cyChar, TRUE) ;
MoveWindow (hwndLabel[i],
(4 * i + 1) * cxClient / 28, cyChar / 2,
cxClient / 7, cyChar, TRUE)
MoveWindow (hwndValue[i],
(4 * i + 1) * cxClient / 28,
cyClient - 3 * cyChar / 2,
cxClient / 7, cyChar, TRUE) ;
}
SetFocus (hwnd) ;
return 0 ;
case WM_SETFOCUS :
SetFocus (hwndScroll[idFocus]) ;
return 0 ;
case WM_VSCROLL :
i = GetWindowLong ((HWND) lParam, GWL_ID) ;
switch (LOWORD (wParam))
{
case SB_PAGEDOWN :
color[i] += 15 ;
// fall through
case SB_LINEDOWN :
color[i] = min (255, color[i] + 1) ;
break ;
case SB_PAGEUP :
color[i] -= 15 ;
// fall through
case SB_LINEUP :
color[i] = max (0, color[i] - 1) ;
break ;
case SB_TOP :
color[i] = 0 ;
break ;
case SB_BOTTOM :
color[i] = 255 ;
break ;
case SB_THUMBPOSITION :
case SB_THUMBTRACK :
color[i] = HIWORD (wParam) ;
break ;
default :
break ;
}
SetScrollPos (hwndScroll[i], SB_CTL, color[i], TRUE) ;
wsprintf (szBuffer, TEXT ("%i"), color[i]) ;
SetWindowText (hwndValue[i], szBuffer) ;
DeleteObject ((HBRUSH)
SetClassLong (hwnd, GCL_HBRBACKGROUND, (LONG)
CreateSolidBrush (RGB (color[0], color[1], color[2])))) ;
InvalidateRect (hwnd, &rcColor, TRUE) ;
return 0 ;
int SetScrollPos(HWND hWnd,int nBar,int nPos,BOOL bRedraw);