On Tue, Apr 12, 2005 at 12:24:11PM -0600, Vitaliy Margolen wrote:
Also small fix for custom draw color. Native does not use colors returned from NM_CUSTOMDRAW notify.
This is odd, and it deserves at the very least a comment in the code, but more preferably a unit test.
Tuesday, April 12, 2005, 3:09:57 PM, you wrote:
On Tue, Apr 12, 2005 at 12:24:11PM -0600, Vitaliy Margolen wrote:
Also small fix for custom draw color. Native does not use colors returned from NM_CUSTOMDRAW notify.
This is odd, and it deserves at the very least a comment in the code, but more preferably a unit test.
Well, yes and no. This is custom draw callback/notify. It shouldn't change control's parameters, such as color. At least on a permanent basis. This is what set color messages for.
I have a Delphi Custom TreeView sample that has all kinds of problems. For one, the colors it is setting are not displayed correctly. Second, and mach bigger problem, it goes into endless loop. I have traced this down to SetItemT invalidating new item if anything got changed. The problem is Delphi using callbacks for both image indexes.
Also I can't quite understand why TVM_GETITEM for iImage returns something like 0x4079D5D0 while traces show 0, 1 or 3 dependant on open/closed/has children.
I'm working on it right now to see what could be done about it. At the very least we should distinguish what should cause screen update and what's not. Simple memcmp doesn't cut it here. So far it looks like we'll have to do something different if iImage or iSelectedImage returned as a callback.
As far as conformance tests go, I'm not sure how to do it. The part I would like to test is what changes could cause TreeView node to get invalidated. Do I have to subclass TreeView to define notify message handler? if not, how to do this inside the conformance test?
Vitaliy
On Tue, Apr 12, 2005 at 04:13:32PM -0600, Vitaliy Margolen wrote:
Well, yes and no. This is custom draw callback/notify. It shouldn't change control's parameters, such as color. At least on a permanent basis. This is what set color messages for.
Agreed. But judging by what listview is doing, we do need to use them when we are drawing the item (or whatever). But I agree, we must not change those parameters permanently.
Also I can't quite understand why TVM_GETITEM for iImage returns something like 0x4079D5D0 while traces show 0, 1 or 3 dependant on open/closed/has children.
I guess this needs more debugging :)
Tuesday, April 12, 2005, 10:57:02 PM, you wrote:
On Tue, Apr 12, 2005 at 04:13:32PM -0600, Vitaliy Margolen wrote:
Well, yes and no. This is custom draw callback/notify. It shouldn't change control's parameters, such as color. At least on a permanent basis. This is what set color messages for.
Agreed. But judging by what listview is doing, we do need to use them when we are drawing the item (or whatever). But I agree, we must not change those parameters permanently.
Ok, I need help here. I spend half a day trying to fix this. I moved send notify after color and font setup in TREEVIEW_DrawItem. It's getting closer to native. But! No matter what I try, I can't set background color from within Delphi App on DrawItemNotify. Which does work on windows.
Am I missing something? I changed text mode to opaque, so it should use current brush color for background. But when I printing GetDCBrushColor it stays the same! Could we have a problem somewhere in GDI?
Also I can't quite understand why TVM_GETITEM for iImage returns something like 0x4079D5D0 while traces show 0, 1 or 3 dependant on open/closed/has children.
I guess this needs more debugging :)
I haven't debugged this one yet. I have a filling that it's callback messing things up. It could be that Delphi does not respond correctly to updete disp info notifies when they sent not from drawing code. Not a problem right now. It's doing the same on native.
Vitaliy Margolen wrote:
Tuesday, April 12, 2005, 10:57:02 PM, you wrote:
On Tue, Apr 12, 2005 at 04:13:32PM -0600, Vitaliy Margolen wrote:
Well, yes and no. This is custom draw callback/notify. It shouldn't change control's parameters, such as color. At least on a permanent basis. This is what set color messages for.
Agreed. But judging by what listview is doing, we do need to use them when we are drawing the item (or whatever). But I agree, we must not change those parameters permanently.
Ok, I need help here. I spend half a day trying to fix this. I moved send notify after color and font setup in TREEVIEW_DrawItem. It's getting closer to native. But! No matter what I try, I can't set background color from within Delphi App on DrawItemNotify. Which does work on windows.
Am I missing something? I changed text mode to opaque, so it should use current brush color for background. But when I printing GetDCBrushColor it stays the same! Could we have a problem somewhere in GDI?
It seems fairly simple to me. You need to make a note of what the app changed the nmtvcd.clrTextBk field to (I do this in the toolbar control by passing the notify structure around), and then changes some lines in TREEVIEW_DrawItem: hbrBk = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); -> if (nmtvcd->clrTextBk != CLR_NONE) hbrBk = CreateSolidBrush(nmtvcd->clrTextBk); else hbrBk = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
and then further down: if ((infoPtr->dwStyle & TVS_TRACKSELECT) && (wineItem == infoPtr->hotItem)) -> if (nmtvcd->clrTextBk != CLR_NONE) hbrBk = CreateSolidBrush(nmtvcd->clrTextBk); if ((infoPtr->dwStyle & TVS_TRACKSELECT) && (wineItem == infoPtr->hotItem))
Rob
Thursday, April 14, 2005, 11:50:50 AM, you wrote:
Vitaliy Margolen wrote:
Tuesday, April 12, 2005, 10:57:02 PM, you wrote:
On Tue, Apr 12, 2005 at 04:13:32PM -0600, Vitaliy Margolen wrote:
Well, yes and no. This is custom draw callback/notify. It shouldn't change control's parameters, such as color. At least on a permanent basis. This is what set color messages for.
Agreed. But judging by what listview is doing, we do need to use them when we are drawing the item (or whatever). But I agree, we must not change those parameters permanently.
Ok, I need help here. I spend half a day trying to fix this. I moved send notify after color and font setup in TREEVIEW_DrawItem. It's getting closer to native. But! No matter what I try, I can't set background color from within Delphi App on DrawItemNotify. Which does work on windows.
Am I missing something? I changed text mode to opaque, so it should use current brush color for background. But when I printing GetDCBrushColor it stays the same! Could we have a problem somewhere in GDI?
It seems fairly simple to me. You need to make a note of what the app changed the nmtvcd.clrTextBk field to (I do this in the toolbar control by passing the notify structure around), and then changes some lines in TREEVIEW_DrawItem: hbrBk = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
->>
if (nmtvcd->clrTextBk != CLR_NONE) hbrBk = CreateSolidBrush(nmtvcd->clrTextBk); else hbrBk = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
and then further down: if ((infoPtr->dwStyle & TVS_TRACKSELECT) && (wineItem ==
infoPtr->>hotItem)) ->>
if (nmtvcd->clrTextBk != CLR_NONE) hbrBk = CreateSolidBrush(nmtvcd->clrTextBk); if ((infoPtr->dwStyle & TVS_TRACKSELECT) && (wineItem ==
infoPtr->>hotItem))
Thank you! One thing I can't understand is why I couldn't see those changes directly in DC? Unless there are something more going on inside Delphi components. Any way, thanks for you help, patch in a queue.
Vitaliy Margolen wrote:
Thursday, April 14, 2005, 11:50:50 AM, you wrote:
Vitaliy Margolen wrote:
Ok, I need help here. I spend half a day trying to fix this. I moved send notify after color and font setup in TREEVIEW_DrawItem. It's getting closer to native. But! No matter what I try, I can't set background color from within Delphi App on DrawItemNotify. Which does work on windows.
Am I missing something? I changed text mode to opaque, so it should use current brush color for background. But when I printing GetDCBrushColor it stays the same! Could we have a problem somewhere in GDI?
Thank you! One thing I can't understand is why I couldn't see those changes directly in DC? Unless there are something more going on inside Delphi components. Any way, thanks for you help, patch in a queue.
{Set,Get}DCBrushColor do something different to what you expect. They set the DC_BRUSH colour, not the colour of the current brush selected into the DC. You can get select it into the DC using SelectObject(GetStockObject(DC_BRUSH)). The concept was probably introduced for this very use though, so you don't have to create a temporary solid brush and then delete it again.
Rob
Thursday, April 14, 2005, 2:49:45 PM, you wrote:
{Set,Get}DCBrushColor do something different to what you expect. They set the DC_BRUSH colour, not the colour of the current brush selected into the DC. You can get select it into the DC using SelectObject(GetStockObject(DC_BRUSH)). The concept was probably introduced for this very use though, so you don't have to create a temporary solid brush and then delete it again.
Ah, I see. Thank you for an explanation! It's name a bit misleading then (what a surprise). I was using those for traces, and it got me more confused. Shouldn't affect my patch since I used Set(Bk/Text)Color. Still waiting on AJ.
Vitaliy