zoukankan      html  css  js  c++  java
  • C++ builder FMX 遍历窗口所有控件 并 动态消失

    原创  可转载  请注明 来处
    
     
    
    cpp:
    
    void TForm1::HideAllControl(bool vshow){
    if(! vshow){
    FOldPostion->Clear();
    for (int i = 0; i < ComponentCount - 1; i++) {
    TPropInfo *info;
    TPropInfo *infoVisiable;
    TObject* objTemp;
    objTemp = GetObjectProperty(Components[i], "Position");
    
    infoVisiable =    GetPropInfo(Components[i],"Visible");
    
    if ((objTemp) && (infoVisiable)) {
    info = GetPropInfo(objTemp,'Y');
    if (info) {
    float y = GetFloatProp(objTemp, 'Y');
    FOldPostion->Values[Components[i]->Name] = FloatToStr(y);
    int j = y;
    int x = 1;
    for (j; j < ClientHeight; j += x) {
    SetFloatProp(objTemp, info, j);
    Sleep(3);
    Application->ProcessMessages();
    Updated;
    x += 1;
    }
    
    if (infoVisiable) {
    SetVariantProp(Components[i], infoVisiable, 0);
    }
    
    }
    
    }
    
    }
    }
    else {
    for (int i = 0; i < ComponentCount - 1; i++) {
    TPropInfo *info;
    TPropInfo *infoVisiable;
    TObject* objTemp;
    objTemp = GetObjectProperty(Components[i], "Position");
    
    infoVisiable = GetPropInfo(Components[i], "Visible");
    
    if ((objTemp) && (infoVisiable)) {
    info = GetPropInfo(objTemp, 'Y');
    if (info) {
    float y = 0;
    int k = StrToInt(FOldPostion->Values[Components[i]->Name]);
    
    int j = y;
    int x = 1;
    for (j; j < k; j += x) {
    SetFloatProp(objTemp, info, j);
    Sleep(3);
    Application->ProcessMessages();
    Updated;
    x += 1;
    }
    
    if (infoVisiable) {
    SetVariantProp(Components[i], infoVisiable, 1);
    }
    
    }
    
    }
    
    }
    
    }
    }
    
     
    
    .h
    
    Public:
    
    void HideAllControl(bool vshow);
    
     
    
    匿名线程调用:
    
    //定义个  cpp 调用delphi  proc 的类 窗口继承 Form
    
    class TSleepFunc : public TCppInterfacedObject<TProc> {
    public:
    //这里建议用自己继承的TForm。由于后面所需參数要从Form获得
    TSleepFunc(TForm1* Form) : FForm(Form) {
    }
    
    virtual void __fastcall Invoke(void) {
    //这里处理你多线程代码
    //參数所有是 TForm3的变量,多线程中所需參数从TForm中声明
    FForm->HideAllControl(false);
    FForm->HideAllControl(true);
    //这里处理和TForm交互内容
    //    TThread::Synchronize(TThread::CurrentThread,UpdateCaption );
    }
    
    void __fastcall UpdateCaption(void) {
    FForm->Caption = "OK";
    }
    
    
    private:
    TForm1* FForm;
    };
    
     
    
    void __fastcall TForm1::btn14Click(TObject *Sender) {
    // std:: thread T1(HideAllControl,false);
    // T1.join() ;
    
    TThread::CreateAnonymousThread(new TSleepFunc(this))->Start();
    }

    好不容易活着
  • 相关阅读:
    PHP+MYSQL不错的环境架设软件
    ASV2011(Action Script Viewer)免费升级
    Win2003证书服务配置/客户端(服务端)证书申请/IIS站点SSL设置
    Entity FrameWork 4 PoCo使用
    使用Forms Authentication实现用户注册、登录
    验证数字的正则表达式集
    web.config/app.config敏感数据加/解密的二种方法
    如何创建一个标准的Windows服务
    抛弃WebService 在.NET4中用jQuery调用WCF
    EF 中调用带输出参数的存储过程
  • 原文地址:https://www.cnblogs.com/iwana/p/13606705.html
Copyright © 2011-2022 走看看