Problem with TreeView, NM_CUSTOMDRAW and CDDS_ITEMPREPAINT

I have a TreeView (without MFC) and I want to change the background color of the text. I use the following code, as showed into the MSDN. My problem is that my app never receive the CDDS_ITEMPREPAINT message when I add a node to the tree.
The CDDS_PREPAINT is well processed.
Argh!!!!

Does anybody know WHY ?
Thank you !

// Within the WM_NOTIFY process :
case IDL_C:      // notify from my tree view
switch (ph->code)
{
case NM_CUSTOMDRAW:
{
LPNMTVCUSTOMDRAW pd = (LPNMTVCUSTOMDRAW)ph;
if (pd->nmcd.dwDrawStage==CDDS_PREPAINT)
return CDRF_NOTIFYITEMDRAW;
if (pd->nmcd.dwDrawStage==CDDS_ITEMPREPAINT)
{
pd->clrTextBk = WEYellow;
return CDRF_NEWFONT;
}
return CDRF_DODEFAULT;
}
LVL 2
lif081199Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NickRepinCommented:
Try to force repaint after adding node by InvalidateRect(hTView,clientRect); UpdateWindow(hTView)
0
NickRepinCommented:
You said you never recieve CDDS_ITEMPREPAINT. So added node is displayed w/o yellow background?
May be, it is just a yet another bug already fixed in new version of comctl32.dll?
Also sometimes Windows doesn't send notification on YOUR action. For example, SendMessage(TVM_EXPAND) doesn't cause TVN_ITEMEXPANDING. Of course, Windows must send CDDS_ITEMPREPAINT in your case, but who knows...
0
lif081199Author Commented:
Your first idea doesn't work :(
I just receive more CDDS_PREPAINT messages.

About your question, yes, each node is displayed witouht the colored bkgnd.

Note that my soft has to work with the 4.70 version of comctl32 :(
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

lif081199Author Commented:
Your first idea doesn't work :(
I just receive more CDDS_PREPAINT messages.

About your question, yes, each node is displayed witouht the colored bkgnd.

Note that my soft has to work with the 4.70 version of comctl32 :(
0
NickRepinCommented:
By the way, is your control in dialog?
If so, I wonder how dialog proc can return anything except of TRUE or FALSE.
Try to return codes in SetWindowLong(hDlg,DWL_MSGRESULT,...)
0
lif081199Author Commented:
Hum... that is a good clue. The parent is a standard window, but my encapsulation is maybe bad or corrupted.
I check immediatly.
0
lif081199Author Commented:
You win !

My NOTIFY encapsulation was returning only a BOOL. Now it works for the text.

Curiously, the background behind the cross to collapse/expand a node stay uncolored. I still have to work :(

Please post a message as an answer to get your points.

And thank you a lot !

Lionel.
0
NickRepinCommented:
You could accept my comment as answer.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.