?? ehlibvcl.pas
字號:
function SendTextMessage(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: string): LRESULT;
begin
Result := SendMessage(hWnd, Msg, wParam, Integer(PChar(lParam)));
end;
function SendGetTextMessage(hWnd: HWND; Msg: UINT; wParam: WPARAM; var lParam: String; BufferSize: Integer): LRESULT;
var
Text: array[0..4095] of Char;
begin
Word((@Text)^) := SizeOf(Text);
Result := SendMessage(hWnd, HWND, wParam, Longint(@Text));
SetString(lParam, Text, Result);
end;
function SystemParametersInfoEh(uiAction, uiParam: UINT; var pvParam; fWinIni: UINT): BOOL;
begin
Result := SystemParametersInfo(uiAction, uiParam, @pvParam, fWinIni);
end;
function WindowsInvalidateRect(hWnd: HWND; var Rect: TRect; bErase: BOOL): BOOL;
begin
Result := InvalidateRect(hWnd, @Rect, bErase);
end;
function WindowsValidateRect(hWnd: HWND; var Rect: TRect): BOOL;
begin
Result := ValidateRect(hWnd, @Rect);
end;
function WindowsScrollWindowEx(hWnd: HWND; dx, dy: Integer;
var prcScroll, prcClip: TRect;
hrgnUpdate: HRGN; {prcUpdate: TRect; }flags: UINT): BOOL;
begin
Result := ScrollWindowEx(hWnd, dx, dy, @prcScroll, @prcClip,
hrgnUpdate, nil, flags);
end;
function WindowsScrollWindow(hWnd: HWND; dx, dy: Integer; var prcScroll, prcClip: TRect): BOOL;
begin
Result := ScrollWindow(hWnd, dx, dy, @prcScroll, @prcClip);
end;
function FindWindowEh(lpClassName, lpWindowName: String): HWND;
begin
Result := FindWindow(PChar(lpClassName), PChar(lpWindowName));
end;
procedure VarToMessage(var VarMessage; var Message: TMessage);
begin
Message := TMessage(VarMessage);
end;
function MessageToTMessage(var Message): TMessage;
begin
Result := TMessage(Message);
end;
function MessageToTWMMouse(var Message): TWMMouse;
begin
Result := TWMMouse(Message);
end;
function MessageToTWMKey(var Message): TWMKey;
begin
Result := TWMKey(Message);
end;
function UnwrapMessageEh(var Message): TMessage;
begin
Result := TMessage(Message);
end;
function SmallPointToInteger(SmallPoint: TSmallPoint): Integer;
begin
Result := Integer(SmallPoint);
end;
function LongintToSmallPoint(Value: Longint): TSmallPoint;
begin
Result := TSmallPoint(Value);
end;
function WindowsLPtoDP(DC: HDC; var ARect: TRect): BOOL;
begin
Result := LPtoDP(DC, ARect, 2);
end;
function WindowsCreatePolygonRgn(Points: array of TPoint; Count, FillMode: Integer): HRGN;
begin
Result := CreatePolygonRgn(Points, Count, FillMode);
end;
procedure MessageSendGetSel(hWnd: HWND; var SelStart, SelEnd: Integer);
begin
SendMessage(hWnd, EM_GETSEL, Longint(@SelStart), Longint(@SelEnd));
end;
function NlsUpperCase(const S: String): String;
begin
Result := AnsiUpperCase(S);
end;
function NlsLowerCase(const S: String): String;
begin
Result := AnsiLowerCase(S);
end;
function NlsCompareStr(const S1, S2: String): Integer;
begin
Result := AnsiCompareStr(S1, S2);
end;
function NlsCompareText(const S1, S2: String): Integer;
begin
Result := AnsiCompareText(S1, S2);
end;
procedure BitmapLoadFromResourceName(Bmp: TBitmap; Instance: THandle; const ResName: String);
begin
Bmp.LoadFromResourceName(Instance, ResName);
end;
function LoadBitmapEh(hInstance: HINST; lpBitmapID: Integer): HBITMAP;
begin
Result := LoadBitmap(hInstance, PChar(lpBitmapID));
end;
function GetPropListAsArray(ATypeInfo: PTypeInfo; TypeKinds: TTypeKinds): TPropListArray;
var
PropList: PPropList;
PropCount, FSize, i: Integer;
begin
PropCount := GetPropList(ATypeInfo, tkProperties, nil);
FSize := PropCount * SizeOf(Pointer);
GetMem(PropList, FSize);
GetPropList(ATypeInfo, tkProperties, PropList);
SetLength(Result, PropCount);
for i := 0 to PropCount-1 do
Result[i] := PropList[i];
end;
function HexToBinEh(Text: Pointer; var Buffer: TBytes; Count: Integer): Integer;
begin
SetLength(Buffer, 0);
SetLength(Buffer, Count div 2);
Result := HexToBin(PChar(Text), PChar(Buffer), Count);
end;
procedure BinToHexEh(Buffer: TBytes; var Text: String; Count: Integer);
begin
SetString(Text, nil, Count*2);
BinToHex(PChar(Buffer), PChar(Text), Count);
end;
procedure StreamWriteBytes(Stream: TStream; Buffer: TBytes);
begin
Stream.Write(Pointer(Buffer)^, Length(Buffer));
end;
procedure StreamReadBytes(Stream: TStream; var Buffer: TBytes; Count: Integer);
var
bs: String;
i: Integer;
begin
SetLength(Buffer, Count);
SetString(bs, nil, Count);
Stream.Read(Pointer(bs)^, Count);
for i := 0 to Length(bs)-1 do
Buffer[i] := Byte(bs[i+1]);
end;
function BytesOf(S: String): TBytes;
var
i: Integer;
begin
SetLength(Result, Length(S));
for i := 0 to Length(S)-1 do
Result[i] := Byte(S[i+1]);
end;
function PropInfo_getPropType(APropInfo: PPropInfo): PTypeInfo;
begin
Result := APropInfo^.PropType^;
end;
function PropInfo_getName(APropInfo: PPropInfo): String;
begin
Result := APropInfo^.Name;
end;
function PropType_getKind(APropType: PTypeInfo): TTypeKind;
begin
Result := APropType^.Kind;
end;
procedure VarArrayRedimEh(var A : Variant; HighBound: Integer);
begin
VarArrayRedim(A, HighBound);
end;
function EmptyRect: TRect;
begin
Result := Rect(0, 0, 0, 0);
end;
{$IFNDEF EH_LIB_5}
function GetObjectProp(Instance: TObject; PropInfo: PPropInfo): TObject;
begin
Result := TObject(GetOrdProp(Instance, PropInfo));
end;
function GetObjectPropClass(Instance: TObject; PropInfo: PPropInfo): TClass;
var
TypeData: PTypeData;
begin
TypeData := GetTypeData(PropInfo^.PropType^);
if TypeData = nil then
raise Exception.Create('SUnknownProperty');
// raise EPropertyError.CreateRes(@SUnknownProperty);
Result := TypeData^.ClassType;
end;
procedure SetObjectProp(Instance: TObject; PropInfo: PPropInfo;
Value: TObject);
begin
if (Value is GetObjectPropClass(Instance, PropInfo)) or
(Value = nil) then
SetOrdProp(Instance, PropInfo, Integer(Value));
end;
{$ENDIF}
type
TPersistentCracker = class(TPersistent);
TComponentCracker = class(TComponent);
function GetUltimateOwner(APersistent: TPersistent): TPersistent;
begin
Result := TPersistentCracker(APersistent).GetOwner;
end;
{ TFilerAccess }
constructor TFilerAccess.Create(APersistent: TPersistent);
begin
inherited Create;
FPersistent := APersistent;
end;
procedure TFilerAccess.DefineProperties(AFiler: TFiler);
begin
TPersistentCracker(FPersistent).DefineProperties(AFiler);
end;
function TFilerAccess.GetChildOwner: TComponent;
begin
Result := TComponentCracker(FPersistent).GetChildOwner;
end;
function TFilerAccess.GetChildParent: TComponent;
begin
Result := TComponentCracker(FPersistent).GetChildParent;
end;
procedure TFilerAccess.GetChildren(Proc: TGetChildProc; Root: TComponent);
begin
TComponentCracker(FPersistent).GetChildren(Proc, Root);
end;
procedure TFilerAccess.SetAncestor(Value: Boolean);
begin
TComponentCracker(FPersistent).SetAncestor(Value);
end;
procedure TFilerAccess.SetChildOrder(Child: TComponent; Order: Integer);
begin
TComponentCracker(FPersistent).SetChildOrder(Child, Order);
end;
procedure TFilerAccess.Updated;
begin
TComponentCracker(FPersistent).Updated;
end;
procedure TFilerAccess.Updating;
begin
TComponentCracker(FPersistent).Updating;
end;
{ TMemoryStream }
constructor TMemoryStreamEh.Create;
begin
inherited Create;
HalfMemoryDelta := $1000;
end;
function TMemoryStreamEh.Realloc(var NewCapacity: Integer): Pointer;
var
MemoryDelta: Integer;
begin
MemoryDelta := HalfMemoryDelta * 2;
if (NewCapacity > 0) and (NewCapacity <> Size) then
NewCapacity := (NewCapacity + (MemoryDelta - 1)) and not (MemoryDelta - 1);
Result := Memory;
if NewCapacity <> Capacity then
begin
if NewCapacity = 0 then
begin
{$IFDEF MSWINDOWS}
GlobalFreePtr(Memory);
{$ELSE}
FreeMem(Memory);
{$ENDIF}
Result := nil;
end else
begin
{$IFDEF MSWINDOWS}
if Capacity = 0 then
Result := GlobalAllocPtr(HeapAllocFlags, NewCapacity)
else
Result := GlobalReallocPtr(Memory, NewCapacity, HeapAllocFlags);
{$ELSE}
if Capacity = 0 then
GetMem(Result, NewCapacity)
else
ReallocMem(Result, NewCapacity);
{$ENDIF}
{$IFDEF EH_LIB_5}
if Result = nil then raise EStreamError.CreateRes(@SMemoryStreamError);
{$ELSE}
if Result = nil then raise EStreamError.Create(SMemoryStreamError);
{$ENDIF}
end;
end;
end;
{$IFNDEF EH_LIB_6}
{ TDragObjectEx }
procedure TDragObjectEx.BeforeDestruction;
begin
// Do not call inherited here otherwise DragSave will be cleared and thus
// we will be unable to automatically free the dragobject.
end;
{$ENDIF}
procedure DataVarCast(var Dest: Variant; const Source: Variant; AVarType: Integer);
//function DataVarCast(const Source: Variant; AVarType: Integer): Variant;
begin
if VarIsNull(Source) then
Dest := Null
else if AVarType = varVariant then
Dest := Source
else
VarCast(Dest, Source, AVarType);
end;
function VariantToRefObject(Value: Variant): TObject;
begin
Result := TObject(Integer(Value));
end;
function RefObjectToVariant(Value: TObject): Variant;
begin
Result := Integer(Value);
end;
procedure DataVarCastAsObject(var Dest: Variant; const Source: Variant);
begin
DataVarCast(Dest, Source, varVariant);
end;
function WStrCopy(Dest: PWideChar; const Source: PWideChar): PWideChar;
var
Src : PWideChar;
begin
Result := Dest;
Src := Source;
while (Src^ <> #$00) do
begin
Dest^ := Src^;
Inc(Src);
Inc(Dest);
end;
Dest^ := #$00;
end;
{$RANGECHECKS OFF}
// Here and below all routins work without rangecheck
function ExplicitLongwordToLongInt(v: Longword): LongInt;
begin
Result := LongInt(v);
end;
function VarToWideStr(const V: Variant): WideString;
begin
if not VarIsNull(V) then
Result := V
else
Result := '';
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -