implementation
{$R *.dfm}
uses
  StdCtrls;procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  Btn : TButton;
begin
  Btn := TButton.Create(Self);     {<-- Self 在这段代表什么功能?}
  Btn.Parent := Self;            {<-- Parent 是什么东东和功能??}
  Btn.Left := X;
  Btn.Top := Y;
  Btn.Width := Btn.Width + 50;
  Btn.Caption := Format('Button at %d, %d', [X, Y]);  {<---- %d, %d 又是什么?? 可以给实例吗??}end;

解决方案 »

  1.   

    在本例中的self代表form1对象的指针,create(self)就是你可以不用自己free,在程序关闭的时候会被free,与之区别的还有create(application),create(nil),nil要自己释放。%d就是输入十进制的整数,具体看format的用法。另外代码好像少了Btn.Show;你这样会显示吗?
      

  2.   

    去搜搜 format的参数,就明白了
      

  3.   

    当然会了因为一个可视化的控件默认显示(visible)属性是 true
      

  4.   

    self就是对象自己
    Parent是控件指向父控件的指针
    %d是说在这个位置输出一个整数
      

  5.   

    1.在本例中的self代表form1对象的指针,create(self)就是你可以不用自己free,在程序关闭的时候会被free,与之区别的还有create(application),create(nil),nil要自己释放2.parent属性:指定控件的容器。
    Btn.Parent := Self;
    因为此处Self是指form1,那么这个btn按钮的容器是这个Form1。Btn将显示在Form1上面。
    假设,你在Form1上放一个panel1的话,
    那么Btn.Parent:=panel1;你会看到,Btn这个按钮将会显示在panel1这个控件上。3.%d
    双击 Btn.Caption := Format('Button at %d, %d', [X, Y]);中的Format,按F1.
    以下是说明和例子
    format函数说明:
    Returns a formatted string assembled from a format string and an array of arguments.UnitSysutilsCategorystring formatting routinesfunction Format(const Format: string; const Args: array of const): 
    string;DescriptionThis function formats the series of arguments in the open array Args. Formatting is controlled by the format string Format; the results are returned in the function result as a string. For information on the format strings, see Format Strings.format函数例子
    This example displays a message on the form's status bar indicating the table's record count after a record is deleted.
    procedure TForm1.Table1AfterDelete(DataSet: TDataSet);
    begin
      StatusBar1.SimpleText := Format('There are now %d records in the table', [DataSet.RecordCount]);
    end;
      

  6.   

    以下也红色处为d的解释。Decimal十进制。详细见F1Format specifiers have the following form:"%" [index ":"] ["-"] [width] ["." prec] typeA format specifier begins with a % character. After the % come the following, in this order:An optional argument index specifier, [index ":"]
    An optional left justification indicator, ["-"]
    An optional width specifier, [width]
    An optional precision specifier, ["." prec]
    The conversion type character, typeThe following table summarizes the possible values for type:d Decimal. The argument must be an integer value. The value is converted to a string of decimal digits. If the format string contains a precision specifier, it indicates that the resulting string must contain at least the specified number of digits; if the value has less digits, the resulting string is left-padded with zeros.
    u Unsigned decimal. Similar to 'd' but no sign is output.
    e Scientific. The argument must be a floating-point value. The value is converted to a string of the form "-d.ddd...E+ddd". The resulting string starts with a minus sign if the number is negative. One digit always precedes the decimal point.The total number of digits in the resulting string (including the one before the decimal point) is given by the precision specifier in the format stringղ default precision of 15 is assumed if no precision specifier is present. The "E" exponent character in the resulting string is always followed by a plus or minus sign and at least three digits.
    f Fixed. The argument must be a floating-point value. The value is converted to a string of the form "-ddd.ddd...". The resulting string starts with a minus sign if the number is negative.The number of digits after the decimal point is given by the precision specifier in the format stringղ default of 2 decimal digits is assumed if no precision specifier is present.
    g General. The argument must be a floating-point value. The value is converted to the shortest possible decimal string using fixed or scientific format. The number of significant digits in the resulting string is given by the precision specifier in the format stringղ default precision of 15 is assumed if no precision specifier is present.Trailing zeros are removed from the resulting string, and a decimal point appears only if necessary. The resulting string uses fixed point format if the number of digits to the left of the decimal point in the value is less than or equal to the specified precision, and if the value is greater than or equal to 0.00001. Otherwise the resulting string uses scientific format.
    n Number. The argument must be a floating-point value. The value is converted to a string of the form "-d,ddd,ddd.ddd...". The "n" format corresponds to the "f" format, except that the resulting string contains thousand separators.
    m Money. The argument must be a floating-point value. The value is converted to a string that represents a currency amount. The conversion is controlled by the CurrencyString, CurrencyFormat, NegCurrFormat, ThousandSeparator, DecimalSeparator, and CurrencyDecimals global variables, all of which are initialized from the Currency Format in the International section of the Windows Control Panel. If the format string contains a precision specifier, it overrides the value given by the CurrencyDecimals global variable.
    p Pointer. The argument must be a pointer value. The value is converted to an 8 character string that represents the pointers value in hexadecimal.
    s String. The argument must be a character, a string, or a PChar value. The string or character is inserted in place of the format specifier. The precision specifier, if present in the format string, specifies the maximum length of the resulting string. If the argument is a string that is longer than this maximum, the string is truncated.
    x Hexadecimal. The argument must be an integer value. The value is converted to a string of hexadecimal digits. If the format string contains a precision specifier, it indicates that the resulting string must contain at least the specified number of digits; if the value has fewer digits, the resulting string is left-padded with zeros.  
      

  7.   

    请问这段内容自那本书??
    怎么我找不到的 >.<ll 
    作者是 : Marco Cantù 吗??
      

  8.   

    双击 Btn.Caption := Format('Button at %d, %d', [X, Y]);中的Format,按F1.
    选Format function(Visual Component Library Reference)这一项
    显示出来后,最下面一行有绿色的Format String,点击它就出来了上面的帮助文字了。
      

  9.   

    哦... 扎到我了 >.<ll
    哈哈... 你用 Delphi 7 吗??
      

  10.   

    谢谢.. 因为只有 D7 的才是最清楚的...
    在 2010 易宝龙,很难找到 >.<ll
      

  11.   

    delphi7.0没有什么详细的书,不过我看到一些delphi5.0的电子书很详细