2

I have a base class which is a form, which has a ToolStrip which contains in this order:

  • A label with an image and text
  • Three labels which are just images
  • A label with just text (spring = true)
  • A progress bar
  • A dropdown button

I am working in an MDI environment, and the forms in question are MDIChildren. Upon application closing, the Size, Location, and WindowState of all the forms are saved. When the application loads, these states are restored. The problem manifests when a form's WindowState is normal so the MDI form loads with that form open, not minimized. That form's toolbar will have black areas where the labels and dropdown button should be. The progress bar looks OK for what it's worth. The forms which start minimized render OK when restored.

I have not been able to reproduce this behavior with a minimalist version of my code, so I haven't provided any code. I'm wondering if there is something obvious which would create the black areas, and if there is something I can do to force these items to be drawn after the form is shown, or even later.

The base class:

InstrumentForm, the base class

An inheriting form without the black area:

LaserControl, inherits InstrumentForm, toolbar OK

An inheriting form with the black area (bad):

LoggerForm, inherits InstrumentForm, toolbar not OK

djv
  • 15,168
  • 7
  • 48
  • 72
  • 4
    Are you doing something special like overriding OnPaint, OnPaintBackground, WndProc, etc? Try to remove these (even if the rest isn't working anymore) to narrow down the problem – Simon Mourier Jan 17 '15 at 11:48
  • Try listening to the Disposed event on one of the controls that turns to a black rectangle. – Loathing Jan 18 '15 at 20:13
  • 1
    Upvote for Simon Mourier - black background issues on winforms almost always stem from overriding one of those methods and failing to call the base implementation. If you are overriding any of them, provide that code. – Octopoid Jan 19 '15 at 20:26
  • @SimonMourier I just checked and I haven't overridden anything. – djv Jan 20 '15 at 17:59
  • @Verdolino - or maybe you're using 3rd party controls that would mess things up? – Simon Mourier Jan 20 '15 at 18:08
  • @SimonMourier No I haven't. They are just some `ToolStripStatusLabel`s, and a `ToolStripDropDownButton`. – djv Jan 20 '15 at 18:58
  • Have you seen this: http://stackoverflow.com/questions/24379233/toolstripstatuslabel-displayed-as-black-box – Simon Mourier Jan 20 '15 at 19:37
  • @SimonMourier No, that's it! Instead of the StatusStrip behind the windows toolbar, it's outside the bounds of the MDI window - yields the same result. – djv Jan 20 '15 at 19:39
  • @SimonMourier You deserve the bounty, make an answer. Thanks! – djv Jan 20 '15 at 19:41
  • 2
    Well, it's more a duplicate, I don't deserve much :-) You should instead remove the bounty and close it as a duplicate (is it possible, I don't know), or try to ping Hans Passant if he wants to get the bounty – Simon Mourier Jan 20 '15 at 22:48
  • I would ping Hans (I would have asked him directly a week ago if I could have) but [I can't](http://meta.stackexchange.com/questions/431/any-way-to-send-a-personal-message-to-another-user). – djv Jan 23 '15 at 05:51

0 Answers0