January 14, 2010   Posted by: Anthony G. Cyphers

REALbasic and Snow Leopard: Redraw what?!

A customer has tasked me with updating some of the UI elements in their application. Among the problems they listed was a redraw bug in Snow Leopard, where the controls on windows with a set background color would display a slightly different color in their background even with the Composite property set to True. After about an hour of testing different workarounds, I found what I believe to be an excellent solution.

In this application, all of the windows have a set background color, but only a few displayed the error. I had absolutely no luck in determining the difference, so I can only assume that it’s an inconsistent REALbasic bug. Here’s how I fixed it:

  1. Add a new object to your project, mine is named “WindowHack,” and set it’s Super to “Window.”
  2. Open the window subclass, and navigate to the “Paint” event.
  3. Inside the “Paint” event, add the following block of code:
    #if TargetMacOS then
    If Me.HasBackColor Then
    g.ForeColor = me.BackColor
    g.FillRect( 0, 0, g.Width, g.Height )
    End If
    #endif
  4. Now set the Super of the windows with the problem to “WindowHack” and test.

This seemed to be the most elegant solution I could find to the problem and, quite honestly, the root of the issue still eludes me. Any thoughts on what might be causing this inconsistency?

Comments Off posted in: Code Snipets   |   Programming
About the author

Anthony G. Cyphers - The sole proprietor of CyphersTECH Consulting. With a history in development dating back to DOS, he knows his stuff. He began programming in QuickBasic, and moved up through Visual Basic classic until the .NET platform was released. After spending some time working in .NET, he discovered what was then called "REALbasic", and has been developing for that platform ever since. Languages: ActionScript, JavaScript, PHP, VB, REALbasic, VB.NET, PERL