第1个回答 2007-04-11
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
Temp: TButton;
begin
Temp := TButton.Create(Form1);
Temp.Parent := Form1; // 问题A
Temp.Top := Y;
Temp.Left := X;
Temp.Width := Temp.Width + 100;
end;
这段代码如果缺了问题所在的那一段,那么按钮就不会出现,原因是什么呢?我才学OOP,您们如何理解这个Parent 呢?是不是说如果没有 Parent 那么Button 就没有生根的地方?
却是如此,我试了一下,如果Parent 写成 另外的一个很大的按钮(半个窗体大小的)或者组件,那么按钮就会在所定义的那个组件上面出现,不过这个问题 已经写了,还是问吧,老虾可不可以讲讲原理呢?
我是从Turbo Basic 转行到 Delphi, 现在全力学习 OOP 思想,请多关照!
Parent为包含该控件的父控件,这不是OOP的思想,是‘MS的MDI思想’
父组件,容器
unit Unit10;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Panel1: TPanel;
Panel2: TPanel;
procedure Button1Click(Sender: TObject);
procedure Panel1Click(Sender: TObject);
procedure Panel2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Button1.Parent := Panel1;
Button1.SetBounds(0, 0, Button1.Width, Button1.Height);
end;
procedure TForm1.Panel1Click(Sender: TObject);
begin
Button1.Parent := Panel1;
Button1.SetBounds(0, 0, Button1.Width, Button1.Height);
end;
procedure TForm1.Panel2Click(Sender: TObject);
begin
Button1.Parent := Panel2;
Button1.SetBounds(0, 0, Button1.Width, Button1.Height);
end;
end.
这个不是OOP的东西,windows的东西
当设置Parent时,会导致delphi调用DestroyHandle,
接着调用CreateHandle,
重建Button, 在CreateParams时,
if Parent <> nil then
WndParent := Parent.GetHandle
取相应的Parent的Handle,
然后CreateWindowEx,
恐怕不能放到一个很大的按钮上,因为Parent必须是个容器,象:form,panel,groupbox……
>恐怕不能放到一个很大的按钮上,因为Parent必须是个容器,象:form,panel,groupbox
The fact is I put the buttons on a very large button!!!!
第2个回答 2007-04-13
Oop basic thought
Many originality of the OOP thought all come it is at the Simula language, and at Smalltalk language of perfect get to morely expand with standardize in the process with to before of thought of afresh comment.Can say that OO thought and OOPL are an almost synchronous development to promote mutually.And what the function type program design(logic-programming) of program design(functional-programming) and logic type represent close at the machine of actual calculation model different BE, the OOP almost led into precision of mathematics copy Xu, but a trait of builds up an object model, it can look like of reflect the relation of of apply entity in the realm, its essence is more close cognize at a kind of mankind thing adopt of the calculation model of philosophy view.Caused from here a topic of nature, what be that be the OOP exactly is?[D&T 1988][B.S 1991] ..In the OOP, the object is to compute corpus, own an own name, appearance and accept connect of outside news.Produce new object in the object model, the old object destroy, send out news and respond to news to constitute an OOP calculation the root of the model.
The creation of object contains two kinds of basic ways.1 kind takes prototype(prototype) object as foundation to produce new object.1 kind takes type(class) as the foundation creation new object.The concept of prototype has already been used to hermeneutic concept to study in the cognition the psychology of pass and increase characteristic, the prototype is to attempt to pass to provide an object which has a representative as foundation to produce various new object, and continue to produce to match actual and applied object more from here.And prototype-entrust is also that the object in the OOP is abstract, the code shares a kind within mechanism.A the in general use which provided a perhaps several objects copies Xu.See from the formal standpoint, the type relates to type, so an equal hence from that type ofly gather of output solid example.And so of the standpoint will also bring some antinomies, more typical be while inherit the system, the son gather(son) the behavior of that object and father gather(father) object to mutually melt sex and may can hardly attain, this is also in the OOP to be often quote from of-the sub- type(subtype) be unequal to son(subclass)[the Budd be 2002].But under the global view background that a kind of all all object, at type's model foundation last still is born 1 kind own the new object model of dollar(metaclass).Then the type is also a kind of other object.Three kinds of above standpoints with different root respectively defined 3 kinds according to the type(class-based), according to the object model of the prototype(prototype-based) and dollar(metaclass-based).And these three kinds of object models also caused many different program design languages.(if we temporarily put the difference of the static state and the dynamic state in the part)Yes, we usually contiguous C++, the Javas all use according to the object model of type, but in addition still had a lot of contiguous OOPLs that we have no to adopt completely different object model and they are use the content of moreover a kind of standpoint annotation OOP.
第3个回答 2007-04-14
Oop basic thought
OOP many originalities the thoughts are all come it in language of Simula, and at Smalltalk language of perfect get to expand morely with standardize in the process and to past of thought afresh comment.Can say the OO the thought and OOPL is almost a synchronous development to promote mutually.With the function type program design( functional- programming) different from the logic type program design( logic- programming) representative of near to in the actual calculation model of the machine is, the OOP almost did not lead into mathematics of the precision to copy the 叙 , but incline toward to build up an object model, the relation between entity in the reflection application realm that it can look like, its essence even is near to in a kind of mankind the calculation model of the philosophy view that the cognition thing adopt.From here, cause a topic of nature, is that what is the OOP exactly?[D&T 1988][B.S 1991] ..In the OOP, the object conduct and actions calculation corpus, own own name, appearance and accept the outside news to connect.In the object model, new object of creation, the old object destroy by burning, sending out the news, responding to the news and then constitute the OOP to compute the root of the model.
The creation of the object contain two kinds of basic ways.A kind of take the prototype( prototype) object as the foundation to produce the new object.A kind of is to take type( class) as the foundation to produce the new object.The concept of the prototype hases already been use in cognize psychology to come to explain the concept to study of pass and increase characteristic, the prototype is to attempt to pass to provide an object that has the representative as foundation to produce various new object, and continue to produce to even match the actual and applied object from here.And prototype- entrust is also an object in the OOP abstract, the code share a kind within mechanism.A provided an or several object of in general use copy the 叙 .See from the formal standpoint, the type has something to do with type, so an equal hence from that type of in the output solid example gather.And such standpoint also will bring some antinomies, comparing the typical model is while inherit the system, the son gather( son) the behavior that the object and fathers gather( father) the of object and melt sex and may can hardly attain mutually, this also is in the OOP to was often quote from of- the sub- type( subtype) is unequal to son( subclass)[2002] of Budd.But under a kind ofly the havings all the global view background of the object, still bore on a model foundation a kind of new object model that owns dollar( metaclass).Then the type is also a kind of other object.Above each of three kinds of basically different standpointseses defined three kinds of according to type( class- based), according to the object model of the prototype( prototype- based) and dollar( metaclass- based).And these three kinds of object models also caused many different program design languages.( if we temporarily put the aside to the difference of the static state and dynamic state)Yes, the C that we usually get in touch with++, the Javas all use according to the object model of the type, but in addition plenty more contiguous OOPL that we have no adopted the complete different object model, they is to use the content that another kind of standpoint explains the OOP.
第4个回答 2007-04-22
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
Temp: TButton;
begin
Temp.Parent := Form1; // 问题A
Temp.Top := Y;
Temp.Left := X;
Temp.Width := Temp.Width + 100;
end;
这段代码如果缺了问题所在的那一段,那么按钮就不会出现,原因是什么呢?我才学OOP,您们如何理解这个Parent 呢?是不是说如果没有 Parent 那么Button 就没有生根的地方?
却是如此,我试了一下,如果Parent 写成 另外的一个很大的按钮(半个窗体大小的)或者组件,那么按钮就会在所定义的那个组件上面出现,不过这个问题 已经写了,还是问吧,老虾可不可以讲讲原理呢?
我是从Turbo Basic 转行到 Delphi, 现在全力学习 OOP 思想,请多关照!
Parent为包含该控件的父控件,这不是OOP的思想,是‘MS的MDI思想’
父组件,容器
unit Unit10;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Panel1: TPanel;
Panel2: TPanel;
procedure Button1Click(Sender: TObject);
procedure Panel1Click(Sender: TObject);
procedure Panel2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Button1.Parent := Panel1;
Button1.SetBounds(0, 0, Button1.Width, Button1.Height);
end;
procedure TForm1.Panel1Click(Sender: TObject);
begin
Button1.Parent := Panel1;
Button1.SetBounds(0, 0, Button1.Width, Button1.Height);
end;
procedure TForm1.Panel2Click(Sender: TObject);
begin
Button1.Parent := Panel2;
Button1.SetBounds(0, 0, Button1.Width, Button1.Height);
end;
end.
这个不是OOP的东西,windows的东西
当设置Parent时,会导致delphi调用DestroyHandle,
接着调用CreateHandle,
重建Button, 在CreateParams时,
if Parent <> nil then
WndParent := Parent.GetHandle
取相应的Parent的Handle,
然后CreateWindowEx,
恐怕不能放到一个很大的按钮上,因为Parent必须是个容器,象:form,panel,groupbox……
>恐怕不能放到一个很大的按钮上,因为Parent必须是个容器,象:form,panel,groupbox
The fact is I put the buttons on a very large button!!!!