views:

72

answers:

4

Very strange thing happening:

I had a whole bunch of TFrame's (might have been TCustomFrame, don't remember because I made an intermediate class between the 40 odd frames and the parent) that I was inheriting to make up the configuration part of a 'really cool' HL7 formula editor. What was weird, but not to the point, was that the DFM on the frame kept on adding OldCreateOrder, PixelsPerInch and TextHeight to the DFM, even though I never implemented those properties in the base class.

Anyway, I had to put those properties in my subclass even though I didn't want to, or else it wouldn't let me compile, so fine. Then I added one of those Color Chooser controls to one of my frames, and that worked until last week when it started giving me the business about not being able to find the parent.

So... I got rid of all my DFM's I changed all the Frames to Panels and it works fine (on my computer, running XP in VM with no themes), but for my colleague to the left of me (running Windows 7 natively) it doesn't matter what I do with TSpeedButtons on these Panels, they always have the same Sans 10pt Bold font, which would work, but I've got some weird symbols for set operations which I'd like to retain and CalcTextWidth totally fails.

I've tried:

  • ParentFont := true and false;
  • Flat := true and false;
  • Parent.Font := Whatever;

Suffice it to say, I've tried all the old tricks. The only thing that works is just removing the XP Manifest (did I mention this is Delphi 7). And that's not an option because sometime this year we're going to port everything over to D2009 and that... won't be an option!

Edit

The really strange thing is that using TFrame and a DFM, it works (even with an ancient compiler). Using TPanel it doesn't work.

There must be some difference between themes on a TPanel (or TCustomPanel, neither worked) and themes on a TFrame.

Also, I've got a TGroupBox between the buttons and the TPanel. Maybe that's causing the problem. I could change that pretty easy.

Edit 2

uses buttons, extctrls, stdctrls

(for Delphi 7, put XPManifest on your form)

procedure TForm1.FormCreate(Sender: TObject);
var
  Panel : TPanel;
  Grp : TGroupBox;
  Btn : TSpeedButton;
begin
  Panel := TPanel.Create(Self);
  Panel.Parent := self;
  Panel.Align := alClient;

  Grp := TGroupBox.Create(Panel);
  Grp.Parent := Panel;
  Grp.Align := alClient;

  Btn := TSpeedButton.Create(Grp);
  Btn.Parent := Grp;

  Btn.Width := 117;
  Btn.Font.Name := 'Symbol';
  Btn.Caption := 'Here is some text';


end;

In windows XP fine, tried on 2008 Server R2 and just shows bold sans font.

I tried this without the Group Box in between and it seems to work though.

(doing it with the frame works, but is too much code to post)

+2  A: 

Delphi 7 was released in August of 2002. Vista came out in 2007 and Windows 7 in 2009. I think to expect a compiler and dev system from 2002 to work with all the new stuff in Vista/7 is a bit much to expect. Upgrade and you will probably see things work.

Of course, upgrading a compiler, particularly for a large application, is never easy.

I do feel for you, but I would not call it a bug in the VCL.

gbrandt
A: 

Well, I'll write an answer to my own question, because today's answer isn't upgrade.

Just override the Paint function in the TSpeedButton, you're not using it on the form anyway.

Then, when you finally do update all 12 million lines of code to D2009, if is problem occurs again, then you can keep that code as one of those fancy helper class functions if you don't want subclass TSpeedButton.

Peter Turner
+1  A: 

I'll try to answer this question for you first:

What was weird, but not to the point, was that the DFM on the frame kept on adding OldCreateOrder, PixelsPerInch and TextHeight to the DFM, even though I never implemented those properties in the base class.

This might have to do with either

  1. Frame inheritance (your DFM file contains the wrong keyword: object in stead if inherited, see this blog posting)

  2. Your .DPR file where the comment behind your Frame unit is wrong (the comment actually is not a comment, it is a hint to the Delphi IDE to tell it which frame, form or datamodule designer it needs to choose)

Let us know if that helps; then focus on the TSpeedButton problem.

--jeroen

Jeroen Pluimers
Wow, I can see that would have really helped! Not going to roll back my changes now (unless I can't fix the speedbutton thing, which I'm sure I can by overriding the paint function to skip theme stuff), I think they're for the better - even though my code looks more like C++ now.
Peter Turner
Just roll back to the version in your version control system ;-)
Jeroen Pluimers
A: 

OK, here's the answer that worked:

groupbox.ParentBackground := false

Not sure why the background of the group box changes the foreground of the speed button.

Peter Turner