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

banana12345 2003-04-23 08:17:32
我 如何用 SetPropValue函数 为含有子项目(如 FONT,Constraints等)的属性赋值?多谢!!!希望大家健康,躲过“非典”劫难!
...全文
330 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
banana12345 2003-04-27
  • 打赏
  • 举报
回复
setPropValue(Label1.Font, 'color', clred)
banana12345 2003-04-26
  • 打赏
  • 举报
回复
继续UP
banana12345 2003-04-25
  • 打赏
  • 举报
回复
继续UP
banana12345 2003-04-24
  • 打赏
  • 举报
回复
继续UP
caishenye 2003-04-24
  • 打赏
  • 举报
回复
to ysai(淡出论坛)(同一个问题不说两次)
高...高...高...
banana12345 2003-04-24
  • 打赏
  • 举报
回复
继续UP
banana12345 2003-04-24
  • 打赏
  • 举报
回复
继续UP
banana12345 2003-04-24
  • 打赏
  • 举报
回复
继续UP
banana12345 2003-04-24
  • 打赏
  • 举报
回复
to u2m(UpToMe),不太懂
继续UP
u2m 2003-04-24
  • 打赏
  • 举报
回复
our callback function prototype}
function EnumWinPropsEx(hWnd: HWND; pString: PChar; Data: THandle;
dwData: DWORD): BOOL; stdcall;

var
Form1: TForm1;

implementation

{these steps will be executed for each property
entry in the window's property list}
function EnumWinPropsEx(hWnd: HWND; pString: PChar; Data: THandle;
dwData: DWORD): BOOL;
begin

{add the string and associated value to the list box}
Form1.ListBox1.Items.Add(Format('%s=%d, User Data: %d',
[pString,Data,dwData]));

{continue enumeration}
Result:=TRUE;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
{add a new property to the window's 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}
EnumPropsEx(Form1.Handle, @EnumWinPropsEx, 1);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
{clear the list box}
Form1.ListBox1.Items.Clear;

{list all of the properties associated with the window}

EnumPropsEx(Form1.Handle, @EnumWinPropsEx, 2);
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}

EnumPropsEx(Form1.Handle, @EnumWinPropsEx, 3);
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
u2m 2003-04-24
  • 打赏
  • 举报
回复
{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 window's 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 window's 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
banana12345 2003-04-24
  • 打赏
  • 举报
回复
up
wwnwnl 2003-04-24
  • 打赏
  • 举报
回复
广告时间.........................

------------------------------------------------------------------------------
2003年4月23日全国非典型肺炎疫情通报稿



卫生部新闻办公室今天下午通报了全国内地非典型肺炎疫情。

今天,全国各省、自治区、直辖市新报告非典型肺炎病例147例,治愈出院18例,死亡9例。其中广东报告14例,出院9例,死亡1例;北京报告105例,出院9例,死亡7例;山西报告16例;内蒙古报告3例;广西报告1例;天津报告2例;河北报告6例;宁夏死亡1例。

截至4月22日20时,全国共累计报告非典型肺炎病例2305例(医务人员517例),治愈出院1231例,死亡106例。其中,广东共累积报告病例1344例(医务人员337例),治愈出院1146例,死亡49例;北京693例(医务人员126例),治愈出院55例,死亡35例;山西157例(医务人员45例),治愈出院13例,死亡7例;内蒙古36例(医务人员5例),死亡6例;广西15例,治愈出院8例,死亡3例;四川8例,治愈出院3例,死亡2例;吉林7例(医务人员2例);河南6例;湖南6例,治愈出院5例,死亡1例;宁夏5例,死亡1例;天津7例,死亡2例;福建3例,治愈出院1例;浙江3例;上海2例;甘肃2例;陕西2例;辽宁1例;山东1例;湖北1例;河北6例。

今天,各地还报告疑似病例237例。截至4月22日20时,全国共累计报告疑似病例1093例。其中广东83例,北京782例,山西87例,内蒙古80例,广西2例,四川10例,吉林2例,河南1例,湖南2例,宁夏2例,天津5例,上海10例,甘肃2例,陕西7例,湖北7例,河北5例,新疆1例,重庆1例,江苏1例,贵州1例,江西1例,安徽1例。

--------------------------------------------------------------------------------


大家继续..............................

Lewolf 2003-04-24
  • 打赏
  • 举报
回复
直接赋值就就行了,好像联机帮助中说对于一个对象的属性也为另一个对象的时候,赋值操作和调用Assign方法是一样的。
banana12345 2003-04-24
  • 打赏
  • 举报
回复
继续UP
banana12345 2003-04-23
  • 打赏
  • 举报
回复
up
banana12345 2003-04-23
  • 打赏
  • 举报
回复
to ysai(淡出论坛)(同一个问题不说两次)
不行呀,编译不通过,[Error] Unit1.pas(20): Unsatisfied forward or external declaration: 'TForm1.GetObjectProperty',再指点一下,多谢?
FrameSniper 2003-04-23
  • 打赏
  • 举报
回复
呵呵,正在学这个,关注...
ysai 2003-04-23
  • 打赏
  • 举报
回复
//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

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