Advertisement

Custom Draw with a TreeView control

Started by May 16, 2001 11:59 AM
3 comments, last by Tornado 23 years, 8 months ago
I'm trying to use Custom Draw with a TreeView control, not trying to draw anything yet! Just trying to get the right notification messages. I had a look at this code example from the MSDN but it just won't work. Here it is:
    
case NM_CUSTOMDRAW:
{
NMTVCUSTOMDRAW *lpNMCD = (NMTVCUSTOMDRAW*)lParam;

switch (lpNMCD->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
return CDRF_NOTIFYITEMDRAW;
case CDDS_ITEMPREPAINT:
{
 // the problem is that we never get to this stage		

} break;
}
} break;
    
When the stage is CDDS_PREPAINT I "ask" the control to report back information when it draws items, but for some weird reason, it doesn't... Thanks for your help! - Goblineye Entertainment The road to success is always under construction Edited by - Tornado on May 16, 2001 1:02:06 PM
Goblineye EntertainmentThe road to success is always under construction
This is supported only in later versions of windows (says ComCtl32.dll version 4.7 in MSDN whatever that is - probably is IE4 - you can check by right clicking on this file in system dir and checking its version).

Other than that it looks the same as the example in MSDN to me.

Sometimes there is a style you have to set (I was thinking it was WS_NOTIFY but I couldn''t find that) to get the controls to send WM_NOTIFY at all. I''ll keep looking and post if I find a style for that one

Hope that hlps

DSutherland
Advertisement
quote:

This is supported only in later versions of windows (says ComCtl32.dll version 4.7 in MSDN whatever that is - probably is IE4 - you can check by right clicking on this file in system dir and checking its version).



Nope, that''s not it My Common Controls are v5.81...

quote:

Sometimes there is a style you have to set (I was thinking it was WS_NOTIFY but I couldn''t find that) to get the controls to send WM_NOTIFY at all. I''ll keep looking and post if I find a style for that one



The WM_NOTIFY is sent to the parent of an item to notify the parent of... "stuff"
So it needs no settings.
Neither there is a special style for Custom Draw since it''s a service. I "tell" the common control if I want it to provide it for me by returning CDRF_NOTIFYITEMDRAW when the CDDS_PREPAINT stage is sent.

Thanks for your help!



- Goblineye Entertainment
The road to success is always under construction
Goblineye EntertainmentThe road to success is always under construction
OK, the problem is solved
I thought I might have missed something so I had another look at the WM_NOTIFY message I hate so much...
Anyway, I just found out that because the message was received in my dialog procedure I need to return a value like this:

    // Assume hwndDlg is the handle to the dialogSetWindowLongPtr(hwndDlg,DWL_MSGRESULT,CDRF_NOTIFYITEMDRAW); // the SetWindowLongPtr is to keep compatibility with 64bit Windows for laterreturn(true); // so no more messages will be processed    


Thanks again



- Goblineye Entertainment
The road to success is always under construction

Edited by - Tornado on May 17, 2001 10:16:05 AM
Goblineye EntertainmentThe road to success is always under construction
Coolness! I see now - you have one function OnNotify and that gets called from the DlgProc. Doesn''t matter what you return from OnNotify if you let windows call the def dlg proc from DlgProc (does it automatically based on that return value), then it wipes out whatever you did.



Doug Sutherland

This topic is closed to new replies.

Advertisement