Delphi7中一个有趣的现象,不知道其他版本又没有这个现象 ( 积分: 300 )

  • 主题发起人 主题发起人 tseug
  • 开始时间 开始时间
看看Delphi语法,这个是他联机帮助带的,
FunctionHeading -> FUNCTION Ident [FormalParameters] ':' (SimpleType | STRING)
这里面能看出来这种语法么?[8D]


Goal -> (Program | Package | Library | Unit)
Program -> [PROGRAM Ident ['(' IdentList ')'] ';']
ProgramBlock '.'
Unit -> UNIT Ident [PortabilityDirective] ';'
InterfaceSection
ImplementationSection
InitSection '.'
Package -> PACKAGE Ident ';'
[RequiresClause]
[ContainsClause]
END '.'
Library -> LIBRARY Ident ';'
ProgramBlock '.'
ProgramBlock -> [UsesClause]
Block
UsesClause -> USES IdentList ';'
PortabilityDirective -> platform
-> deprecated
-> library
InterfaceSection -> INTERFACE
[UsesClause]
[InterfaceDecl]...
InterfaceDecl -> ConstSection
-> TypeSection
-> VarSection
-> ExportedHeading
ExportedHeading -> ProcedureHeading ';' [Directive]
-> FunctionHeading ';' [Directive]
ImplementationSection -> IMPLEMENTATION
[UsesClause]
[DeclSection]...
[ExportsStmt]...
Block -> [DeclSection]
[ExportsStmt]...
CompoundStmt
[ExportsStmt]...
ExportsStmt -> EXPORTS ExportsItem [, ExportsItem]...
ExportsItem -> Ident [NAME|INDEX "'&quot
ConstExpr "'"]
[INDEX|NAME "'&quot
ConstExpr "'"]

DeclSection -> LabelDeclSection
-> ConstSection
-> TypeSection
-> VarSection
-> ProcedureDeclSection
LabelDeclSection -> LABEL LabelId
ConstSection -> CONST (ConstantDecl ';')...
ConstantDecl -> Ident '=' ConstExpr [PortabilityDirective]
-> Ident ':' TypeId '=' TypedConstant [PortabilityDirective]
TypeSection -> TYPE (TypeDecl ';')
TypeDecl -> Ident '=' [TYPE] Type [PortabilityDirective]
-> Ident '=' [TYPE] RestrictedType [PortabilityDirective]
TypedConstant -> (ConstExpr | ArrayConstant | RecordConstant)
ArrayConstant -> '(' TypedConstant ',' ')'
RecordConstant -> '(' RecordFieldConstant ';'... ')'
RecordFieldConstant -> Ident ':' TypedConstant
Type -> TypeId
-> SimpleType
-> StrucType
-> PointerType
-> StringType
-> ProcedureType
-> VariantType
-> ClassRefType

RestrictedType -> ObjectType
-> ClassType
-> InterfaceType
ClassRefType -> CLASS OF TypeId
SimpleType -> (OrdinalType | RealType)
RealType -> REAL48
-> REAL
-> SINGLE
-> DOUBLE
-> EXTENDED
-> CURRENCY
-> COMP
OrdinalType -> (SubrangeType | EnumeratedType | OrdIdent)
OrdIdent -> SHORTINT
-> SMALLINT
-> INTEGER
-> BYTE
-> LONGINT
-> INT64
-> WORD
-> BOOLEAN
-> CHAR
-> WIDECHAR
-> LONGWORD
-> PCHAR
VariantType -> VARIANT
-> OLEVARIANT
SubrangeType -> ConstExpr '..' ConstExpr
EnumeratedType -> '(' EnumeratedTypeElement ','... ')'
EnumeratedTypeElement -> Ident [ '=' ConstExpr ]
StringType -> STRING
-> ANSISTRING
-> WIDESTRING
-> STRING '[' ConstExpr ']'

