我在panel上放了一个checkbox和 button1,现在我如何通过点击‘保存’(button2)来保存checkbox.left,checkbox.top,和button1.left,button1.top
请各位老大指点啊
在此先谢过了~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~解决者绝对给分~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

解决方案 »

  1.   

    up
    可以存入ini文件中或注册表中!
      

  2.   

    是可以存入,但是我现在不能通过遍历整个FORM而得到panel上的checkbox的属性,如TOP,LEFT等
      

  3.   

    i,t:integer;  
      for i:=0 to ComponentCount-1 do
         begin
           if Components[i].ClassType=TCheckBox then
             t:=TCheckBox(Components[i]).top;
         end;
      

  4.   

    TO:zjybestzjybest(zjybestzjybest)
    如果你回答对了,可以再加。我的问题是:
    我想遍历整个FORM上的所有控件,包括容器内的控件(如FROM上的panel上的listbox,checkbox,label等),得到所有控件的基本设置属性(包括LEFT,TOP等),然后把这些属性加密后写入到一个INI文件中;
    还有就是对FORM上的图片文件进行‘更换保存’操作,同时要把新的图片保存到一个位置,在INI文件中记录新图片的路径和名字。大家知道帮帮忙吧
    谢了啊
      

  5.   

    typinfo //在USES里面加上单元//FORM1上面的所有对象的LEFT和TOP。当然对象要有这几个属性才行
    procedure TForm1.Button1Click(Sender: TObject);
    var
      PropList: PPropList;
      PropCount: Integer;
      I,j: Integer;
      kk,tt:tcomponent;
      begin
       for j:=0 to form1.ControlCount -1 do
        begin
        tt:= FORM1.Controls[j] ;
        PropCount := GetTypeData(tt.ClassInfo)^.PropCount;
        GetMem(PropList, PropCount * SizeOf(Pointer));
        try
          GetPropInfos(tt.ClassInfo, PropList);
          memo1.Lines.Add('****************');
          memo1.Lines.Add('控件名字:'+tt.Name );
          for I := 0 to PropCount - 1 do
            begin
            if ('Top'=  PropList[I].Name) or ('Left'=PropList[I].Name) then
             begin
              Memo1.Lines.Add(PropList[I].Name + '=' +
              inttostr(getpropvalue(tt, PropList[I].Name)));
             end;
            end;
        finally
          FreeMem(PropList);
        end;
       end;
     memo1.Lines.SaveToFile('c:\test.txt');
    end;
      

  6.   

    // typinfo 在USES里面加上这个单元,
    //程序需要一个MEMO1 一个BUTTON1procedure TForm1.Button1Click(Sender: TObject);
    var
      PropList: PPropList;
      PropCount: Integer;
      I,j: Integer;
      kk,tt:tcomponent;
      begin
      for j:=0 to form1.ComponentCount-1 do // 改一下写错了
      //for j:=0 to form1.ControlCount -1 do
        begin
        tt:= FORM1.Controls[j] ;
        PropCount := GetTypeData(tt.ClassInfo)^.PropCount;
        GetMem(PropList, PropCount * SizeOf(Pointer));
        try
          GetPropInfos(tt.ClassInfo, PropList);
          memo1.Lines.Add('****************');
          memo1.Lines.Add('控件名字:'+tt.Name );
          for I := 0 to PropCount - 1 do
            begin
            if ('Top'=  PropList[I].Name) or ('Left'=PropList[I].Name) then
             begin
              Memo1.Lines.Add(PropList[I].Name + '=' +
              inttostr(getpropvalue(tt, PropList[I].Name)));
             end;
            end;
        finally
          FreeMem(PropList);
        end;
       end;
     memo1.Lines.SaveToFile('c:\test.txt');
    end;
      

  7.   

    // typinfo 在USES里面加上这个单元,
    //程序需要一个MEMO1 一个BUTTON1procedure TForm1.Button1Click(Sender: TObject);
    var
      PropList: PPropList;
      PropCount: Integer;
      I,j: Integer;
      kk,tt:tcomponent;
      begin
      for j:=0 to form1.ComponentCount-1 do // 改一下写错了
      //for j:=0 to form1.ControlCount -1 do
        begin
        tt:= FORM1.Components[j];//这个地方也写错了,黑肚子饿了
        PropCount := GetTypeData(tt.ClassInfo)^.PropCount;
        GetMem(PropList, PropCount * SizeOf(Pointer));
        try
          GetPropInfos(tt.ClassInfo, PropList);
          memo1.Lines.Add('****************');
          memo1.Lines.Add('控件名字:'+tt.Name );
          for I := 0 to PropCount - 1 do
            begin
            if ('Top'=  PropList[I].Name) or ('Left'=PropList[I].Name) then
             begin
              Memo1.Lines.Add(PropList[I].Name + '=' +
              inttostr(getpropvalue(tt, PropList[I].Name)));
             end;
            end;
        finally
          FreeMem(PropList);
        end;
       end;
     memo1.Lines.SaveToFile('c:\test.txt');
    end;
      

  8.   

    panel上的控件通过这个可以遍历得到吗?
      

  9.   

    可以的,因为他是在FORM1.COMPONENTS数组里面
      

  10.   

    楼上的,可以解释一下如下代码吗?
    var PropList: PPropList;PropCount := GetTypeData(tt.ClassInfo)^.PropCount;    GetMem(PropList, PropCount * SizeOf(Pointer));      GetPropInfos(tt.ClassInfo, PropList);
    非常感谢
      

  11.   

    PropCount := GetTypeData(tt.ClassInfo)^.PropCount;//取得属性的项数GetMem(PropList, PropCount * SizeOf(Pointer));//分配PROPLIST连续分配指向各个属性的指针的空间,当然里面现在都是NILGetPropInfos(tt.ClassInfo, PropList);//读取每一个属性的运行信息的指针到PropList的每一项中
      

  12.   

    pproplist 是什么类型,怎么在DELPHI 帮助内找不到?
    还有这几个函数过程:gettypedata(),getpropinfos 怎么都找不到帮助啊?
    在哪里可以找到
      

  13.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    cleardata(panel1);
    end;procedure TForm1.cleardata(Sender: TObject);
    var  i : Integer;
    begin
      if Sender is TPanel then
      begin
        for i:=0 to TPanel(Sender).ControlCount-1 do
         Cleardata(TPanel(Sender).Controls[i]);
      end;
      showmessage(inttostr(TEdit(Sender).Left));
    end;
      

  14.   

    form(form)
     你的代码有问题万一PANEL上面放一个TBUTTON了或者其他什么控件就不行了哟哈哈!
      

  15.   

    to:zjybestzjybest(zjybestzjybest) 
    现在能存到INI文件中了,但还要从INI文件中读出来。在FORM创建时,动态生成INI中的组件,INI文件中存在组件的信息。
    即把原来界面上的组件的位置大小信息从INI文件读出来,动态创建一遍再。
    要求如PANEL上有CHECKBOX,在动态生成后还原到PANEL上。
    还有如果有IMAGE文件,INI中还有IMAGE的存放路径,要求把原图象调出来显示在FORM上。如果解决了,再有50相送。INI文件形式如下:
    [button]
    left=10
    top=20
    height=30
    width=50
    [panel]
    left=10
    top=20
    height=30
    width=50
    [checkbox]
    left=10
    top=20
    height=30
    width=50