I have upgraded to Delphi XE from 2009 and am experiencing a strange issue.
I create a new project, put down a TRibbon control, compile and run. Keeping the form in its default size I then minimize and restore without issues. I then maximise the form, minimize and restore and the form colour is changed to black.
I have no random code to change it and am using all defaults Delphi XE comes with and it does it each and every time without fail.
I have moved the compiled exe to a friends computer and the problem remains so I know it's not my computer. If I turn off Aero effects the problem goes away, but put Aero back on and the problem returns.
Any ideas at all? I'm having trouble finding any relevant threads regarding this issue across the interwebs.
Thanks, Seb
Edit (as requested, the DFM for the Form that displays this behaviour. Note: This happens on any project I start):
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 555
ClientWidth = 989
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
PrintScale = poNone
Scaled = False
PixelsPerInch = 96
TextHeight = 13
object Ribbon1: TRibbon
Left = 0
Top = 0
Width = 989
Height = 143
Caption = 'Ribbon1'
ExplicitLeft = 104
ExplicitTop = 296
ExplicitWidth = 0
StyleName = 'Ribbon - Luna'
end
end
Nothing fanciful at all, it's just a new project with a single form.
I am able to reproduce the bug, here are some of the issues I discovered. Maybe they'll help someone figure this thing out.
- If I place a button on the form and call
Invalidate
from the button'sOnClick
event, the form gets it's colors back. - If I place a place a timer on the form, enable the timer from
WndProc
onWM_SIZE
withwParam
=SIZE_MAXIMIZED
, then callInvalidate
from the timer the form gets it's colors back. This is essentially the same as the first method (callingInvalidate
from a button), but the timer makes this automatic and ensuresInvalidate
is called only when there are no more messages to be processed. I tried the same with a simplePostMessage
but didn't work (ie: I was probablyInvalidate
-ing too soon, and that's probably an other clue) - Interesting: If I make
Application.MainFormOnTaskbar := False
in the project's source, I no longer see the black form.
Workaround
The ribbon takes up the top part of the form. Place a TPanel
on the rest of the form, make it Align = alClient
and put everything on the Panel. The Black behind the panel is no longer visible!
You should enable glass frame when using Ribbon, because the Ribbon control is especially designed to work with aero glass frames on. Secondly you should do a little more work to configure your ribbon, adding an application menu, and some panes, to have it work as designed. I don't believe that "ribbon by itself" without any tab groups, or a system menu, is going to render properly at runtime.
If you want the ribbon to work on systems with Aero glass enabled, you should enable the glass frame property (Form.GlassFrame.Enabled) , and turn on Form.DoubleBuffered property, add some tab pages, add some tab groups, and add a system menu. Lots of steps.
Please try the attached ribbon starter project. (ribbonStarter.zip 88k)
Update If even my ribbonStarter produces the same result on your system, perhaps this should be logged in Quality Central. It is possibly a bug in your video driver, for which some code workaround in the ribbon and form code could be made.
来源:https://stackoverflow.com/questions/6490900/delphi-xe-with-aero-effects-causes-paint-issue