StrucType -> [PACKED] (ArrayType | SetType | FileType | RecType [PACKED])
ArrayType -> ARRAY ['[' OrdinalType ','... ']'] OF Type [PortabilityDirective]
RecType -> RECORD [FieldList] END [PortabilityDirective]
FieldList -> FieldDecl ';'... [VariantSection] [';']
FieldDecl -> IdentList ':' Type [PortabilityDirective]
VariantSection -> CASE [Ident ':'] TypeId OF RecVariant ';'...
RecVariant -> ConstExpr ','... ':' '(' [FieldList] ')'
SetType -> SET OF OrdinalType [PortabilityDirective]
FileType -> FILE OF TypeId [PortabilityDirective]
PointerType -> '^' TypeId [PortabilityDirective]
ProcedureType -> (ProcedureHeading | FunctionHeading) [OF OBJECT]
VarSection -> VAR (VarDecl ';')...
VarDecl On Windows -> IdentList ':' Type [(ABSOLUTE (Ident | ConstExpr)) | '=' ConstExpr] [PortabilityDirective] On Linux -> IdentList ':' Type [ABSOLUTE (Ident) | '=' ConstExpr] [PortabilityDirective]

Expression -> SimpleExpression [RelOp SimpleExpression]...
SimpleExpression -> ['+' | '-'] Term [AddOp Term]...
Term -> Factor [MulOp Factor]...
Factor -> Designator ['(' ExprList ')']
-> '@' Designator
-> Number
-> String
-> NIL
-> '(' Expression ')'
-> NOT Factor
-> SetConstructor
-> TypeId '(' Expression ')'
RelOp -> '>'
-> '<'
-> '<='
-> '>='
-> '<>'

-> IN
-> IS
-> AS
AddOp -> '+'
-> '-'
-> OR
-> XOR
MulOp -> '*'
-> '/'
-> DIV
-> MOD
-> AND
-> SHL
-> SHR
Designator -> QualId ['.' Ident | '[' ExprList ']' | '^']...
SetConstructor -> '[' [SetElement ','...] ']'
SetElement -> Expression ['..' Expression]
ExprList -> Expression ','...
Statement -> [LabelId ':'] [SimpleStatement | StructStmt]

StmtList -> Statement ';'
SimpleStatement -> Designator ['(' [ExprList] ')']
-> Designator ':=' Expression
-> INHERITED
-> GOTO LabelId
StructStmt -> CompoundStmt
-> ConditionalStmt
-> LoopStmt
-> WithStmt
-> TryExceptStmt
-> TryFinallyStmt
-> RaiseStmt
-> AssemblerStmt
CompoundStmt -> BEGIN StmtList END
ConditionalStmt -> IfStmt
-> CaseStmt
IfStmt -> IF Expression THEN Statement [ELSE Statement]
CaseStmt -> CASE Expression OF CaseSelector ';'... [ELSE StmtList] [';'] END
CaseSelector -> CaseLabel ','... ':' Statement
CaseLabel -> ConstExpr ['..' ConstExpr]
LoopStmt -> RepeatStmt
-> WhileStmt
-> ForStmt
RepeatStmt -> REPEAT Statement UNTIL Expression
WhileStmt -> WHILE Expression DO Statement
ForStmt -> FOR QualId ':=' Expression (TO | DOWNTO) Expression DO Statement
WithStmt -> WITH IdentList DO Statement
TryExceptStmt -> TRY
Statement...
EXCEPT
ExceptionBlock
END
ExceptionBlock -> [ON [Ident ':'] TypeID DO Statement]...
[ELSE Statement...]
TryFinallyStmt -> TRY
Statement
FINALLY
Statement
END
RaiseStmt -> RAISE [object] [AT address]

AssemblerStatement -> ASM
-> <assemblylanguage>
-> END
ProcedureDeclSection -> ProcedureDecl
-> FunctionDecl
ProcedureDecl -> ProcedureHeading ';' [Directive] [PortabilityDirective]
Block ';'
FunctionDecl -> FunctionHeading ';' [Directive] [PortabilityDirective]
Block ';'
FunctionHeading -> FUNCTION Ident [FormalParameters] ':' (SimpleType | STRING)

ProcedureHeading -> PROCEDURE Ident [FormalParameters]
FormalParameters -> '(' [FormalParm ';'...] ')'
FormalParm -> [VAR | CONST | OUT] Parameter
Parameter -> IdentList [':' ([ARRAY OF] SimpleType | STRING | FILE)]
-> Ident ':' SimpleType '=' ConstExpr
Directive -> CDECL
-> REGISTER
-> DYNAMIC
-> VIRTUAL
-> EXPORT
-> EXTERNAL
-> NEAR
-> FAR
-> FORWARD

