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 ...
Soon as I applied that solution, the control scrollbar doesn't drawn anymore, part of the control (CGridCtrl) didn't drawn as well, the focus on this control (CGridCtrl) has weird behavior ... and I have to mention that this solution applied on test application that has the same CGridCtrl, work pretty correct (looks ugly, but is working) ...
scrollbars which are shown in windows having WS_HSCROLL and/or WS_VSCROLL style;
scrollbar common controls (of window class "ScrollBar").
WM_CTLCOLOR messages are sent to the parent to allow changing the default colors of its child controls. So, what you tried to achieve in your test application uploaded here, works only for scrollbar controls (kind #2).
In fact, it is logical to be like that, as long CTLCOLOR_BTN change color of a button, CTLCOLOR_EDIT change color of a edit box, CTLCOLOR_SCROLLBAR should change color of an CScrollbar control, not some scrollbars of some controls ... I have to dig in ...
I think I found a solution to colorize the scrollbars: using FlatSB_SetScrollProp ... and is almost done, except one thing: OS redraw the control scrollbars when I click on scrollbars ... could you give a hand to solve this issue ? I am struggling for weeks about this problem ... see attachment ...
I think I found a solution to colorize the scrollbars: using FlatSB_SetScrollProp ... and is almost done, except one thing: OS redraw the control scrollbars when I click on scrollbars ... could you give a hand to solve this issue ? I am struggling for weeks about this problem ... see attachment ...
Super!
You did not answer this question yet:
Originally Posted by VictorN
Define "didn't work".
And how does "your" case differ from the case described in the article?
So you are expecting that we will be now searching for the differences between the original code and your own implementation?
I think I make myself unclear: I succeeded into color scrollbars (of an control, let say CListBox), but not with this: http://www.codeproject.com/Articles/...r-with-a-custo solution, but using FlatSB_SetScrollProp ... The only thing that remain is that this scrollbars (custom colorized) are switch back into original color when I click them ... yes, seems to be the same project, but it has another solution to colorize scrollbars ...
Last edited by mesajflaviu; February 26th, 2015 at 04:36 AM.
"And how does "your" case differ from the case described in the article?"
That solution applied on my case, is not function at all, I mean, the scrollbars has vanish completely ... I know, sounds illogical, but this is the fact ... that is why I searched for another solution ...
Yes, put this solution: http://www.codeproject.com/Articles/...r-with-a-custo
into simple test app, had worked, but looks pretty ugly ... but when I had applied that on my real app, the scrollbars has disappeared completely ... so, the better choice is to search another solution ...
Last edited by mesajflaviu; February 27th, 2015 at 07:06 AM.
"So you are expecting that we will be now searching for the differences between the original code and your own implementation"
I would not have this expectation, of course ... the only thing is, I didn't explain why scrollbars, once I applied FlatSB_SetScrollProp properties, is redrawn as original color ... that is all ...
I think I found a solution to colorize the scrollbars: using FlatSB_SetScrollProp ... and is almost done, except one thing: OS redraw the control scrollbars when I click on scrollbars ... could you give a hand to solve this issue ? I am struggling for weeks about this problem ... see attachment ...
From MSDN:
Remarks
Note Flat scroll bar functions are implemented in Comctl32.dll versions 4.71 through 5.82. Comctl32.dll versions 6.00 and higher do not support flat scroll bars.
but when I had applied that on my real app, the scrollbars has disappear completely ...
... which means you applied that wrong way.
so, the better choice is to search another solution ...
A choice, don't know better or worse, would be to understand the suggested solution in details. Did you? Do you understand what the code does, and what for? Do you see how new supplementary windows appear? Do you see how those windows change original z-order, subclass original controls, route scroll messages? Unless you do, all the code would seem doing a kind of magic while it's just a pure technique.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.