Repository navigation
Closed
Milestone
Description
.NET version
Any version.
Did it work in .NET Framework?
No
Did it work in any of the earlier releases of .NET Core or .NET 5+?
No response
Issue description
TreeView OwnerDrawText Flickering even in TVS_EX_DOUBLEBUFFER
Steps to reproduce
Add a TreeView, enable TVS_EX_DOUBLEBUFFER.
SendMessage(treeView1.Handle, TVM_SETEXTENDEDSTYLE, (IntPtr)TVS_EX_DOUBLEBUFFER, (IntPtr)TVS_EX_DOUBLEBUFFER);
Add a Node. Draw node text in DrawNode. Add a button, change node text when clicking button. Flickering happens when clicking button.
Issue in handling CDDS_ITEMPOSTPAINT.
using (Graphics g = nmtvcd->nmcd.hdc.CreateGraphics())
{
Rectangle bounds = node.Bounds;
It cannot use node boundary. It should use boundary from nmtvcd->nmcd as native TreeView control sends empty rectangle with Window DC when updating node text. Maybe for measuring purpose. In DrawNode, if user only draws inside the boundary. No actual draw will happen on window dc, no flickering.
This the WinForm log:
Changing node text
abc1 {X=21,Y=0,Width=32,Height=18} Window DC
abc1 {X=21,Y=0,Width=32,Height=18} Window DC
After change node text
abc1 {X=21,Y=0,Width=32,Height=18} Memory DC
This the native code log
change node text
---- NMTVCUSTOMDRAW ----
hdr.hwndFrom = 00000000000E03F0
hdr.idFrom = 100
hdr.code = -12 (NM_CUSTOMDRAW=-12)
dwDrawStage = 0x00000001 [PREPAINT]
hdc = FFFFFFFFFD0120CF GetObjectType=3 (WINDOW/DISPLAY DC)
hdc clipbox = (0,0,296,296) clipType=2
hdc vpOrg = (0,0) winOrg = (0,0)
rc = (0,0,0,0) 0x0
dwItemSpec = 0000000000000000 text=""
uItemState = 0x00000000 [0]
lItemlParam = 0
clrText = 0x00000000
clrTextBk = 0x00000000
iLevel = 0
---- NMTVCUSTOMDRAW ----
hdr.hwndFrom = 00000000000E03F0
hdr.idFrom = 100
hdr.code = -12 (NM_CUSTOMDRAW=-12)
dwDrawStage = 0x00010001 [ITEMPREPAINT]
hdc = FFFFFFFFFD0120CF GetObjectType=3 (WINDOW/DISPLAY DC)
hdc clipbox = (0,0,296,296) clipType=2
hdc vpOrg = (0,0) winOrg = (0,0)
rc = (0,0,0,0) 0x0
dwItemSpec = 00000242062F4F50 text="abc1"
uItemState = 0x00000000 [0]
lItemlParam = 0
clrText = 0xFFFFFFFF
clrTextBk = 0x00FFFFFF
iLevel = 0
---- NMTVCUSTOMDRAW ----
hdr.hwndFrom = 00000000000E03F0
hdr.idFrom = 100
hdr.code = -12 (NM_CUSTOMDRAW=-12)
dwDrawStage = 0x00010002 [ITEMPOSTPAINT]
hdc = FFFFFFFFFD0120CF GetObjectType=3 (WINDOW/DISPLAY DC)
hdc clipbox = (0,0,296,296) clipType=2
hdc vpOrg = (0,0) winOrg = (0,0)
**rc = (0,0,0,0) 0x0**
dwItemSpec = 00000242062F4F50 text="abc1"
uItemState = 0x00000000 [0]
lItemlParam = 0
clrText = 0xFFFFFFFF
clrTextBk = 0x00FFFFFF
iLevel = 0
After change node text
---- NMTVCUSTOMDRAW ----
hdr.hwndFrom = 00000000000E03F0
hdr.idFrom = 100
hdr.code = -12 (NM_CUSTOMDRAW=-12)
dwDrawStage = 0x00000001 [PREPAINT]
hdc = 000000001A01231C GetObjectType=10 (MEMORY DC)
hdc clipbox = (0,0,296,18) clipType=2
hdc vpOrg = (0,0) winOrg = (0,0)
rc = (0,0,296,18) 296x18
dwItemSpec = 0000000000000000 text=""
uItemState = 0x00000000 [0]
lItemlParam = 0
clrText = 0x1A01231C
clrTextBk = 0x00000000
iLevel = -486201896
---- NMTVCUSTOMDRAW ----
hdr.hwndFrom = 00000000000E03F0
hdr.idFrom = 100
hdr.code = -12 (NM_CUSTOMDRAW=-12)
dwDrawStage = 0x00010001 [ITEMPREPAINT]
hdc = 000000001A01231C GetObjectType=10 (MEMORY DC)
hdc clipbox = (0,0,296,18) clipType=2
hdc vpOrg = (0,0) winOrg = (0,0)
rc = (0,0,296,18) 296x18
dwItemSpec = 00000242062F4F50 text="abc1"
uItemState = 0x00000000 [0]
lItemlParam = 0
clrText = 0x00000000
clrTextBk = 0x00FFFFFF
iLevel = 0
---- NMTVCUSTOMDRAW ----
hdr.hwndFrom = 00000000000E03F0
hdr.idFrom = 100
hdr.code = -12 (NM_CUSTOMDRAW=-12)
dwDrawStage = 0x00010002 [ITEMPOSTPAINT]
hdc = 000000001A01231C GetObjectType=10 (MEMORY DC)
hdc clipbox = (0,0,296,18) clipType=2
hdc vpOrg = (0,0) winOrg = (0,0)
**rc = (0,0,296,18) 296x18**
dwItemSpec = 00000242062F4F50 text="abc1"
uItemState = 0x00000000 [0]
lItemlParam = 0
clrText = 0x00000000
clrTextBk = 0x00FFFFFF
iLevel = -2
Metadata
Metadata
Assignees
Labels
No labels
Activity
Zheng-Li01 commentedon Nov 19, 2026
Verified the issue with .NET 12.0.0-alpha.1.26568.110, the issue has been fixed as below screenshot.
15345.mp4