-> MESSAGE ConstExpr
-> OVERRIDE
-> OVERLOAD
-> PASCAL
-> REINTRODUCE
-> SAFECALL
-> STDCALL
-> VARARGS
-> LOCAL
-> ABSTRACT
ObjectType -> OBJECT [ObjHeritage] [ObjFieldList] [MethodList] END
ObjHeritage -> '(' QualId ')'
MethodList -> (MethodHeading [';' VIRTUAL]) ';'...
MethodHeading -> ProcedureHeading
-> FunctionHeading

-> ConstructorHeading
-> DestructorHeading
ConstructorHeading -> CONSTRUCTOR Ident [FormalParameters]
DestructorHeading -> DESTRUCTOR Ident [FormalParameters]
ObjFieldList -> (IdentList ':' Type) ';'
InitSection -> INITIALIZATION StmtList [FINALIZATION StmtList] END
-> BEGIN StmtList END
-> END
ClassType -> CLASS [ClassHeritage]
[ClassVisibility]
[ClassFieldList]

[ClassMethodList]
[ClassPropertyList]
END
ClassHeritage -> '(' IdentList ')'
ClassVisibility -> [PUBLIC | PROTECTED | PRIVATE | PUBLISHED]
ClassFieldList -> (ClassVisibility ObjFieldList) ';'...
ClassMethodList -> (ClassVisibility MethodList) ';'...
ClassPropertyList -> (ClassVisibility PropertyList ';')...
PropertyList -> PROPERTY Ident [PropertyInterface] [PropertySpecifiers] [PortabilityDirective]

PropertyInterface -> [PropertyParameterList] ':' Ident
PropertyParameterList -> '[' (IdentList ':' TypeId) ';'... ']'
PropertySpecifiers -> [INDEX ConstExpr]
[READ Ident]
[WRITE Ident]
[STORED (Ident | Constant)]
[(DEFAULT ConstExpr) | NODEFAULT]
[IMPLEMENTS TypeId]
InterfaceType -> INTERFACE [InterfaceHeritage]
[ClassMethodList]

[ClassPropertyList] ...
END
InterfaceHeritage -> '(' IdentList ')'
RequiresClause -> REQUIRES IdentList... ';'
ContainsClause -> CONTAINS IdentList... ';'
IdentList -> Ident ','...
QualId -> [UnitId '.'] Ident
TypeId -> [UnitId '.'] <type-identifier>
Ident -> <identifier>
ConstExpr -> <constant-expression>
UnitId -> <unit-identifier>
LabelId -> <label-identifier>
Number -> <number>
String -> <string>
 
tseug高手帮帮忙,我知道你精通ASM,或许真能解决

http://www.delphibbs.com/delphibbs/dispq.asp?lid=3084975
 
这个有点意思。
又学到点,
 
这也被你发现了,你真行
 
你好!不知道如何找到你,所以就在这儿跟你问个问题了?
我在FORM上放了 两个RXRICHEDIT名子分别为SS,DD 我想把SS中的内容先放到剪贴板中然后再放入m流中,然后再从流M中读到剪贴板中,然后再追加到DD中,其中将剪贴板中的内容写入流是你在网上的一段程序,我试过了 假如是文字或文字与图片混排都是完全没问题,但是就是单图片时就不行了 我不知道为什么,请你指点! 谢谢!
unit Unit1;

interface

uses
Windows, Messages, SysUtils,Jpeg, clipbrd,Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, RxRichEd;

type
TForm1 = class(TForm)
ss: TRxRichEdit;
Button1: TButton;
Button2: TButton;
DD: TRxRichEdit;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject
var Action: TCloseAction);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
m:tmemorystream;
implementation

{$R *.dfm}
procedure CopyStreamToClipboard(fmt: cardinal
S: TStream);
var
hMem: THandle;
pMem: Pointer;
begin
Assert(Assigned(S));
S.Position := 0;
hMem := GlobalAlloc(GHND or GMEM_DDESHARE, S.Size);
if hMem <> 0 then
begin
pMem := GlobalLock(hMem);
if pMem <> nil then
begin
try
S.Read(pMem^, S.Size);
S.Position := 0;
finally
GlobalUnlock(hMem);
end;
Clipboard.Open;
try
Clipboard.SetAsHandle(fmt, hMem);
finally
Clipboard.Close;
end;
end { If }
else
begin
GlobalFree(hMem);
OutOfMemoryError;
end;
end { If }
else
OutOfMemoryError;
end
{ CopyStreamToClipboard }

