Had to check the latest API docs online.
You are dealing with an advanced feature only found in the 6.0 common control DLL (requires XP and Themed or Vista).
It appears it is possible to create a unique window handle for each item. I would guess then you could get a unique DC for that handle. Likely the treeview is creating a unique child window for each item.
If you create an item using this extended style (TVM_SETITEM) you should be able to get the handle using TVM_GETITEM.
see: http://msdn.microsoft.com/en-us/libr...59(VS.85).aspx
Announcement
Collapse
No announcement yet.
wanted: method to get DC of a treeview item
Collapse
X
-
Originally posted by Chris Boss View PostYou don't get a DC for an individual item.
The TVM_GETITEMHEIGHT message can be sent to the control to get the height of items (they should all be the same).
The aim is to set TVITEMEX.iintegral to a value which will just allow the desired text to be DRAWTEXTed in. I had assumed that by getting the default font from control, as opposed to the TV item, that I was sizing the RECT wrongly. However, it looks more as if I was just drawing the wrong thing, and the sizing of the item was working correctly.
Read the API docs about these messages to learn how to use them correctly.
Leave a comment:
-
You don't get a DC for an individual item.
You only get a DC for a windows clients area (the entire area inside the borders).
The TVM_GETITEMHEIGHT message can be sent to the control to get the height of items (they should all be the same).
The TVM_GETITEMRECT can be sent to fill a RECT structure with the coordinates of a specific item. Read the API docs about these messages to learn how to use them correctly.
Leave a comment:
-
wanted: method to get DC of a treeview item
In order to set the height of the treeview item to accomodate some text, I need to get its DC in order to measure the height required. But I can't find out how to get this DC, except in the NM_CUSTOMDRAW message. But by and by then it is too late, because changing the item's height at this point results in - guess what - more NM_CUSTOMDRAW messages and it all gets a bit blurred.Tags: None
Leave a comment: