تیرماه 87 - کدهای آماده دلفی افزایش بازدید - افزایش بازدید و ترافیک سایت شما
سفارش تبلیغ
صبا ویژن
مردم دنیا همچون سوارانند که در خوابند و آنان را مى‏رانند . [نهج البلاغه]
کدهای آماده دلفی

برای باز کردن منو برنامه خود و فعال کردن گزینه مورد نظر در آن منو با استفاده از این روش امکان پذیر است

procedure TForm1.Button1Click(Sender: T);

 
procedure DropMenuAndSelectItem(MainMenuItemIndex,ItemIndex:integer);
 
var
    n : integer;
 
begin
    //Activate MainMenu
    keybd_event( VK_MENU, Mapvirtualkey( VK_MENU, 0 ), 0, 0 );
    keybd_event( VK_MENU, Mapvirtualkey( VK_MENU, 0 ), KEYEVENTF_KEYUP, 0 );

    keybd_event( VK_RETURN, MapVirtualKey( VK_RETURN, 0), 0, 0 );
    keybd_event( VK_RETURN, MapVirtualKey( VK_RETURN, 0), KEYEVENTF_KEYUP, 0 );

   
//Select MainMenuItem
    while (MainMenuItemIndex>0) do begin
      keybd_event( VK_RIGHT, MapVirtualKey( VK_RIGHT, 0), 0, 0 );
      keybd_event( VK_RIGHT, MapVirtualKey( VK_RIGHT, 0), KEYEVENTF_KEYUP, 0 );
      Dec(MainMenuItemIndex);
   
end;

   
//Select SubItem
    while (ItemIndex>0) do begin
      keybd_event( VK_DOWN, MapVirtualKey( VK_DOWN, 0), 0, 0 );
      keybd_event( VK_DOWN, MapVirtualKey( VK_DOWN, 0), KEYEVENTF_KEYUP, 0 );
      Dec(ItemIndex);
   
end;
 
end;
begin
  //Drop and select third item of the first MainMenuItem
  DropMenuAndSelectItem(0,2);
end;

