محمد مقصودلو - کدهای آماده دلفی افزایش بازدید - افزایش بازدید و ترافیک سایت شما
خلق، نانخور خدایند . لذا محبوب ترینِ خلق نزد خدا، کسی است که به نانخوران خدا سودی رساند وخانواده ای را شادمان کند . [.رسول خدا صلی الله علیه و آله]
کدهای آماده دلفی

برای داشتن یک کامبو باکس با گزینه های که رنگ های گزینه ها با هم فرق می کند می توان از این روش استفاده کرد

 
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  with (Control as TComboBox) do
  begin
    {The Odd Items in Red, the others in black}
    {Los Items pares de color rojo}
    {Los impares en negro}
    if Odd(Index) then Canvas.Font.Color:=clRed
                  else Canvas.Font.Color:=clBlack;
    Canvas.FillRect(Rect);
    Canvas.TextOut(Rect.Left,Rect.Top,Items[Index]);
  end;
end;



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

از این تابع برای ذخیره یک تری ویو در یک اینی فایل استفاده کنید


procedure TreeToIni(Tree: TTreeView; INI: TIniFile; Section: string);
var
  n: Integer;
  MS: TMemoryStream;
  tTv: TStringList;
  Msg: string;
begin
  tTv := TStringList.Create;
  MS := TMemoryStream.Create;
  try
    Tree.SaveToStream(MS);
    MS.Position := 0;
    tTv.LoadFromStream(MS);
    INI.EraseSection(Section);
    for n := 0 to tTv.Count - 1 do
      INI.WriteString(Section, "Node" + IntToStr(n), StringReplace(tTv[n], #9,
        "#", [rfReplaceAll]));
  finally
    tTv.Free;
    MS.Free;
  end;
end;

procedure TreeFromIni(Tree: TTreeView; INI: TIniFile; Section: string;
  Expand: Boolean);
var
  n: Integer;
  MS: TMemoryStream;
  tTv: TStringList;
  Msg: string;
begin
  tTv := TStringList.Create;
  MS  := TMemoryStream.Create;
  try
    INI.ReadSection(Section, tTv);
    for n := 0 to tTv.Count - 1 do
      tTv[n] := StringReplace(INI.ReadString(Section, tTv[n], ""), "#", #9,
        [rfReplaceAll]);
    tTv.SaveToStream(MS);
    MS.Position := 0;
    Tree.LoadFromStream(MS);
    if (Expand = True) and (Tree.Items.Count > 0) then
      Tree.Items[0].Expand(True);
  finally
    tTv.Free;
    MS.Free;
  end;
end;

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



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

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

procedure TForm1.FormCreate(Sender: T);
const
  bgcolor = $00FFDDEE;
  linecolor = $00554366;
var
  img: array of TImage;
  reg: hrgn;
  i: Integer;
begin
  for i := 0 to ComponentCount - 1 do
  begin
    if Components[i].ClassName = "TPanel" then
    begin
      setlength(img, Length(img) + 1);
      img[i] := TImage.Create(Self);
      img[i].Width := (Components[i] as TPanel).Width;
      img[i].Height := (Components[i] as TPanel).Height;
      img[i].Parent := (Components[i] as TPanel);
      img[i].Canvas.Brush.Color := bgcolor;
      img[i].Canvas.pen.Color := bgcolor;
      img[i].Canvas.Rectangle(0,0,img[i].Width, img[i].Height);
      img[i].Canvas.pen.Color := linecolor;
      img[i].Canvas.RoundRect(0,0,img[i].Width - 1,img[i].Height - 1,20,20);
      reg := CreateRoundRectRgn(0,0,(Components[i] as TPanel).Width,
        (Components[i] as TPanel).Height, 20,20);
      setwindowrgn((Components[i] as TPanel).Handle, reg, True);
      delete(reg);
    end;
  end;
end;

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



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

با استفاده از این روش شما فرم برنامه شما همواره در وسط صفحه نمایش قرار دارد و امکان تغییر مکان آن وجود ندارد
ابتدا تابع را در قسمت توابع معرفی فرم قرار داده و سپس خود تابع را در برنامه قرار دهید


procedure Centrala(var m: TWMWINDOWPOSCHANGED); message   
   WM_WINDOWPOSCHANGING ;


  procedure TForm1.Centrala(var m : TWMWINDOWPOSCHANGED);
  begin
        m.windowpos.x := (Screen.Width - Width) div 2;   {Left/Posicion X}
        m.windowpos.y := (Screen.Height - Height) div 2; {Left/Posicion X}
  end;



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

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

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 صبح

<   <<   11   12   13   14      >

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

>> بازدیدهای وبلاگ <<
بازدید امروز: 2
بازدید دیروز: 21
کل بازدید :88620

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

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

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

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

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

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

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



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

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


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

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

>>ساعت<<

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

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

>>فال حافظ<<

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

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

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

>>تاریخ و ساعت<<
دوشنبه 04/4/16 ساعت 7:14 صبح