- 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! :)
type TyourHackGrid = class(TDBGrid); TyourHackGrid(yourDBGrid).RowHeights[0] := 50;Nice indeed ;)
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! ;)