برگرفته شده از سایت دنیای برنامه نویسی دلفی(http://mt85.blogfa.com)


 



محمد مقصودلو ::: شنبه 87/4/29::: ساعت 11:28 صبح

گرفتن اطلاعات سیستم - اطلاعاتی در رابطه با حافظه

procedure TForm1.Button1Click(Sender: T);
var
   MemoryStatus: TMemoryStatus;

begin

   Memo1.Lines.Clear;

   MemoryStatus.dwLength := SizeOf(MemoryStatus);

   GlobalMemoryStatus(MemoryStatus);

  
with MemoryStatus do
   begin
     { Size of MemoryStatus record }
     Memo1.Lines.Add(IntToStr(dwLength) +
      
" Size of ""MemoryStatus"" record");
    
{ Per-Cent of Memory in use by your system }
     Memo1.Lines.Add(IntToStr(dwMemoryLoad) +
      
"% memory in use");
    
{The amount of Total Physical memory allocated to your system.}
     Memo1.Lines.Add(IntToStr(dwTotalPhys) +
      
" Total Physical Memory in bytes");
    
{ The amount available of physical memory in your system. }
     Memo1.Lines.Add(IntToStr(dwAvailPhys) +
      
" Available Physical Memory in bytes");
    
{ The amount of Total Bytes allocated to your page file }
     Memo1.Lines.Add(IntToStr(dwTotalPageFile) +
      
" Total Bytes of Paging File");
    
{ The amount of available bytes in your page file }
     Memo1.Lines.Add(IntToStr(dwAvailPageFile) +
      
" Available bytes in paging file");
    
{ The amount of Total bytes allocated to this program
        (generally 2 gigabytes of virtual space) }
     Memo1.Lines.Add(IntToStr(dwTotalVirtual) +
      
" User Bytes of Address space");
    
{ The amount of avalable bytes that is left to your program to use }
     Memo1.Lines.Add(IntToStr(dwAvailVirtual) +
      
" Available User bytes of address space");
  
end;
end



محمد مقصودلو ::: شنبه 87/4/29::: ساعت 11:27 صبح

procedure CopyDirectory(Origen, Desti : string);
var
    Files : integer;

FOrigen, FDesti :
string;
ok : boolean;
Search : TSearchRec;
begin Files := FindFirst(Origen + "\*.*", faAnyFile, Search);
while Files = 0 do  begin  if Search.Attr <> faDirectory then  begin FOrigen := Origen + "\" + Search.Name;
FDesti := Desti +
"\" + Search.Name;
ok := CopyFile(PChar(FOrigen),PChar(FDesti),false);
if not ok then ShowMessage("No se pudo copiar el fichero: "+
Search.Name);
end  else  begin  if (Search.Name <> ".") and (Search.Name <> "..") then  begin ok := CreateDir(Desti + "\" + Search.Name);
if not ok then ShowMessage("No se pudo crear el directorio: "+
Search.Name)
else CopiaDirectori(Origen+"\"+Search.Name,Desti+"\"+Search.Name);
end;
end;
Files := FindNext(Search);
end;
FindClose(Search);
end;

برگرفته شده از سایت دنیای برنامه نویسی دلفی(http://mt85.blogfa.com)



محمد مقصودلو ::: شنبه 87/4/29::: ساعت 11:26 صبح

برای ذخیره کردن در فیلد بانک اطلاعاتی 
Table1.Append;

Table1Imagen.LoadFromfile(
"c:\image?.jpg");
Table1.Post;
نحوه لود کردن یک عکس از فیلد باینری بانک اطلاعاتی 
procedure TForm1.Button2Click(Sender: T);
var
   Jpeg:TJpegImage;

Corriente:TMemoryStream;
begin  {We crate a TJPejImage and a TMemoryStream} Jpeg:=TJpegImage.create;
Corriente:=TMemoryStream.create;
{Save the binary field in the stream} Table1Imagen.SaveToStream(Corriente);
{Rewind the stream} Corriente.Seek(0,soFromBeginning);
{Load the stream into the TJpegImage} Jpeg.LoadFromStream(Corriente);
{Assign the TJpegImage to the Image1 of the form} Image1.Picture.Assign(Jpeg);
{Free the temporal things} Corriente.Free;
Jpeg.Free;
end;

برگرفته شده از سایت دنیای برنامه نویسی دلفی(http://mt85.blogfa.com)




محمد مقصودلو ::: شنبه 87/4/29::: ساعت 11:22 صبح

procedure TForm1.StringGrid1DrawCell(Sender: T; Col, Row: Integer;

Rect: TRect; State: TGridDrawState);
var Grid : TStringGrid;
Texto :
String; const  {Escoger una de las tres}  {Choose one} ALINEACION = // DT_LEFT;
// DT_RIGHT;
DT_CENTER; begin Grid := TStringGrid(Sender);
if (Row < Grid.FixedRows) or (Col < Grid.FixedCols)
then Grid.Canvas.Brush.Color := clBtnFace
else Grid.Canvas.Brush.Color := clWhite;
Grid.Canvas.FillRect(Rect);
Texto := Grid.Cells[Col,Row];
DrawText( Grid.Canvas.Handle,
PChar(Texto),
StrLen(PChar(Texto)),
Rect,
ALINEACION);
end;

برگرفته شده از سایت دنیای برنامه نویسی دلفی(http://mt85.blogfa.com)



محمد مقصودلو ::: شنبه 87/4/29::: ساعت 11:21 صبح

procedure TForm1.FormCreate(Sender: T);
var
  hMenuHandle : HMENU;

i:Integer;
begin hMenuHandle := GetSystemMenu(handle, FALSE);
if (hMenuHandle <> 0) then begin DeleteMenu(hMenuHandle, SC_CLOSE, MF_BYCOMMAND);
i := GetMenuItemCount(hMenuHandle)-1;
if i > -1 then DeleteMenu(hMenuHandle,i,MF_BYPOSITION);
end; end;


محمد مقصودلو ::: شنبه 87/4/29::: ساعت 11:21 صبح

procedure TForm1.Button1Click(Sender: T);

const CLAVE =
 
"\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";

var
  reg    : TRegistry;
  Lista  : TStringList;
  Lista2 : TStringList;
  i,n    : integer;

begin
 {Create temporal things}
  reg    := TRegistry.Create;
  Lista  := TStringList.Create;
  Lista2 := TStringList.Create;

 
{Load all the subkeys}
 with Reg do
 begin
    RootKey := HKEY_LOCAL_MACHINE;
    OpenKey(CLAVE,false);
    GetKeyNames(Lista);
 
end;

 
{Load all the Value Names}
 for i := 0 to Lista.Count -1 do begin
    reg.OpenKey(CLAVE +
"\" +Lista.Strings[i],false);
    reg.GetValueNames(Lista2);

   
{We will show only if there is "DisplayName"}
    n:=Lista2.IndexOf("DisplayName");
   
if (n <> -1) and (Lista2.IndexOf("UninstallString")<>-1) then
 begin
 {DisplayName+UnInstallString}
      Memo1.Lines.Append ( reg.ReadString(Lista2.Strings[n])+"-"+
        reg.ReadString(Lista2.Strings[Lista2.IndexOf(
"UninstallString")]) );
   
end;
 
end;
 
{Free temporals}
  Lista.Free;
  Lista2.Free;
  reg.CloseKey;
  reg.Destroy;
end;

برگرفته شده از سایت دنیای برنامه نویسی دلفی(http://mt85.blogfa.com)


 



محمد مقصودلو ::: شنبه 87/4/29::: ساعت 11:16 صبح

نحوه اضافه کردن یک ستون برای شماره ردیف در گرید 

{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

1. create new blank field in dbgrid

2. rename the title with "No"

3. put this code in OnDrawColumncell

4. Now your Grid has a row number

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}

procedure TForm1.DBGrid1DrawColumnCell(Sender: T; const Rect: TRect;

DataCol: Integer; Column: TColumn; State: TGridDrawState);

begin

if DataSource1.DataSet.RecNo > 0 then

begin

if Column.Title.Caption = "No" then

DBGrid1.Canvas.TextOut(Rect.Left + 2, Rect.Top, IntToStr(DataSource1.DataSet.RecNo));

end;

end;

برگرفته شده از سایت دنیای برنامه نویسی دلفی(http://mt85.blogfa.com)



محمد مقصودلو ::: شنبه 87/4/29::: ساعت 11:14 صبح

نحوه افزدون کابر - تعریف کاربر برای لاگین در بانک اس کیو ال سرور

procedure TForm1.Button1Click(Sender: T);

begin

ADOConnection1.Connected := True;

ADOCommand1.CommandText := "Exec SP_AddLogin " + QuotedStr("UserName") +

"," + QuotedStr("Password") + "," + QuotedStr("Database Name") + "," +

QuotedStr("English") + ";";

ADOCommand1.Execute;

end;

برگرفته شده از سایت دنیای برنامه نویسی دلفی(http://mt85.blogfa.com)



محمد مقصودلو ::: شنبه 87/4/29::: ساعت 11:13 صبح

 

برای ریجستر کردن فایل های ocx از این روش استفاده نمایید

procedure TForm1.Button1Click(Sender: T);
type
  TDLLRegisterServer   = function: HResult stdcall;
var
  MangoOCX  : THandle;
  Registrar : TDllRegisterServer;
begin
  {Cargamos el OCX}
  {Load the OCX}
  MangoOCX:= LoadLibrary("c:\windows\system\html.ocx");
 
{Hallamos la direccion de la funcion para registrar el OCX}
  {Get the address to register the OCX}
  Registrar:= GetProcAddress(MangoOCX, "DllRegisterServer");
 
{Llamamos a la funci?n}
  {Call to the function}
  if Registrar <> 0 then ShowMessage("Error");
 
{Liberamos el OCX}
  {Free the OCX}
  FreeLibrary(MangoOCX);
end;

برگرفته شده از سایت دنیای برنامه نویسی دلفی(http://mt85.blogfa.com)




محمد مقصودلو ::: سه شنبه 87/4/25::: ساعت 11:39 صبح

<      1   2   3   4      >

لیست کل یادداشت های این وبلاگ

>> بازدیدهای وبلاگ <<
بازدید امروز: 7
بازدید دیروز: 42
کل بازدید :88482

>> درباره خودم <<
کدهای آماده دلفی
محمد مقصودلو
در این وبلاگ سعی میکنم مطالب مربوط به برنامه نویسی دلفی ، پاسکال و گرافیک رایانه ای 2 بعدی و 3 بعدی را به روز کنم منتظر سوالات شما نیز هستم

>>تست سرعت تایپ<<

>> پیوندهای روزانه <<

>>فهرست موضوعی یادداشت ها<<

>>آرشیو شده ها<<

>>لوگوی وبلاگ من<<
کدهای آماده دلفی

>>لوگوی دوستان<<



>>اشتراک در خبرنامه<<
 

>>طراح قالب<<


>>ذکر روزهای هفته<<

>>جستجوگر وبلاگها<<

>>ساعت<<

>> اخبار فناوری<<

>>جدیدترین اس ام اس های اینترنت<<

>>فال حافظ<<

>>دیکشنری آنلاین<<
-

>>جک یا لطیفه<<

>>هواشناسی<<

>>تاریخ و ساعت<<
جمعه 04/4/13 ساعت 2:49 صبح