GDI+ ownerdrawn troubles

  • Thread starter Thread starter Danny van Kasteel
  • Start date Start date
D

Danny van Kasteel

Hi,

I'm having some trouble drawing items in controls that I've marked as
ownerdrawn.
I'm currently developing an application that has ownerdrawn statusbar
panels, and a listbox that contains ownerdrawn items.

Both controls behave irratically:

The statusbar panels draw fine (the point is to draw an image in them),
EXCEPT when the form they statusbar is in is maximized. In that case, any
FillRectangle calls I make to the graphics object provided in the DrawItem
event are executed flawlessly, but any DrawRectangle or DrawImage methods
are seemingly not executed. (i.e. I don't see the image, and Rectangles are
partially drawn)

The ListBox has similar issues, except the items NEVER draw correctly :o(

Below is the code I use for the StatusBar Panels:

Private Sub StatusBar1_DrawItem(ByVal sender As Object, ByVal sbdevent As
System.Windows.Forms.StatusBarDrawItemEventArgs) Handles StatusBar1.DrawItem

Dim oImage As Image

If sbdevent.Panel Is StatusBar1.Panels(1) Then
Select Case m_oDependencyChecker.Dependencies(0).Status
Case DependencyStatus.OK
oImage = imlDependencyStatus.Images(1)
Case Else
oIage = imlDependencyStatus.Images(2)
End Select
ElseIf sbdevent.Panel Is StatusBar1.Panels(0) Then
Select Case m_oDependencyChecker.Dependencies(0).Status
Case DependencyStatus.OK
oImage = imlDependencyStatus.Images(1)
Case Else
oImage = imlDependencyStatus.Images(2)
End Select
End If

sbdevent.Graphics.DrawImage(oImage, sbdevent.Bounds.Location)



End Sub

The problems also occur when ownerdrawing the controls by inheriting from
them, so I am fairly certain that is not the issue.

Does anyone know what I'm doing wrong?

TIA,

Danny van Kasteel
 
Hello,

Danny van Kasteel said:
The problems also occur when ownerdrawing the controls
by inheriting from them, so I am fairly certain that is not the issue.

I suggest you post this question to the Windows Forms controls group:

news://news.microsoft.com/microsoft.public.dotnet.framework.windowsforms.controls
 
Back
Top