System Error. Code: 1400.

thumb0422 2014-01-06 04:01:23
TcxPageControl创建多个TcxTabSheet,每个TcxTabSheet里嵌套一个FORM, 如果不触发FORM里任何事件,则能够正常的关闭SHEET(加载在其中的FORM也会关闭)以及重新创建相同的SHEET(重新创建FORM),但是如果触发了一个事件(即使是SHOWMESSAGE),关闭SHEET(加载在其中的FORM也会关闭)之后,再打开就会报错
Project HS.exe raised exception class EOSError with message 'System Error.  Code: 1400.
无效的窗口句柄。'.

SHEET关闭事件是TcxPageControl中的
MainPGCanCloseEx(Sender: TObject; ATabIndex: Integer;
var ACanClose: Boolean);

这是什么原因,以及如何解决?
...全文
475 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
sololie 2014-01-13
  • 打赏
  • 举报
回复
挽尊,撸过 不熟悉第三方组件
thumb0422 2014-01-13
  • 打赏
  • 举报
回复
thumb0422 2014-01-08
  • 打赏
  • 举报
回复
嵌套的FORM

type
  TbsTest1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

function ShowMDIForm(App: TApplication;AParentWindows:THandle): THandle; stdcall;
exports
    ShowMDIForm;

var
  bsTest1: TbsTest1;

implementation

{$R *.dfm}

function ShowMDIForm(App: TApplication;AParentWindows:THandle): THandle;
begin
  Application := App;
  with TbsTest1.Create(App) do
  try
    FormStyle:=fsNormal;
    ParentWindow:=AParentWindows;
    Align := alClient;
    BorderStyle := bsNone;
    BorderIcons := [];
    Show;
    result := Handle;
  except
    Result := 0;
  end;
end;

procedure TbsTest1.Button1Click(Sender: TObject);
begin
  ShowMessage('111212');
end;

procedure TbsTest1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action:=caFree;
end;
主界面

  TShowMDIForm = function(App : TApplication;AParentWindows:THandle):THandle; stdcall;

function TbsMainForm.LoadPackageB(tempBpl: string): Boolean;
var
  pProc : TShowMDIForm;
  tempSheet:TcxTabSheet;
begin
  Result:=True;
  bplH := LoadPackage(tempBpl);
  if IsWindow(bplFormH) then
  try
    ShowWindow(bplFormH, SW_SHOW);
    exit;
  except on E: Exception do
    raise Exception.Create(e.Message);
  end;
  if bplH = 0 then
    raise Exception.Create('无法获取待使用的包文件句柄!');
  pProc := getprocaddress(bplH, 'ShowMDIForm');
  ShowMessage('start');
  tempSheet:=GetTabSheet(tempBpl);
  if Assigned(pProc) then
  bplFormH := pProc(Application,tempSheet.Handle);
  ShowMessage('end');
end;

function TbsMainForm.GetTabSheet(tabName: string): TcxTabSheet;
var tempSheet:TcxTabSheet;
    tempName:string;
    tempDirName:string;
    i:Integer;
begin
  Result:=nil;
  if tabName='' then
  begin
    Exit;
  end;
  tempDirName:=ExtractFileDir(ParamStr(0));
  tempName:=StringReplace(tabName,tempDirName+'\','',[rfReplaceAll]);
  tempName:=Copy(tempName,1,pos('.',tempName)-1);
  if tabSheetList.IndexOf('cx'+tempName)<>-1 then
  begin
    //存在 则SHOW
    for i := 0 to MainPG.PageCount-1 do
    begin
      if MainPG.Pages[i].Name=('cx'+tempName) then
      begin
        MainPG.ActivePage:=MainPG.Pages[i];
        Result:=MainPG.Pages[i];
      end;
    end;
  end
  else
  begin
    //不存在
    try
      tempSheet:=TcxTabSheet.Create(MainPG);
      with tempSheet do
      begin
        AllowCloseButton:=True;
        Caption:=tempName;
        Enabled:=True;
        Name:='cx'+tempName;
        Visible:=True;
        Parent:=MainPG;
        PageControl:=MainPG;
        ParentWindow:=MainPG.Handle;
        TabVisible:=True;
      end;
      tabSheetList.Add(tempSheet.Name);
      Result:=tempSheet;
      MainPG.ActivePage:=tempSheet;
    except

    end;
  end;
end;
thumb0422 2014-01-07
  • 打赏
  • 举报
回复
引用 2 楼 a5312010 的回复:
用皮肤了吗?
没有噢。控件 就用了 DEV的。FORM里的触发事件就一个SHOWMESSAGE
a5312010 2014-01-07
  • 打赏
  • 举报
回复
用皮肤了吗?
thumb0422 2014-01-07
  • 打赏
  • 举报
回复
求教哦。 FORM的父窗体SHEET关闭了,FORM还需要写关闭事件么?

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