I have written a code with Delphi 2009 and updated my CodeGear Delphi to XE2. It compiled perfectly with Delphi 2009, but now it doesn't ! It gives me this error instead :

[DCC Error] Incompatible types: 'TFormStyle' and 'TTeeFontStyle'! I tried creating a new Vcl Forms Application and wrote the command that generates this error :

Form1.FormStyle := FsNormal;

and it compiled perfectly too,I don't know why is this happening, although I believe there's nothing wrong with my syntax, please help, thanks. This is the code that is not compiling :

procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
begin
KeyPreview := True;
case Msg.message of
WM_KEYDOWN:
  if Msg.wParam = 27 then
  begin
    form1.Menu:=mainmenu1;
    fullscreen1.Checked:=false;
    form1.formstyle:=fsnormal;
    form1.BorderStyle:=bssizeable;
  end
  else
  if msg.wParam=VK_f5 then
  begin
    browser.Navigate(memo2.Text);
  end;
  end;
end;
end;
有帮助吗?

解决方案

There is name conflict with some TeeChart module, which is in "use" clause. You can write full-qualified identificator name to resolve this problem:

formstyle := Vcl.Forms.fsnormal;

P.S. Note that I deleted "form1." qualifier also. Normally it is not very useful in the form method body, and sometimes even harmful (imagine that you have multiple instances of TForm1)

其他提示

In addition to the answer of MBo, I think it is better to use:

Self.formstyle := Vcl.Forms.fsnormal;

When you have multiple instances of TForm1, this will always adjust the instance you are using at that moment.

Qualify the value with the particular enum type that it comes from:

Form1.FormStyle := TFormStyle.fsNormal;

Or even:

Form1.FormStyle := Vcl.Forms.TFormStyle.fsNormal;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top