تعدادی از مبدل ها:
BoolToStr(B: Boolean; UseBoolStrs: Boolean = False): string;
ByteToCharIndex(const S: string; Index: Integer): Integer;
CharToByteIndex(const S: string; Index: Integer): Integer;
CharToByteLen(const S: string; MaxLen: Integer): Integer;
CurrToStr(Value: Currency): string; overload;
CursorToString(Cursor: TCursor): string;
DateTimeToStr(const DateTime: TDateTime): string; overload;
DateTimeToString(var Result: string; const Format: string;
DateTimeToSystemTime(const DateTime: TDateTime; var SystemTime: TSystemTime);
DateTimeToTimeStamp(DateTime: TDateTime): TTimeStamp;
DateToStr(const DateTime: TDateTime): string; overload;
FloatToCurr(const Value: Extended): Currency;
FloatToDateTime(const Value: Extended): TDateTime;
FloatToDecimal(var Result: TFloatRec; const Value;
FloatToDecimal(var Result: TFloatRec; const Value;
FloatToStr(Value: Extended): string; overload;
FloatToText(BufferArg: PChar; const Value; ValueType: TFloatValue;
GUIDToString(const GUID: TGUID): string;
IntToHex(Value: Integer; Digits: Integer): string; overload;
IntToStr(Value: Integer): string; overload;
StrCharLength(const Str: PChar): Integer;
StringToCursor(const S: string): TCursor;
StringToGUID(const S: string): TGUID;
StrToBool(const S: string): Boolean;
StrToBoolDef(const S: string; const Default: Boolean): Boolean;
StrToCurr(const S: string): Currency; overload;
StrToCurrDef(const S: string; const Default: Currency): Currency;
StrToDate(const S: string): TDateTime;
StrToDate(const S: string): TDateTime; overload;
StrToFloat(const S: string): Extended; overload;
StrToInt(const S: string): Integer;
StrToInt64(const S: string): Int64;
StrToInt64Def(const S: string; const Default: Int64): Int64;
StrToIntDef(const S: string; Default: Integer): Integer;
StrToTime(const S: string): TDateTime; overload;
StrToTime(const S: string;
SystemTimeToDateTime(const SystemTime: TSystemTime): TDateTime;
TextToFloat(Buffer: PChar; var Value;
TimeStampToMSecs(const TimeStamp: TTimeStamp): Comp;
TimeToStr(const DateTime: TDateTime): string; overload;
TryStrToInt(const S: string; out Value: Integer): Boolean;
TryStrToInt64(const S: string; out Value: Int64): Boolean;
VarToStr(const V: Variant): string;
VarToStrDef(const V: Variant; const ADefault: string): string;
VarToWideStr(const V: Variant): WideString;
VarToWideStrDef(const V: Variant; const ADefault: WideString): WideString;
VarToDateTime(const V: Variant): TDateTime;
VarFromDateTime(const DateTime: TDateTime): Variant;
WideFormatVarToStr(var S: WideString; const V: TVarData);
محمد مقصودلو ::: چهارشنبه 87/7/24::: ساعت 1:24 عصر
یک کد عالی برای تبدیل تصویر به icon . هر کس با داشتن این کد می توانید یک نرم افزار جالب بسازد.شما می توانید برای کاربر محیطی را فراهم سازید که او بر روی یک تصویر با سایز ??*?? کار کند و سر انجام با این کد تصویر را به icon تبدیل کنید.به جای image تصویر را معرفی و به جای filename آدرس ذخیره سازی را وارد کنید:
procedure bmp2ico(image:timage;filename:tfilename);
var
bmp:tbitmap;
icon:ticon;
imagelist:timagelist;
begin
bmp:=tbitmap.Create;
icon:=ticon.Create;
try
bmp.Assign(image.picture);
imagelist:=timagelist.CreateSize(image.Width,image.Height);
try
imagelist.AddMasked(bmp,bmp.TransparentColor);
imagelist.GetIcon(0,icon);
icon.SaveToFile(FILENAME);
finally
imagelist.Free;
end;
finally
bmp.Free;
icon.Free;
end;
end;
//Copyright 2005 KOOSHA SYSTEM SOFTWARE HTTP://DELPHI-CENTER.BLOGFA.COM
محمد مقصودلو ::: چهارشنبه 87/7/24::: ساعت 1:24 عصر
شاید این موضوع در بسیاری از tip های برنامه نویسی وجود داشته باشد.
اما انجا ما از آن tip ها استفاده نکردیم و یک نوآوری و یک روش بسیار جالب به خرج دادیم.
1 - باید یک فایل را در تمام دیسک ها ذخیره کرد و با دستور Try Except آن را کنترل کرد .
* -> چیزهای مورد نیاز : یک Memo . یک Listbox و یک Button
اینم کدش :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: T);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function aa(a:integer):string;
begin
if a=1 then
aa:="c";
if a=2 then
aa:="d";
if a=3 then
aa:="e";
if a=4 then
aa:="f";
if a=5 then
aa:="g";
if a=6 then
aa:="h";
if a=7 then
aa:="i";
if a=8 then
aa:="j";
if a=9 then
aa:="k";
if a=10 then
aa:="l";
if a=11 then
aa:="m";
if a=12 then
aa:="n";
if a=13 then
aa:="o";
if a=14 then
aa:="p";
if a=15 then
aa:="q";
if a=16 then
aa:="r";
if a=17 then
aa:="s";
if a=18 then
aa:="t";
if a=19 then
aa:="u";
if a=20 then
aa:="v";
if a=21 then
aa:="w";
if a=22 then
aa:="x";
if a=23 then
aa:="y";
if a=24 then
aa:="z";
end;
procedure TForm1.Button1Click(Sender: T);
var i:integer;s:string;
begin
listbox1.Clear;
for i:=1 to 24 do
begin
s:=aa(i);
try
begin
memo1.Lines.SaveToFile(s+":\a.txt");
listbox1.Items.Add(s);
deletefile(s+":\a.txt");
end;
except
continue;
end;
end;
end;
end.
محمد مقصودلو ::: چهارشنبه 87/7/24::: ساعت 1:22 عصر
برای این کار شما باید اول مسیر ICON رو وارد کنید و بعد فایل مورد نظر را در درایو مورد نظر کپی کنید (هیچ کدام از این مراحل را لازم نیست شما طی کنید بلکه تمام کارها را باید با برنامه نوسی انجام دهید).
یک procedure به نام changeicon به صورت زیر تعریف کنید .
procedure changeicon(iconname:string;diskname:string);
var a:textfile;
begin
copyfile(pchar(iconname),pchar(diskname+":\dcblog.ico"),false);
filegetattr(diskname+":\dcblog.ico");
assignfile(a,"f:\AUTORUN.inf");
rewrite(a);
writeln(a,"[AUTORUN]");
writeln(a,"ICON=dcblog.ico");
closefile(a);
filegetattr(diskname+":\AUTORUN.inf");
end;
اجرا کنید button را در یک Procedure حالا این
procedure TForm1.Button1Click(Sender: T);
begin
changeicon("f:\aa.ico","c");
end;
محمد مقصودلو ::: چهارشنبه 87/7/24::: ساعت 1:22 عصر
اینم چیزه خوبیه . برای شروع کار گرافیکی در دلفی
برای این کار یک image بر روی فرم قرار دهید و یک button هم قرار دهید .
حالا کد های زیر را بنویسید :
procedure TForm1.Button1Click(Sender: T);
var I,q : integer;
begin
for q:= 1 to image1.Height-1 do
begin
for I := 1 to image1.Width-1 do
Image1.canvas.pixels[i,q]:=image1.canvas.pixels[i,q] div 256;
end;
end;
اگر رنگ هر پیکسل را بر 256 تقسیم کنیم رنگ ان زرد می شود
محمد مقصودلو ::: چهارشنبه 87/7/24::: ساعت 1:21 عصر
خوب یک کد عالی برای عوض کردن caption یک پنجره ی فعال
به جای notepad تیتر اون پنجره و به جای kss کلمه ی مطلوب را بنویسد:
setwindowtext(findwindow("notepad",nil),"kss");
محمد مقصودلو ::: چهارشنبه 87/7/24::: ساعت 12:53 عصر
بدون توضیح آنها را شرح می دهیم:
1 Invalid function number
2 File not found
3 Path not found
4 Too many open files
5 File access denied
6 Invalid file handle
12 Invalid file access code
15 Invalid drive number
16 Cannot remove current directory
17 Cannot rename across drives
100 Disk read error
101 Disk write error
102 File not assigned
103 File not open
104 File not open for input
105 File not open for output
106 Invalid numeric format
200 Division by zero
201 Range check error
202 Stack overflow error
203 Heap overflow error
204 Invalid pointer operation
205 Floating point overflow
206 Floating point underflow
207 Invalid floating point operation
210 not initialized
211 Call to abstract method
212 Stream registration error
213 Collection index out of range
214 Collection overflow error
215 Arithmetic overflow error
216 General protection fault
//© 2005 koosha system Software http://delphi-center.blogfa.com
محمد مقصودلو ::: چهارشنبه 87/7/24::: ساعت 12:48 عصر
با این کد دیگر نمی توان از کلید های میانبر کپی و پیست استفاده کرد.به محض فشردن آنها ابتدا چک می شود که آیا متن است یا نه . اگر متن بود کلیپ بورد پاک می شود.
uses Clipbrd;
procedure TForm1.Memo1KeyDown(Sender: T; var Key: Word;
Shift: TShiftState);
begin
if ((Key = ord("V")) and (ssCtrl in Shift)) then begin
if Clipboard.HasFormat(CF_TEXT) then ClipBoard.Clear;
key := 0;
end;
if ((Key = ord("C")) and (ssCtrl in Shift)) then begin
if Clipboard.HasFormat(CF_TEXT) then ClipBoard.Clear;
key := 0;
end;
end;
//© 2005 koosha system Software http://delphi-center.blogfa.com
محمد مقصودلو ::: چهارشنبه 87/7/24::: ساعت 12:46 عصر
این فیلتر برای تبدیل تصویر به نقاشی با مداد است.شما این فیلتر را در برنامه های معروفی چون فتوشاپ دیده اید.یک دکمه بر روی فرم ایجاد کنید و از کد زیر استفاده کنید.ُُ
procedure TForm1.Button2Click(Sender: T);
var x,y,z : integer;
begin
for x:= 1 to image1.Height-1 do
begin
for y := 1 to image1.Width-1 do
Image1.canvas.pixels[y,x]:=image1.canvas.pixels[y,x] div 256;
end;
for z:=0 to 2 do
begin
for y:= 1 to image1.Height-1 do
begin
for x := 1 to image1.Width-1 do
Image1.canvas.pixels[x,y]:=image1.canvas.pixels[x,y] * 256;
end;
end;
end;
محمد مقصودلو ::: چهارشنبه 87/7/24::: ساعت 12:45 عصر
یک کد برای یرعکس کردن رنگ های تصویر و در گفتار خودمانی Invert کردن عکس.این کد آخرین شماره ی رنگ یعنی سفید را از رنگ هر پیکسل کم می کند و مخالف همان رنگ بدست می آید.
procedure TForm1.Button1Click(Sender: T);
var a,b:integer;
begin //© 2005 koosha system Software
for a:=0 to Image1.Height-1 do
begin
for b:=0 to Image1.Width-1 do
Image1.Canvas.Pixels[b,a]:= clWhite-(Image1.Canvas.Pixels[b,a]);
end; //© 2005 koosha system Software
end;
محمد مقصودلو ::: چهارشنبه 87/7/24::: ساعت 12:44 عصر