当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

    摘要: 我的2924里几个端口连到其它楼. 有些楼我想绑定ip到mac,而有些我不想绑定,应如何做? ......
    摘要: hfile是createfile()函数产生的文件句柄, 通过hfile怎样问cfile类的函数? ......


如何用 SetPropValue函数 为含有子项目(如 FONT,Constraints等)的属性赋值

我   如何用   SetPropValue函数   为含有子项目的属性赋值?多谢!!!希望大家健康,躲过“非典”劫难!

NO.1   作者: ysai

//uses   typinfo  
   
  function   GetObjectProperty(  
          const   AObject       :   TObject;  
          const   APropName   :   string  
          ):TObject;  
  var  
      PropInfo:PPropInfo;  
  begin  
      Result     :=     nil;  
      PropInfo:=GetPropInfo(AObject.ClassInfo,APropName);  
      if   Assigned(PropInfo)   and  
              (PropInfo^.PropType^.Kind   =   tkClass)   then  
          Result     :=     GetObjectProp(AObject,PropInfo);  
  end;  
   
  function   SetIntegerPropertyIfExists(  
          const   AObject       :   TObject;  
          const   APropName   :   string;  
          const   AValue         :   integer  
          ):Boolean;  
  var  
      PropInfo:PPropInfo;  
  begin  
      PropInfo:=GetPropInfo(AObject.ClassInfo,APropName);  
      if   Assigned(PropInfo)   and  
              (PropInfo^.PropType^.Kind   =   tkInteger)   then  
      begin  
          SetOrdProp(AObject,PropInfo,AValue);  
          Result:=True;  
      end   else  
          Result:=False;  
  end;  
   
  //调用  
  procedure   TFrmTest.FormCreate(Sender:   TObject);  
  var  
      objTemp   :   TObject;  
  begin  
      objTemp   :=     GetObjectProperty(Self,Font);  
      if   Assigned(objTemp)   then  
          SetIntegerPropertyIfExists(objTemp,Size,9);  
  end;  
   
  //属性不能是集合,如TDBGrid.Columns

NO.2   作者: u2m

{our   callback   function   prototype}  
  function   EnumWinProps(hWnd:   HWND;   pString:   PChar;   Data:   THandle):   BOOL;   stdcall;  
   
  var  
      Form1:   TForm1;  
   
  implementation  
   
  {these   steps   will   be   executed   for   each   property  
    entry   in   the   windows   property   list}  
  function   EnumWinProps(hWnd:   HWND;   pString:   PChar;   Data:   THandle):   BOOL;  
  begin  
        {add   the   string   and   associated   value   to   the   list   box}  
        Form1.ListBox1.Items.Add(Format(%s=%d,[pString,Data]));  
   
        {continue   enumeration}  
        Result:=TRUE;  
  end;  
   
  procedure   TForm1.Button1Click(Sender:   TObject);  
  begin  
        {add   a   new   property   to   the   windows   property   list}  
        SetProp(Form1.Handle,PChar(Edit1.Text),StrToInt(Edit2.Text));  
   
        {clear   the   edit   boxes}  
        Edit1.Text:=;  
        Edit2.Text:=;  
   
        {clear   the   list   box}  
        Form1.ListBox1.Items.Clear;  
   
        {list   all   of   the   properties   associated   with   the   window}  
   
        EnumProps(Form1.Handle,   @EnumWinProps);  
  end;  
   
  procedure   TForm1.Button2Click(Sender:   TObject);  
  begin  
        {clear   the   list   box}  
        Form1.ListBox1.Items.Clear;  
   
        {list   all   of   the   properties   associated   with   the   window}  
        EnumProps(Form1.Handle,   @EnumWinProps);  
  end;  
   
  procedure   TForm1.Button3Click(Sender:   TObject);  
  begin  
        {remove   the   selected   property   from   the   property   list}  
   
        RemoveProp(Form1.Handle,PChar(Copy(ListBox1.Items[ListBox1.ItemIndex],    
                              0,Pos(=,ListBox1.Items[ListBox1.ItemIndex])-1)));  
   
        {clear   the   list   box}  
        Form1.ListBox1.Items.Clear;  
   
        {list   all   of   the   properties   associated   with   the   window}  
        EnumProps(Form1.Handle,   @EnumWinProps);  
  end;  
   
  procedure   TForm1.Button4Click(Sender:   TObject);  
  var  
        Data:   THandle;     //   this   stores   the   property   entry   data  
   
  begin  
        {get   property   entry   data   associated   with   the   given   string}  
        Data:=GetProp(Form1.Handle,PChar(Edit1.Text));  
   
        {if   there   was   a   property   value   returned...}  
        if   (Data<>0)   then  
              {...display   it...}  
              Edit2.Text:=IntToStr(Data)  
        else  
              {...otherwise   display   an   error   message}  
              Edit2.Text:=No   property   found.;  
  end;  
   
  The   Tomes   of   Delphi   3:   Win32   Core   API   Help   File   by   Larry   Diehl


    摘要: void __fastcall tplayer::formcreate(tobject *sender) { mediaplayer1->filename=""; trackbar1->enabled=false; initshow(); } void tplayer::initshow() { if (mediaplayer1->filena......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE