急问:如何改变滚动条的颜色

jinchaocsdn 2004-03-21 02:15:35
如题,多谢
...全文
183 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
changlele 2004-03-21
  • 打赏
  • 举报
回复
响应WM_CtlColor消息映射就行了
afx_msg HBRUSH OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor );
jinchaocsdn 2004-03-21
  • 打赏
  • 举报
回复
谢谢楼上的,我是想问这样一种情况,改变一个ListCtrl控件,或ListBox控件的滚动条颜色,最好有例子,多谢
_foo 2004-03-21
  • 打赏
  • 举报
回复
提问题得清楚一点,你是要改变滚动条控件色还是改变窗口内建的滚动条色?
xstring 2004-03-21
  • 打赏
  • 举报
回复
WM_CTLCOLORSCROLLBAR
The WM_CTLCOLORSCROLLBAR message is sent to the parent window of a scroll bar control when the control is about to be drawn. By responding to this message, the parent window can use the display context handle to set the background color of the scroll bar control.

A window receives this message through its WindowProc function.

LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_CTLCOLORSCROLLBAR
WPARAM wParam, // handle to DC (HDC)
LPARAM lParam // handle to scroll bar (HWND)
);
Parameters
wParam
Handle to the device context for the scroll bar control.
lParam
Handle to the scroll bar.
Return Values
If an application processes this message, it must return the handle to a brush. The system uses the brush to paint the background of the scroll bar control.

Remarks
By default, the DefWindowProc function selects the default system colors for the scroll bar control.

The system does not automatically destroy the returned brush. It is the application's responsibility to destroy the brush when it is no longer needed.

The WM_CTLCOLORSCROLLBAR message is never sent between threads; it is only sent within the same thread.

If a dialog box procedure handles this message, it should cast the desired return value to a BOOL and return the value directly. If the dialog box procedure returns FALSE, then default message handling is performed. The DWL_MSGRESULT value set by the SetWindowLong function is ignored.

The WM_CTLCOLORSCROLLBAR message is used only by child scrollbar controls. Scrollbars attached to a window (WS_SCROLL and WS_VSCROLL) do not generate this message. To customize the appearance of scrollbars attached to a window, use the flat scroll bar functions.

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