zoukankan      html  css  js  c++  java
  • component to string 自定义窗体

    component to string

    string to component

    StringToComponent

    ComponentToString

    ObjectTextToBinary

    ObjectBinaryToText

    ReadComponent

    RegisterClass

    WriteComponentResFile

    ReadComponentResFile

    #include <memory>       //For STL auto_ptr class
     
    class MyScrollBar : public TScrollBar
    {
    __published:    // IDE-managed Components
    private:    // User declarations
    public:        // User declarations
        __fastcall MyScrollBar(TComponent* Owner);
    };
     
    __fastcall MyScrollBar::MyScrollBar(TComponent* Owner)
        : TScrollBar(Owner)
    {
    }
     
    void RegisterClassesWithStreamingSystem(void)
    {
      // Make sure that, as part of the startup
      // code, the streaming classes are registered
      // with the streaming system.
     
      #pragma startup RegisterClassesWithStreamingSystem
     
      Classes::RegisterClass(__classid(MyScrollBar));
    }
     
    MyScrollBar *ScrollBar1;
     
    String __fastcall ComponentToString(TComponent *c)
    {
      String as;
      std::auto_ptr<TMemoryStream> pms(new TMemoryStream);
      std::auto_ptr<TStringStream> pss(new TStringStream(as));
     
      try
      {
        pms->WriteComponent(c);
        pms->Seek(0, soFromBeginning);
        ObjectBinaryToText(pms.get(), pss.get());
        pss->Seek(0, soFromBeginning);
        as = pss->DataString;
      }
      catch(...)
      {
        ShowMessage("Streaming error.");
      }
     
      return as;
    }
     
    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
      Memo1->Text = ComponentToString(ScrollBar1);
    }
     
    TComponent *__fastcall StringToComponent(String as)
     
    {
      std::auto_ptr<TMemoryStream> pms(new TMemoryStream);
      std::auto_ptr<TStringStream> pss(new TStringStream(as));
      TComponent *pc;
     
      try
      {
        ObjectTextToBinary(pss.get(), pms.get());
        pms->Seek(0, soFromBeginning);
      }
      catch(...)
      {
        ShowMessage("Streaming error.");
      }
     
      pc = pms->ReadComponent(NULL);
      return pc;
    }
     
    void __fastcall TForm1::Button2Click(TObject *Sender)
    {
      TComponent *temp = StringToComponent(Memo1->Text);
      ScrollBar1->Free();
     
      ScrollBar1 = dynamic_cast<MyScrollBar *>(temp);
      ScrollBar1->Parent = Form1;
      ScrollBar1->Visible = TRUE;
    }
     
    __fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
    {
      ScrollBar1 = new MyScrollBar(Form1);  // Form1 will clean up the scroll bar.
      ScrollBar1->Parent = Form1;
      ScrollBar1->Visible = TRUE;
      ScrollBar1->Top = 48;
      ScrollBar1->Left = 250;
      ScrollBar1->Name = "Ricksbar";
    }
    View Code

     RegisterClass(TPersistentClass(aFrom.ClassType));

    UnRegisterClass(TPersistentClass(aFrom.ClassType));

     dwscript,paxcompiler 支持pas格式的语法

    RegisterComponentEditor

    http://blog.csdn.net/henreash/article/details/7371897

    属性编辑器

    http://www.rgzz.sdedu.net/ebook/hdbook/computer/bc/DELPHIzhuanti/rmjq/028.htm

  • 相关阅读:
    实用图片滑块,传送带,幻灯片效果【附源码】
    Canvas 示例:4种超炫的网站动画背景效果
    GOCR.js – 使用 JS 识别出图片中的文本
    Flexslider
    30款最好的 Bootstrap 3.0 免费主题和模板
    应用 CSS3 动画实现12种风格的通知提示
    Sequence.js 实现带有视差滚动特效的图片滑块
    使用QFuture类监控异步计算的结果
    Qt中的常用容器类(解释比较全面,有插图)
    QMetaEnum获取枚举元信息
  • 原文地址:https://www.cnblogs.com/cb168/p/4679004.html
Copyright © 2011-2022 走看看