dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 20

Thread: Customize control scrollbar

Threaded View

  1. #1
    Join Date
    Jan 2009
    Posts
    312

    Customize control scrollbar

    I get a task: to color the control scrollbar (a gridctrl scrollbar, whatever). In the first attempting I didn't succeded ... So, I started to trying coloring a CListBox scrollbar ... I developed a derived CListBox where I override OnCtlColor:
    Code:
    HBRUSH CMyListBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
    {
    	HBRUSH hbr = CListBox::OnCtlColor(pDC, pWnd, nCtlColor);
    
    	// TODO: Change any attributes of the DC here
    
    	// TODO: Return a different brush if the default is not desired
    
    	if(CTLCOLOR_STATIC == nCtlColor)
    	{
    		pDC->SetTextColor(RGB(200, 34, 0));
    		pDC->SetBkColor(RGB(250, 230, 200));
    		return m_Brush;
    	}
    
    	return hbr;
    }
    not working ...
    I override CTestDlg::OnCtlColor:
    Code:
    HBRUSH CTestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
    {
    	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
    
    	// TODO: Change any attributes of the DC here
    
    	// TODO: Return a different brush if the default is not desired
    
    //	if(CTLCOLOR_SCROLLBAR == nCtlColor)
    	{
    		pDC->SetTextColor(RGB(200, 34, 0));
    		pDC->SetBkColor(RGB(250, 230, 200));
    		return m_Brush;
    	}
    
    	return hbr;
    }
    I colored everything, except scrollbars ) ... I attached the app demo ...

    I already tried this solution:

    http://www.codeproject.com/Articles/...r-with-a-custo

    but in my case, didn't worked ...

    My question is, how can I color the control scrollbar ? It is possible ? If yes, how ?
    I'll appreciate any hint, link, etc.

    Thank you.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)