- ExtractFilePath : this will returns the directory for a file, including a backslash("\" ~ Env. Windows)
- ExpandFileName: Example : "c:\program files\yohan\is\cool\..\.." will returns "c:\program files\yohan\"
Two very handy functions! :)
procedure TForm1.btn1Click(Sender: TObject);
var
bmp : TBitmap;
begin
if(dlgOpenPic1.Execute()) then
begin
img1.Picture.LoadFromFile(dlgOpenPic1.FileName);
bmp := TBitmap.Create;
try
bmp.Width := img1.Picture.Width;
bmp.Height := img1.Picture.Height;
bmp.Canvas.Draw(0, 0, img1.Picture.Graphic);
Canvas.Draw(btn1.Left, btn1.Top + btn1.Height + 20, bmp);
finally
bmp.Free;
end;
end;
end;
Just dont forget to include the jpeg unit if you want to work with the jpegs, and for delphi 2009 and up you could add the PNGImage to work with png files on your delphi project//
// FunctionWithVarArgs()
//
// skeleton for a function that
// can accept vairable number of
// multi-type variables
//
// here are some examples on how
// to call this function:
//
// FunctionWithVarArgs(
// [ 1, True, 3, '5', '0' ] );
//
// FunctionWithVarArgs(
// [ 'one', 5 ] );
//
// FunctionWithVarArgs( [] );
//
procedure FunctionWithVarArgs(
const ArgsList : array of const );
var
ArgsListTyped :
array[0..$FFF0 div SizeOf(TVarRec)]
of TVarRec absolute ArgsList;
n : integer;
begin
for n := Low( ArgsList ) to
High( ArgsList ) do
begin
with ArgsListTyped[ n ] do
begin
case VType of
vtInteger : begin
{handle VInteger here} end;
vtBoolean : begin
{handle VBoolean here} end;
vtChar : begin
{handle VChar here} end;
vtExtended : begin
{handle VExtended here} end;
vtString : begin
{handle VString here} end;
vtPointer : begin
{handle VPointer here} end;
vtPChar : begin
{handle VPChar here} end;
vtObject : begin
{handle VObject here} end;
vtClass : begin
{handle VClass here} end;
vtWideChar : begin
{handle VWideChar here} end;
vtPWideChar : begin
{handle VPWideChar here} end;
vtAnsiString: begin
{handle VAnsiString here} end;
vtCurrency : begin
{handle VCurrency here} end;
vtVariant : begin
{handle VVariant here} end;
else begin
{handle unknown type here} end;
end;
end;
end;
end;Packed Recordstype
// Declare an unpacked record
TDefaultRecord = Record
name1 : string[4];
floater : single;
name2 : char;
int : Integer;
end;
// Declare a packed record
TPackedRecord = Packed Record
name1 : string[4];
floater : single;
name2 : char;
int : Integer;
end;
var
defaultRec : TDefaultRecord;
packedRec : TPackedRecord;
begin
ShowMessage('Default record size = '+IntToStr(SizeOf(defaultRec)));
ShowMessage('Packed record size = '+IntToStr(SizeOf(packedRec)));
end;there is more advanced usage for the record type of delphi, such as this one :type
TRect = packed record
case Integer of
0: (Left, Top, Right, Bottom: Integer);
1: (TopLeft, BottomRight: TPoint);
end; TRect.TopLeft will map to the TRect.Left and TRect.Top, TRect.BottomRight will map to the TRect.Right and TRect.Bottom, anoher usage would be like this one :type
// Declare a fruit record using case to choose the
// diameter of a round fruit, or length and height ohterwise.
TFruit = Record
name : string[20];
Case isRound : Boolean of // Choose how to map the next section
True :
(diameter : Single); // Maps to same storage as length
False :
(length : Single; // Maps to same storage as diameter
width : Single);
end;when isRound is true, you could define 1 more variable, and that is the diameter:Single, and if isRound is false, you could define 2 more variable, that is length, and width
procedure TForm1.Button1Click(Sender: TObject); type CRForm = class of TForm; var a: array[0..2] of CRForm; c: TForm; begin a[0] := TForm2; a[1] := TForm3; a[2] := TForm4; c := TForm(a[2].Create(self)); c.ShowModal; c.Free; end;welcome to the power! :)
HKEY_CURRENT_USER – SOFTWARE – MICROSOFT – WINDOWS – INTERNET SETTINGS – ZONESif you find Letter not Numbers, delete the Letter one.
type
TMyClass = class(TObject)
public
class var X: Integer;
end;
function JHROR32(Value : dword ; N : integer) : dword ; begin Result := (Value shr N) + (Value shl (32-N)); end; function JHROL32(Value : dword ; N : integer) : dword ; begin Result := (Value shl N) + (Value shr (32-N)); end;Hope you find it usefully! ;)
| Operator name | Syntax | in C | |
|---|---|---|---|
| Bitwise NOT | ~a | Yes | |
| Bitwise AND | a & b | Yes | |
| Bitwise OR | a | b | Yes | |
| Bitwise XOR | a ^ b | Yes | |
| Bitwise left shift | a << b | Yes | |
| Bitwise right shift | a >> b | Yes | |
Type Storage size RangeThis table is pasted from the original source at http://www.delphibasics.co.uk/Article.asp?Name=Numbers a great website for leaning delphi language
Byte 1 0 to 255
ShortInt 1 -127 to 127
Word 2 0 to 65,535
SmallInt 2 -32,768 to 32,767
LongWord 4 0 to 4,294,967,295
Cardinal 4* 0 to 4,294,967,295
LongInt 4 -2,147,483,648 to 2,147,483,647
Integer 4* -2,147,483,648 to 2,147,483,647
Int64 8 -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Single 4 7 significant digits, exponent -38 to +38
Currency 8 50+ significant digits, fixed 4 decimal places
Double 8 15 significant digits, exponent -308 to +308
Extended 10 19 significant digits, exponent -4932 to +4932
* Note : the Integer and Cardinal types are both 4 bytes in size at present (Delphi release 7), but are not guaranteed to be this size in the future. All other type sizes are guaranteed.