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();
    }

    好不容易活着
  • 相关阅读:
    leetcode5 Longest Palindromic Substring
    leetcode17 Letter Combinations of a Phone Number
    leetcode13 Roman to Integer
    leetcode14 Longest Common Prefix
    leetcode20 Valid Parentheses
    leetcode392 Is Subsequence
    leetcode121 Best Time to Buy and Sell Stock
    leetcode198 House Robber
    leetcode746 Min Cost Climbing Stairs
    tomcat下使用druid配置jnid数据源
  • 原文地址:https://www.cnblogs.com/iwana/p/13606705.html
Copyright © 2011-2022 走看看