两个基本概念的问题

icystone 2003-10-09 04:32:15
1。如何实现静态方法,即不用生成类的实例而调用类的方法。
2。如何改变ProgressBar中进度条的颜色。
...全文
43 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
FrameSniper 2003-10-12
  • 打赏
  • 举报
回复
问题一只可以使用类方法
icystone 2003-10-12
  • 打赏
  • 举报
回复
WinXP风格进度条,好像没有什么效果???
关于静态方法,我只是想探讨一下,怎样实现我知道,只是觉得既然支持oop那么就应该有静态方法。
天外流星的话我不动,既然是静态的为什么不可以不需要生成实例就直接调用???
dickeybird888 2003-10-09
  • 打赏
  • 举报
回复
哈哈!
sundayzhao 2003-10-09
  • 打赏
  • 举报
回复
我知道C++可以声明静态方法,不需要生成实例就可以直接调用。Delphi我不是很清楚。
如果一定需要,可以声明全局函数啊。
outer2000 2003-10-09
  • 打赏
  • 举报
回复
你声明一个类方法的时候,默认都是STATIC的;
Methods are by default static. When a static method is called, the declared (compile-time) type of the class or object variable used in the method call determines which implementation to activate. In the following example, the Draw methods are static.

type
TFigure = class
procedure Draw;
end;
TRectangle = class(TFigure)
procedure Draw;
end;
hiflower 2003-10-09
  • 打赏
  • 举报
回复
不生成实例不行吧,只能调用一些不用到类数据成员的方法
TonyWzz 2003-10-09
  • 打赏
  • 举报
回复
class function fname(params)
IORILI 2003-10-09
  • 打赏
  • 举报
回复
uses

CommCtrl;

procedure TForm1.Button1Click(Sender: TObject);

begin

// Set the Background color to teal

Progressbar1.Brush.Color := clTeal;

// Set bar color to yellow

SendMessage(ProgressBar1.Handle, PBM_SETBARCOLOR, 0, clYellow);

end;

WinXP风格进度条

const

{$EXTERNALSYM PBS_MARQUEE}

PBS_MARQUEE = 08;

 

procedure TForm1.FormCreate(Sender: TObject);

begin

SetWindowLong(ProgressBar1.Handle, GWL_STYLE,

GetWindowLong(ProgressBar1.Handle, GWL_STYLE) or PBS_MARQUEE);

end;

//------------------------------------------------------------------------------

procedure TForm1.Button1Click(Sender: TObject);

var

i: Integer;

begin

for i := 0 to 30 do

begin

Sleep(100);

ProgressBar1.StepIt;

Application.ProcessMessages;

end;

end;

5,379

社区成员

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

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