看我怎样改变ListView,TreeView,Memo等的ScrollBar的外观(200分)

  • 主题发起人 主题发起人 cemi
  • 开始时间 开始时间
C

cemi

Unregistered / Unconfirmed
GUEST, unregistred user!
1,尝试用EnumChildWindows,ChildWindowFromPoint等函数获取ScrollBar的Handle,<br>&nbsp; &nbsp;都失败。<br><br>2,继承TCustomerListView然后在OnCreate的事件创建一个TPanel,并用setwindowpos改变它的Z轴的位置<br>&nbsp; &nbsp;但这个Panel始终被ScrollBar遮住,也失败。<br><br>3,在响应窗口的WM_HSCROLL或WM_VSCROLL时用以下的代码 &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp;...........<br>&nbsp; &nbsp; &nbsp;..........<br>&nbsp; &nbsp; &nbsp;DC:=GetDC(0); &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp;P:=Self.ClientToScreen(point(0,0));<br>&nbsp; &nbsp; &nbsp;R:=RECT(P.x+width-FSBWidth, P.y, P.x+width, P.y+height);<br>&nbsp; &nbsp; &nbsp;Fillrect(DC,R,Brush);<br>&nbsp; &nbsp; &nbsp;.............<br>&nbsp; &nbsp; &nbsp;...........<br>&nbsp; &nbsp;这样在鼠标拖动滑块时就会原形毕露,并且不知道怎样响应ScrollBar的OnMouseDown,OnMouseUp等的消息,<br>&nbsp; &nbsp;所以也失败。<br><br>4, 跟着在MSDN中查到以下的一些函数<br>&nbsp; &nbsp;InitializeFlatSB ,FlatSB_SetScrollProp ,FlatSB_ShowScrollBar.... 等的一些函数<br>&nbsp; &nbsp;写了下面的函数<br>&nbsp; &nbsp;function TCEMIListView.PaintVSB:boolean;<br>&nbsp; &nbsp;var<br>&nbsp; &nbsp; &nbsp;PE:TPaletteEntry;<br>&nbsp; &nbsp; &nbsp;LP:TLogPalette;<br>&nbsp; &nbsp; &nbsp;PL:HPALETTE;<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp;result:=false;<br>&nbsp; &nbsp; &nbsp;if not InitializeFlatSB(handle) then exit;<br>&nbsp; &nbsp; &nbsp;if not FlatSB_SetScrollProp(handle,WSB_PROP_VBKGCOLOR ,clBlue,true) then exit;<br>&nbsp; &nbsp; &nbsp;with PE do<br>&nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp;peRed:=$7F;<br>&nbsp; &nbsp; &nbsp; &nbsp;peBlue:=$4F;<br>&nbsp; &nbsp; &nbsp; &nbsp;peGreen:=$7F;<br>&nbsp; &nbsp; &nbsp; &nbsp;peFlags:=PC_EXPLICIT; //?<br>&nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp;with LP do<br>&nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp;palVersion:=1;<br>&nbsp; &nbsp; &nbsp; &nbsp;palNumEntries:=1;<br>&nbsp; &nbsp; &nbsp; &nbsp;palPalEntry[0]:=PE; &nbsp;//?<br>&nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp;PL:=CreatePalette(LP);<br>&nbsp; &nbsp; &nbsp;if not FlatSB_SetScrollProp(handle,WSB_PROP_PALETTE,PL,true) then exit;<br>&nbsp; &nbsp; &nbsp;result:=true;<br>&nbsp; &nbsp;end;<br>&nbsp; &nbsp;调用这个函数返回的是True,并且可以把ScrollBar变成Flat的样式和把背景颜色改成蓝色,<br>&nbsp; &nbsp;但用Palette填充的语句根部不起作用,不知道那里写错了。就算可以用Palette填充,还是<br>&nbsp; &nbsp;跟我想达到的目的有很大的差距。<br>&nbsp; &nbsp;<br>最后我已经无计可施,恳请大家指点。
 
我看应该是没人答我的问题了。
 
在 WM_HSCROLL 的消息中的lParam纪录scrollbar 的handle,但却有这样一句<br>Value of lParam. Identifies the control if WM_VSCROLL is sent by a scroll bar <br>control. If WM_VSCROLL is sent by a window's standard scroll bar, <br>hwndScrollBar is not used. <br>
 
好象达不到。以前这个问题我也问过的,没有什么结果。
 
不要保留原先的ScrollBar,试一下在继承时替换掉它的ScrollBar
 
你看看它们的源代码,关于SCROLLBAR是怎么写的,在哪些过程或函数里,<br>然后继承ListView,TreeView,Memo等生成一个新的控件,在新控件里把这些方法重写
 
把分分了算了
 
后退
顶部