Delphi - FMX表格BUG?

时间:2015-08-02 11:03:59

标签: delphi firemonkey delphi-xe8

我有通常的代码来显示模态形式。但有时会发生下图中捕获的奇怪错误。 (大约每10次尝试一次显示该表单)仅使用自定义FireMonkey样式“Diamond.style”。

enter image description here

我的设置样式的代码(在DPR文件中):

var
  lib: THandle;
  RS: TResourceStream;
begin
  Application.Initialize;
  lib := LoadLibrary('res.dll');
  RS := TResourceStream.Create(lib, 'DIAMOND', RT_RCDATA);
  try
    TStyleManager.SetStyle(TStyleManager.LoadFromStream(RS));
  finally
    RS.Free;
  end;
  ...

我显示表单的代码:

  formProjectName := TformProjectName.Create(Self);
  try
    formProjectName.ShowModal;
    ...
  finally
    formProjectName.Free;
  end;

1 个答案:

答案 0 :(得分:1)

我不确定这是否有用....但这是我在加载样式名称时使用的TComboBox的“OnChange”事件中的代码:

var
  resname :string;
  style:TFMXObject;

begin
  // set style to default...
  if TOSVersion.Platform = pfAndroid then
      resname := 'And';
  if TOSVersion.Platform = pfWindows then
      resname := 'Win';

  if cbStyles.ItemIndex > 0 then
  Begin
    //(Add prefix to style name from TComboBox)
    resname := resname + cbStyles.Selected.Text;
    Style := TStyleStreaming.LoadFromResource(HInstance,resname, RT_RCDATA) ;
    if style <> nil then
      TStyleManager.SetStyle(style);

  End;
   // The below line causes hangs in some future version (just guessing:-) ) -- XE8 was OK.
  //else TStyleManager.SetStyle(nil);

我像这样加载TComboBox STyles ......

 CBStyles.Items.Clear;

    CBStyles.Items.Add('Default');

    if TOSVersion.Platform = pfAndroid  then
    begin
       CBStyles.Items.Add('CoralCrystal');
       CBStyles.Items.Add('CoralDark');
       CBStyles.Items.Add('Diamond');
       CBStyles.Items.Add('EmeraldCrystal');

       CBStyles.Items.Add('EmeraldDark');
       CBStyles.Items.Add('Jet');
       CBStyles.Items.Add('Radiant');

       CBStyles.Items.Add('Sterling');
       CBStyles.Items.Add('Vapor');

    end;

也许这会有所帮助......