procedure CopyStreamFromClipboard(fmt: cardinal
S: TStream);
var
hMem: THandle;
pMem: Pointer;
begin
Assert(Assigned(S));
hMem := Clipboard.GetAsHandle(fmt);
if hMem <> 0 then
begin
pMem := GlobalLock(hMem);
if pMem <> nil then
begin
try
S.Write(pMem^, GlobalSize(hMem));
S.Position := 0;
finally
GlobalUnlock(hMem);
end;
end { If }
else
raise Exception.Create('CopyStreamFromClipboard: could not lock global handle ' +
'obtained from clipboard!');
end
{ If }
end
{ CopyStreamFromClipboard }

procedure SaveClipboardFormat(fmt: word
writer: TWriter);
var
fmtname: array[0..128] of char;
ms: TMemoryStream;
begin
Assert(Assigned(writer));
if 0 = GetClipboardFormatName(fmt, fmtname, sizeof(fmtname)) then
fmtname[0] := #0;
ms := TMemoryStream.Create;
try
CopyStreamFromClipboard(fmt, ms);
if ms.Size > 0 then
begin
writer.WriteInteger(fmt);
writer.WriteString(fmtname);
writer.WriteInteger(ms.Size);
writer.Write(ms.Memory^, ms.Size);
end
{ If }
finally
ms.Free
end
{ Finally }
end
{ SaveClipboardFormat }

procedure LoadClipboardFormat(reader: TReader);
var
fmt: integer;
fmtname: string;
size: integer;
ms: TMemoryStream;
begin
Assert(Assigned(reader));
fmt := reader.ReadInteger;
fmtname := reader.ReadString;
size := reader.ReadInteger;
ms := TmemoryStream.Create;
try
ms.Size := size;
reader.Read(ms.memory^, size);
if Length(fmtname) > 0 then
fmt := RegisterCLipboardFormat(PChar(fmtname));
if fmt <> 0 then
CopyStreamToClipboard(fmt, ms);
finally
ms.Free;
end
{ Finally }
end
{ LoadClipboardFormat }

procedure SaveClipboard(S: TStream);
var
writer: TWriter;
i: integer;
begin
Assert(Assigned(S));
writer := TWriter.Create(S, 4096);
try
Clipboard.Open;
try
writer.WriteListBegin;
for i := 0 to Clipboard.formatcount-1 do
SaveClipboardFormat(Clipboard.Formats, writer);
writer.WriteListEnd;
finally
Clipboard.Close;
end
{ Finally }
finally
writer.Free
end
{ Finally }
end
{ SaveClipboard }

procedure LoadClipboard(S: TStream);
var
reader: TReader;
begin
Assert(Assigned(S));
reader := TReader.Create(S, 4096);
try
Clipboard.Open;
try
clipboard.Clear;
reader.ReadListBegin;
while not reader.EndOfList do
LoadClipboardFormat(reader);
reader.ReadListEnd;
finally
Clipboard.Close;
end
{ Finally }
finally
reader.Free
end
{ Finally }
end
{ LoadClipboard }



// Examples:

{ Save Clipboard }
{
procedure TForm1.Button1Click(Sender: TObject);
var
ms: TMemoryStream;
begin
ms := TMemoryStream.Create;
try
SaveClipboard(ms);
ms.SaveToFile('c:/temp/ClipBrdSaved.dat');
finally
ms.Free;
end
{ Finally }
//end;

{ Clear Clipboard }
{
procedure TForm1.Button2Click(Sender: TObject);
begin
clipboard.Clear;
end;

{ Restore Clipboard }
{
procedure TForm1.Button3Click(Sender: TObject);
var
fs: TfileStream;
begin
fs := TFilestream.Create('c:/temp/ClipBrdSaved.dat',
fmopenread or fmsharedenynone);
try
LoadClipboard(fs);
finally
fs.Free;
end
{ Finally }
//end;

procedure TForm1.Button1Click(Sender: TObject);
begin
m.Clear;
m.Position:=0;
ss.CopyToClipboard;
saveClipboard(m);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
m:=tmemorystream.Create;

end;

procedure TForm1.FormClose(Sender: TObject
var Action: TCloseAction);
begin
m.Free ;

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
clipboard.Clear;
m.Position:=0;
loadClipboard(m);
dd.PasteFromClipboard;
end;

end.
 
我刚才又试了 同时选为两幅图象时也没问题 就是选一个图象时有出错
 
后退
顶部