Messages for drawitem

  • Thread starter Thread starter barry
  • Start date Start date
B

barry

Hi

is the drawitemstate of drawitem method of comobox defferent for Windows XP
and Windows 2003, how does one solve such problems

TIA
Barry
 
if you echo the e.state.ToString() of the drawitem event it shows

"None" or "Selected" in Windows 2003

"NoAccelerator, NoFocus" or "Selected, NoAccelerator, NoFocusRect" in
Windows XP
 
I prefer to ignore such EXPERT comments

Peter Duniho said:
.NET doesn't use messages, it uses events. And they will be the same for
a given .NET version, regardless of OS version. There's no "problem" to
solve.

Pete
 
Since the DrawItemState enumeration has a flags attribute, the values can be
"or'ed" together. This could occur regardless of the OS version. It appears
the defaults, probably due to visual styles or themes, are different between
the OS's in question.

barry said:
if you echo the e.state.ToString() of the drawitem event it shows

"None" or "Selected" in Windows 2003

"NoAccelerator, NoFocus" or "Selected, NoAccelerator, NoFocusRect" in
Windows XP

Alex Meleta said:
Hi barry,

Hmmmm... for instance, like this
http://www.codeproject.com/KB/combo...osition&view=Quick&select=1953419#xx1953419xx

Regards,
Alex Meleta [Tech Blog: http://devkids.blogspot.com]

b> Hi
b> b> is the drawitemstate of drawitem method of comobox defferent for
b> Windows XP and Windows 2003, how does one solve such problems
b> b> TIA
b> Barry
 
Thanks for your reply

MSDN suggests the following (not tried it myself, but i solved the problem
in my app)

// Draws the backgrounds for entire ListView items.
private void listView1_DrawItem(object sender,
DrawListViewItemEventArgs e)
{
if ((e.State & ListViewItemStates.Selected) != 0)
{
// Draw the background and focus rectangle for a selected item.
e.Graphics.FillRectangle(Brushes.Maroon, e.Bounds);
e.DrawFocusRectangle();
}
else
{
// Draw the background for an unselected item.
using (LinearGradientBrush brush =
new LinearGradientBrush(e.Bounds, Color.Orange,
Color.Maroon, LinearGradientMode.Horizontal))
{
e.Graphics.FillRectangle(brush, e.Bounds);
}
}

// Draw the item text for views other than the Details view.
if (listView1.View != View.Details)
{
e.DrawText();
}
}
Family Tree Mike said:
Since the DrawItemState enumeration has a flags attribute, the values can
be
"or'ed" together. This could occur regardless of the OS version. It
appears
the defaults, probably due to visual styles or themes, are different
between
the OS's in question.

barry said:
if you echo the e.state.ToString() of the drawitem event it shows

"None" or "Selected" in Windows 2003

"NoAccelerator, NoFocus" or "Selected, NoAccelerator, NoFocusRect" in
Windows XP

Alex Meleta said:
Hi barry,

Hmmmm... for instance, like this
http://www.codeproject.com/KB/combo...osition&view=Quick&select=1953419#xx1953419xx

Regards,
Alex Meleta [Tech Blog: http://devkids.blogspot.com]

b> Hi
b> b> is the drawitemstate of drawitem method of comobox defferent for
b> Windows XP and Windows 2003, how does one solve such problems
b> b> TIA
b> Barry
 
Correct, the drawing for a listviewitem would be handled similar to that for a
combobox. The flags are or'ed together in both cases. Glad you got it
working.

barry said:
Thanks for your reply

MSDN suggests the following (not tried it myself, but i solved the problem
in my app)

// Draws the backgrounds for entire ListView items.
private void listView1_DrawItem(object sender,
DrawListViewItemEventArgs e)
{
if ((e.State & ListViewItemStates.Selected) != 0)
{
// Draw the background and focus rectangle for a selected item.
e.Graphics.FillRectangle(Brushes.Maroon, e.Bounds);
e.DrawFocusRectangle();
}
else
{
// Draw the background for an unselected item.
using (LinearGradientBrush brush =
new LinearGradientBrush(e.Bounds, Color.Orange,
Color.Maroon, LinearGradientMode.Horizontal))
{
e.Graphics.FillRectangle(brush, e.Bounds);
}
}

// Draw the item text for views other than the Details view.
if (listView1.View != View.Details)
{
e.DrawText();
}
}
Family Tree Mike said:
Since the DrawItemState enumeration has a flags attribute, the values can
be
"or'ed" together. This could occur regardless of the OS version. It
appears
the defaults, probably due to visual styles or themes, are different
between
the OS's in question.

barry said:
if you echo the e.state.ToString() of the drawitem event it shows

"None" or "Selected" in Windows 2003

"NoAccelerator, NoFocus" or "Selected, NoAccelerator, NoFocusRect" in
Windows XP

Hi barry,

Hmmmm... for instance, like this
http://www.codeproject.com/KB/combo...osition&view=Quick&select=1953419#xx1953419xx

Regards,
Alex Meleta [Tech Blog: http://devkids.blogspot.com]

b> Hi
b> b> is the drawitemstate of drawitem method of comobox defferent for
b> Windows XP and Windows 2003, how does one solve such problems
b> b> TIA
b> Barry
 
Back
Top