zoukankan      html  css  js  c++  java
  • 使用 IntraWeb (3)

    新建 StandAlone Application 工程后, 再通过 File > New > Other.. > IntraWeb > New Form 添加两个窗体.

    然后 TIWForm1 上放两个 TIWButton, 在 TIWForm2 和 TIWForm3 上各放一个 TIWButton. 测试代码用到三个窗体的 OnCreate 和每个按钮的 OnClick 事件.



    Unit1 中的代码:


    
     
    uses ServerController, Unit2, Unit3; procedure TIWForm1.IWAppFormCreate(Sender: TObject); begin   IWServerController.HistoryEnabled := True; //使浏览器后退、前进按钮有效   IWButton1.Caption := 'IWForm2';   IWButton2.Caption := 'IWForm3'; end; procedure TIWForm1.IWButton1Click(Sender: TObject); begin   TIWForm2.Create(WebApplication).Show; //建立并显示 TIWForm2; 执行后 WebApplication.ActiveForm 就从 TIWForm1 变为 TIWForm2 end; procedure TIWForm1.IWButton2Click(Sender: TObject); begin   TIWForm3.Create(WebApplication).Show; // end; initialization   TIWForm1.SetAsMainForm; //这是 TIWAppForm 的 Class 方法; 其作用是建立并设置当前窗口为主窗口(其实在 IW 中只有 ActiveForm, 无所谓 MainForm )                           //当然也同样设置其他窗体是首先被激活的窗体


    Unit2 中的代码:


    
     
    procedure TIWForm2.IWAppFormCreate(Sender: TObject); begin   IWButton1.Caption := Name; //只是用不同的标题区别一下 end; procedure TIWForm2.IWButton1Click(Sender: TObject); begin   Release; //释放后, TIWForm1 就出来了, 达到了返回的目的           //为什么 IW 提倡使用 Release 而不是通常的 Free 呢?           //我经过测试发现, Release 和 Free 是有区别的; 官方资料中介绍: IWApp;ication 内部还维护着一个 FReleasedForms 列表. end; 


    Unit3 中的代码:


    
     
    procedure TIWForm3.IWAppFormCreate(Sender: TObject); begin   IWButton1.Caption := Name; end; procedure TIWForm3.IWButton1Click(Sender: TObject); begin   Release; end; 


    还有一个问题, 在这里我们并没有引用 IWInit, 代码中的 WebApplication 是哪来的呢? 原来 TIWBaseForm(TIWAppForm < TIWForm < TIWBaseHTMLForm < TIWBaseForm)也提供了 WebApplication.
    经测试, 两个 WebApplication 都指向了同一个 TIWApplication 对象, 挺方便的.

    感觉 IW 比传统的 VCL 更巧妙些.

  • 相关阅读:
    iOS 根据生日计算生肖
    iOS 生日计算星座
    iOS App设置icon,启动图
    iOS UITextFiled基本解析
    自定义tabbaritem上的badeg
    iOS摄像头和相册-UIImagePickerController-浅析
    C++ 类型转换操作与操作符重载 operator type() 与 type operator()
    c++中的强制转换
    啊里巴巴上市--马云的励志话
    争--转任志强
  • 原文地址:https://www.cnblogs.com/martian6125/p/9630995.html
Copyright © 2011-2022 走看看