delphi huge tricks

1643
  1 !"# %&'()* ! #$%& '() *%'+,-.

Upload: elmorrover

Post on 04-Oct-2015

411 views

Category:

Documents


22 download

DESCRIPTION

Progrmación Delphi Pascal

TRANSCRIPT

  • 1

    HUGE TRICKS

    By TanZ tHe AnthroX

  • 2

    Bir Tlistbox icerisinde bulunan satirlarin, belli sartlara gre farkli renklerde olmasi mmkndr. Asagidaki kod rneginde bunun yapilisi gsterilmektedir. Dikkat edilmesi gereken en nemli husus, Listbox bileseninin Style zelligi lbOwnerDrawFixed olmalidir. //Style= lbOwnerDrawFixed olmali procedure TForm1.ListBox1DrawItem(Control: TWinControl;Index: Integer; Rect: TRect; State: TOwnerDrawState); begin with ( Control as TListBox ).Canvas do begin case Index of 0: begin Font.Color := clBlue; Brush.Color := clYellow; end; 1: begin Font.Color := clRed; Brush.Color := clLime; end; 2: begin Font.Color := clGreen; Brush.Color := clFuchsia; end; end; FillRect(Rect); TextOut(Rect.Left, Rect.Top, ( Control as TListBox).Items[Index]); end; end;

  • 3

    //IDE Servers blmndeki Wordapplication ile Dosya acmak //gerci Comobj ile Oleobj kullanmak daha kolay ama Nokta //dan sonra prosedr ve metotlari gsterdiginden bu faydali. //Degiskenler bos birakilmammali, olevariant olarak tanimlanmali. //Degiskenler hakkinda bilgiyi(tipi vs.) word Visual basic penceresindeki yardimdan grenebilirsiniz. procedure TForm1.Button2Click(Sender: TObject); var filename:Olevariant; s1,s2,s3,s4,s5,s6,s7,s8,s9:Olevariant; begin s1:=false;//ConfirmConversions Optional Variant. True s2:=false;//readonly s3:=false;//AddToRecentFiles Optional Variant. True s4:='';// The password for opening the document. s5:='';// The password for opening the template. s6:=true;//Revert s7:=''; //The password for saving changes to the document. s8:=''; //The password for saving changes to the template. s9:=wdOpenFormatAuto;//format. wa1.Disconnect;//word elle kaparsa hata vermemesi icin wa1.Connect; filename:='d:\worddelphi\ykdsubat2001.doc'; wa1.Visible:=true;//word gster wa1.Documents.Open(filename,s1,s2,s3,s4,s5,s6,s7,s8,s9);//degisken kac adetse tanimlanmali. end; procedure TForm1.Button3Click(Sender: TObject); begin wa1.Disconnect;//Word elle kapanirsa hata vermesin diye. //wordapplication1.Visible:=false;// Bunu kullanma. word cikarken degisiklikleri kaydetmek istiyormusunuz vs. diye sordugunda gremedigin icin acik kaliyor. wa1.Quit; end;

  • 4

    Masastndeki ikonlarin gizlenmesi

    Asagidaki program calistirildiginda, grev cubugu zerindeki uyari blmnde bir ikon olarak grnr. Bu ikon zerinde tiklandiginda desktop zerindeki ikonlar saklanir, bir kez daha basildiginda ise geri gelir. program DeskPop; uses Windows, Messages, ShellAPI, sysutils; {$R *.RES} const AppName = 'DeskTop Sakla'; var x: integer; tid: TNotifyIconData; WndClass: array[0..50] of char; procedure Panic (szMessage: PChar); begin if szMessage nil then MessageBox (0, szMessage, AppName, mb_ok); Halt (0); end; procedure HandleCommand (Wnd: hWnd; Cmd: Word); begin case Cmd of Ord ('A'): MessageBox (0, 'Merhaba', AppName, mb_ok); Ord ('E'): PostMessage (Wnd, wm_Close, 0, 0); end; end; function DummyWindowProc (Wnd: hWnd; Msg, wParam: Word; lParam: LongInt): LongInt; stdcall; var TrayHandle: THandle; dc: hDC; i: Integer; pm: HMenu; pt: TPoint; begin DummyWindowProc := 0; StrPCopy(@WndClass[0], 'Progman'); TrayHandle := FindWindow(@WndClass[0], nil); case Msg of wm_Create: begin tid.cbSize := sizeof (tid); tid.Wnd := Wnd; tid.uID := 1; tid.uFlags := nif_Message or nif_Icon or

  • 5

    tid.uFlags := nif_Message or nif_Icon or nif_Tip; tid.uCallBackMessage := wm_User; tid.hIcon := LoadIcon (hInstance, 'MAINICON'); lstrcpy (tid.szTip,'Desktop is on'); Shell_NotifyIcon (nim_Add, @tid); end; wm_Destroy: begin Shell_NotifyIcon (nim_Delete, @tid); PostQuitMessage (0); ShowWindow(TrayHandle, SW_RESTORE); end; wm_Command: begin HandleCommand (Wnd, LoWord (wParam)); Exit; end; wm_User: // Had a tray notification - see what to do if (lParam = wm_LButtonDown) then begin if x = 0 then begin ShowWindow(TrayHandle, SW_HIDE); //tid.hIcon := LoadIcon (hInstance, 'offICON'); lstrcpy (tid.szTip,'Desktop Kapali'); Shell_NotifyIcon (NIM_MODIFY, @tid); x:=1 end else begin ShowWindow(TrayHandle, SW_RESTORE); //tid.hIcon := LoadIcon (hInstance, 'ONICON'); lstrcpy (tid.szTip,'Desktop Acik'); Shell_NotifyIcon (NIM_MODIFY, @tid); x:= 0; end; end else if (lParam = wm_RButtonDown) then begin GetCursorPos (pt); pm := CreatePopupMenu; AppendMenu (pm, 0, Ord ('A'), 'Hakkinda...'); AppendMenu (pm, mf_Separator, 0, nil); AppendMenu (pm, 0, Ord ('E'), ''); SetForegroundWindow (Wnd); dc := GetDC (0); if TrackPopupMenu (pm, tpm_BottomAlign or tpm_RightAlign, pt.x,GetDeviceCaps(dc,HORZRES){pt.y}, 0, Wnd, nil) then SetForegroundWindow (Wnd); DestroyMenu (pm) end; end; DummyWindowProc := DefWindowProc (Wnd, Msg, wParam, lParam);

  • 6

    end; procedure WinMain; var Wnd: hWnd; Msg: TMsg; cls: TWndClass; begin { Previous instance running ? If so, exit } if FindWindow (AppName, nil) 0 then exit; //Panic (AppName + ' is already running.'); { window Sinifini kaydettir } FillChar (cls, sizeof (cls), 0); cls.lpfnWndProc := @DummyWindowProc; cls.hInstance := hInstance; cls.lpszClassName := AppName; RegisterClass (cls); { Bos pencereyi yarat } Wnd := CreateWindow (AppName, AppName, ws_OverlappedWindow, cw_UseDefault, cw_UseDefault, cw_UseDefault, cw_UseDefault, 0, 0, hInstance, nil); x:= 0; if Wnd 0 then begin ShowWindow (Wnd, sw_Hide); while GetMessage (Msg, 0, 0, 0) do begin TranslateMessage (Msg); DispatchMessage (Msg); end; end; end; begin WinMain; end.

  • 7

    Edit bileseninde sadece sayi yazmak

    function rakam(Key:Char):Char; begin if (Key>='0') and (Key

  • 8

    Harici bir ortamdan basilan tusu anlamak Keyboard Hook

    {*************************************************************} { TKeySpy Component for Delphi 16/32 } { Version: 2.8 } { E-Mail: [email protected] } { Home page: www.utilmind.com } { Created: August, 16, 1998 } { Modified: June, 6, 2000 } { Legal: Copyright (c) 1998-2000, UtilMind Solutions } {*************************************************************} { KEYBOARD SPY: } { This component is intended for interception of pressing the } { keyboard. The KeySpy is possible to apply for interception } { of the typed text of the another's programs, as keyboard } { spy, or for processing events at type certain keywords etc..} {*************************************************************} { Properties: ************************************************} { Enabled: as it usual... } { Keyword: At a set of this word event will be } { carried out (See OnKeyword event). } { ActiveLayout: Active keyboard layout (string) Win32 only } { SpyLayout: now present English, Russian, German } { & Italian } {ActiveWindowTitle: Title of active window (Read only) } { Events: ************************************************} { OnKeySpyDown: as OnKeyDown, but in any place (window). } { OnKeySpyUp: as OnKeyUp, but in any place (window). } { OnKeyword: The Keyword has been typed (See Keyword). } { OnLayoutChanged: The Keyboard layout was changed. Win32 only} { OnActiveWindowChanged: } {*************************************************************} { IMPORTANT NOTE: } { This code may be used and modified by anyone so long as } { this header and copyright information remains intact. By } { using this code you agree to indemnify UtilMind Solutions } { from any liability that might arise from its use. You must } { obtain written consent before selling or redistributing } { this code. } {*************************************************************} { Changes: } { 20.I.1999: Added 32-bit support } { 14.V.1999: Added OnChangeLayout event. } { Added Italian and Russian keyboard layouts. } { 28.V.1999: Added ActiveWindowTitle property. } { 27.VII.1999: Added Portugese keyboard layout. } { Thanks to Tiago Correia ([email protected])} { 19.IX.1999: Added German keyboard layout (added by Slaine, } { [email protected]) } { 5.V.2000: Added French keyboard layout (added by Vincent } { CALLIES, [email protected]) } {*************************************************************} unit KeySpy;

  • 9

    interface uses {$IFDEF WIN32} Windows, {$ELSE} WinTypes, WinProcs,{$ENDIF} SysUtils, Controls, Classes, Messages, Forms; type TSpyLayout = (klAmerican, klItalian, klRussian, klPortuguese, klGerman, klFrench); TOnKeySpy = procedure(Sender: TObject; Key: Byte; KeyStr: string) of object; {$IFDEF Win32} TOnLayoutChanged = procedure(Sender: TObject; Layout: string) of object; {$ENDIF} TOnActiveWindowChanged = procedure(Sender: TObject; ActiveTitle: string) of object; TKeySpy = class(TComponent) private {$IFDEF Win32} CurrentLayout: string; FActiveLayout: string; {$ENDIF} CurrentActiveWindowTitle: string; FActiveWindowTitle: string; FSpyLayout: TSpyLayout; FWindowHandle: HWnd; FOnKeySpyDown, FOnKeySpyUp: TOnKeySpy; FOnKeyword: TNotifyEvent; {$IFDEF Win32} FOnLayoutChanged: TOnLayoutChanged; {$ENDIF} FOnActiveWindowChanged: TOnActiveWindowChanged; FEnabled: Boolean; FKeyword, KeyComp: string; OldKey: Byte; LShiftUp, RShiftUp: Boolean; procedure UpdateTimer; procedure SetEnabled(Value: Boolean); procedure SetKeyword(Value: string); procedure WndProc(var Msg: TMessage); procedure SetNothingStr(Value: string); protected procedure KeySpy; dynamic; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; published property ActiveWindowTitle: string read FActiveWindowTitle write SetNothingStr; property Enabled: Boolean read FEnabled write SetEnabled; property Keyword: string read FKeyword write SetKeyword; property SpyLayout: TSpyLayout read FSpyLayout write FSpyLayout; {$IFDEF Win32} property ActiveLayout: string read FActiveLayout write FActiveLayout; {$ENDIF} property OnKeySpyDown: TOnKeySpy read FOnKeySpyDown write FOnKeySpyDown;

  • 10

    property OnKeySpyUp: TOnKeySpy read FOnKeySpyUp write FOnKeySpyUp; property OnKeyword: TNotifyEvent read FOnKeyword write FOnKeyword; {$IFDEF Win32} property OnLayoutChanged: TOnLayoutChanged read FOnLayoutChanged write FOnLayoutChanged; {$ENDIF} property OnActiveTitleChanged: TOnActiveWindowChanged read FOnActiveWindowChanged write FOnActiveWindowChanged; end; procedure register; implementation {$I KLayouts.inc} constructor TKeySpy.Create(AOwner: TComponent); begin inherited Create(AOwner); LShiftUp := True; RShiftUp := True; FEnabled := True; FWindowHandle := AllocateHWnd(WndProc); if FEnabled then UpdateTimer; end; destructor TKeySpy.Destroy; begin FEnabled := False; UpdateTimer; DeallocateHWnd(FWindowHandle); inherited Destroy; end; procedure TKeySpy.WndProc(var Msg: TMessage); begin with Msg do if Msg = WM_TIMER then try KeySpy; except Application.HandleException(Self); end else Result := DefWindowProc(FWindowHandle, Msg, wParam, lParam); end; procedure TKeySpy.UpdateTimer; var b: Byte; begin KillTimer(FWindowHandle, 1); if FEnabled then begin asm

  • 11

    mov al, 60h mov b, al end; OldKey := b; if SetTimer(FWindowHandle, 1, 1, nil) = 0 then raise EOutOfResources.Create('No timers'); end; end; procedure TKeySpy.SetEnabled(Value: Boolean); begin if Value FEnabled then begin FEnabled := Value; UpdateTimer; end; end; procedure TKeySpy.SetKeyword(Value: string); begin Value := LowerCase(Value); if Value FKeyword then FKeyword := Value; end; procedure TKeySpy.KeySpy; var PC: array[0..$FFF] of Char; Key: Byte; St: string; Wnd: hWnd; begin {$IFDEF Win32} Wnd := GetForegroundWindow; {$ELSE} Wnd := GetActiveWindow; {$ENDIF} SendMessage(Wnd, wm_GetText, $FFF, LongInt(@PC)); FActiveWindowTitle := StrPas(PC); if CurrentActiveWindowTitle FActiveWindowTitle then begin CurrentActiveWindowTitle := FActiveWindowTitle; if Assigned(FOnActiveWindowChanged) then FOnActiveWindowChanged(Self, FActiveWindowTitle); end; {$IFDEF Win32} GetKeyboardLayoutName(PC); FActiveLayout := StrPas(PC); if (FActiveLayout CurrentLayout) then begin CurrentLayout := FActiveLayout; if Assigned(FOnLayoutChanged) then FOnLayoutChanged(Self, FActiveLayout); end;

  • 12

    {$ENDIF} asm in al, 60h mov Key, al end; if Key = 170 then begin Key := 84; LShiftUp := True; end; if Key = 182 then begin Key := 85; RShiftUp := True; end; if Key = 42 then LShiftUp := False; if Key = 54 then RShiftUp := False; if Key OldKey then begin OldKey := Key; if Key

  • 13

    if Length(KeyComp) > Length(FKeyword) then begin Move(KeyComp[Length(St) + 1], KeyComp[1], Length(KeyComp)); {$IFDEF WIN32} SetLength(KeyComp, Length(FKeyword)); {$ELSE} KeyComp[0] := char(Length(FKeyword)); {$ENDIF} end; if LowerCase(KeyComp) = FKeyword then FOnKeyword(Self); end; end else if Key - 128

  • 14

    end.

    Gnderen: kizer

  • 15

    avi Dosyalarini Fullscreen oynatma( aviden baska da olabilir)

    Gerekenler: 1 Mediaplayer 2 Button 3 Panel "align client olacak" procedure TForm1.Button1Click(Sender: TObject); begin MediaPlayer1.FileName:='c:\hands.avi'; MediaPlayer1.Open; MediaPlayer1.Display := panel1; MediaPlayer1.DisplayRect := Rect(0 , 0, Form1.Clientwidth, Form1.ClientHeight); //avi dosyasini panel e yayyarak genisletme komutu// MediaPlayer1.Play; end; procedure TForm1.FormActivate(Sender: TObject); begin button1.click ; end; end.

    Gnderen: skywalker

  • 16

    programin ayni anda sadece 1 kez calismasi

    function AlreadyLoaded: Boolean; var wHandle: Integer; wTitle: array[0..100] of Char; wClass: array[0..100] of Char; begin StrPCopy(wTitle, Application.Title); StrPCopy(wClass, 'TApplication'); Application.Title := '$Test$'; wHandle := findWindow(wClass, wTitle); Application.Title := wTitle; Result := wHandle 0; if Result then begin ShowWindow(wHandle, SW_SHOWNORMAL); SetForegroundWindow(wHandle); end; end;

    Gnderen: mkx

  • 17

    internet baglanti tipinin bulunmasi

    function ConnectionKind :boolean; var flags: dword; begin Result := InternetGetConnectedState(@flags, 0); if Result then begin if (flags and INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM then begin showmessage('Modem'); end; if (flags and INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN then begin showmessage('LAN'); end; if (flags and INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY then begin showmessage('Proxy'); end; if (flags and INTERNET_CONNECTION_MODEM_BUSY)=INTERNET_CONNECTION_MODEM_BUSY then begin showmessage('Modem Busy'); end; end; end; /////kulanim procedure TForm1.Button3Click(Sender: TObject); begin ConnectionKind ; end;

    Gnderen: meymenet

  • 18

    Ctrl+Esc ve Alt+Tab Tuslarini Devre Disi Birakmak

    Devre Disi Birakmak icin: var OldVal : LongInt; begin SystemParametersInfo (97, Word (True), @OldVal, 0) end; Eski Haline Dndrmek: var OldVal : LongInt; begin SystemParametersInfo (97, Word (False), @OldVal, 0) end;

    Gnderen: erdem_15

    Programi taskbardan saklamak

    procedure TForm1.FormCreate(Sender: TObject); begin WS_EX_TOOLWINDOW); //taskbardan saklar SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW); end;

    Gnderen: metinsdr

  • 19

    Running an external application (and waiting)

    People have been asking me over and over: how can I run an external program from within a Delphi program? And also: how can I make the Delphi program wait until the external program is terminated? For just running an external application (or opening a registered file, opening a folder, printing a file, and so on), there are several functions available. In most cases, the Windows API-function ShellExecute is used. It gives some degree of control and at the same time it's not to complicated. Some examples:

    Start any application: ShellExecute(Handle, 'open', PChar('c:\test\app.exe'), nil, nil, SW_SHOW);

    Start NotePad (which is in the system's "path", so we don't have to specify the full path): ShellExecute(Handle, 'open', PChar('notepad'), nil, nil, SW_SHOW);

    Start NotePad and load a file: ShellExecute(Handle, 'open', PChar('notepad'), PChar('c:\test\readme.txt', nil, SW_SHOW);

    Open a textfile with NotePad (*.txt files are registered with the system): ShellExecute(Handle, 'open', PChar('c:\test\readme.txt'), nil, nil, SW_SHOW);

    You can do the previuos trick with any type of registered data-file, e.g. launch your browser with a certain URL: ShellExecute(Handle, 'open', PChar('http://www.festra.com/'), nil, nil, SW_SHOW);

    Print a file: ShellExecute(Handle, 'print', PChar('c:\test\readme.txt'), nil, nil, SW_SHOW);

    Explore a folder with Windows Explorer: ShellExecute(Handle, 'explore', PChar('c:\windows)', nil, nil, SW_SHOW);

    ------- Ayr bir dosya (program) nasl altrlr? Herhangi bir program altrmak iin

    ShellExecute(Handle, 'open', PChar('c:\test\Tanz_AnthroX.exe'), nil, nil, SW_SHOW); NOTEPAD'I altrmak

    ShellExecute(Handle, 'open', PChar('notepad'), nil, nil, SW_SHOW); NOTEPAD'e BeniOku.TXT dosyasn atrmak

    ShellExecute(Handle, 'open', PChar('notepad'), PChar('c:\AnthroX\benioku.txt', nil, SW_SHOW);

    Web sayfasn atrmak ShellExecute(Handle, 'open', PChar('http://www.delphiturk.com/'), nil, nil, SW_SHOW);

    Print ettirmek ShellExecute(Handle, 'print', PChar('c:\test\readme.txt'), nil, nil, SW_SHOW);

    WINDOWS EXPLORER la dizinlere bakmak ShellExecute(Handle, 'explore', PChar('c:\windows)', nil, nil, SW_SHOW);

  • 20

    Yuvarlak Form Olusyurma

    procedure TForm1.FormCreate(Sender: TObject); var region: HRgn; begin { yuvarlak form olusturur } region:=CreateEllipticRgn(1,1,200,200); SetWindowRgn(handle, region, true); end;

    Gnderen: aliuzun

  • 21

    Sisteme admin olarak mi girilmis ? (NT/2000) const SECURITY_NT_AUTHORITY: TSIDIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 5)); SECURITY_BUILTIN_DOMAIN_RID = $00000020; DOMAIN_ALIAS_RID_ADMINS = $00000220; function IsAdmin: Boolean; var hAccessToken: THandle; ptgGroups: PTokenGroups; dwInfoBufferSize: DWORD; psidAdministrators: PSID; x: Integer; bSuccess: BOOL; begin Result := False; bSuccess := OpenThreadToken(GetCurrentThread, TOKEN_QUERY, True, hAccessToken); if not bSuccess then begin if GetLastError = ERROR_NO_TOKEN then bSuccess := OpenProcessToken(GetCurrentProcess, TOKEN_QUERY, hAccessToken); end; if bSuccess then begin GetMem(ptgGroups, 1024); bSuccess := GetTokenInformation(hAccessToken, TokenGroups, ptgGroups, 1024, dwInfoBufferSize); CloseHandle(hAccessToken); if bSuccess then begin AllocateAndInitializeSid(SECURITY_NT_AUTHORITY, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, psidAdministrators); {$R-} for x := 0 to ptgGroups.GroupCount - 1 do if EqualSid(psidAdministrators, ptgGroups.Groups[x].Sid) then begin Result := True; Break; end; {$R+} FreeSid(psidAdministrators); end; FreeMem(ptgGroups); end; end; // Kullanimi: procedure TForm1.Button1Click(Sender: TObject); begin if isAdmin then

  • 22

    begin ShowMessage('Administrator olarak girilmis'); end; end.

    Microsot Outlook ile programdan mail gondermek

    uses comobj; procedure SendMail(Recipients, Attachments: TStringList; Subject, Body: string); const // OlItemType sabitleri // mail, not, kisi vs. olMailItem = 0; olAppointmentItem = 1; olContactItem = 2; olTaskItem = 3; olJournalItem = 4; olNoteItem = 5; olPostItem = 6; // OlAttachmentType constants olByValue = 1; olByReference = 4; olEmbeddedItem = 5; olOLE = 6; var myOlApp, myItem: OleVariant; i: integer; begin myOlApp := CreateOLEObject('Outlook.Application'); myItem := myOlApp.CreateItem(olMailItem); myItem.Subject := Subject; for i := 0 to Recipients.Count - 1 do myItem.Recipients.Add(Recipients[i]); for i := 0 to Attachments.Count - 1 do myItem.Attachments.Add(Attachments[i], olByValue, 1, Attachments[i]); myItem.Body := Body; myItem.Send; myOlApp := VarNull; myItem := VarNull; end; // kullanimi: procedure TForm1.Button1Click(Sender: TObject); var Alicilar, Dosyalar: TStringList; begin Alicilar := TStringList.Create; Alicilar.Add('[email protected]');

  • 23

    Alicilar.Add('[email protected]'); Dosyalar := TStringList.Create; Dosyalar.Add('C:\autoexec.bat'); Dosyalar.Add('C:\config.sys'); try SendMail(Alicilar, Dosyalar, 'Deneme Mail, Autoexec.bat ve config.sys', Memo1.Lines.Text); finally Alicilar.Free; Dosyalar.Free; end; end;

    Gnderen: webmaster

  • 24

    Microsoft Outlook'ta tanimli mail hesaplarinin alinmasi

    { Daha fazla bilgi ve detay icin Registry'de HKEY_CURRENT_USER anahtarinin altinda Software\Microsoft\Internet Account Manager\Accounts 'a bakiniz. } uses registry; function GetEMailAccounts: string; var Emails, Res: TStrings; AccountName, EmailTemp: string; POP3Server, POP3User, SMTPServer, SMTPName, SMTPEmailAdress: string; i: integer; begin Emails := TStringlist.create; Res := TStringlist.create; with TRegistry.Create do begin RootKey := HKEY_CURRENT_USER; LazyWrite := false; if KeyExists('Software\Microsoft\Internet Account Manager\Accounts') then OpenKey('Software\Microsoft\Internet Account Manager\Accounts', false); GetKeyNames(Emails); CloseKey; if Emails.Count > 0 then begin for i := 0 to Emails.Count - 1 do begin OpenKey('Software\Microsoft\Internet Account Manager\Accounts\' + Emails.Strings[i], False); AccountName := ReadString('Account Name'); POP3Server := ReadString('POP3 Server'); POP3User := ReadString('POP3 User Name'); SMTPServer := ReadString('SMTP Server'); SMTPName := ReadString('SMTP Display Name'); SMTPEmailAdress := ReadString('SMTP Email Address'); if AccountName = '' then AccountName := 'name not found'; if POP3User = '' then POP3User := 'login not found'; if SMTPName = '' then SMTPName := 'name not found'; if SMTPEmailAdress = '' then SMTPEmailAdress := 'email not found'; EmailTemp := '"' + AccountName + '": ' + SMTPName + ' (' + POP3User + '; ' + POP3Server + '/' + SMTPServer; if POP3Server '' then begin if SMTPServer '' then begin Res.Add(EmailTemp); end; end; CloseKey; end; Destroy; end; //with Emails.Free; end;

  • 25

    if Res.count = 0 then Res.Add('(email accounts not found)'); Result := ReS.Text; Res.Free; end;

    TListbox'a yatay scrollbar eklenmesi

    { Form'un create event handlerina asagidaki kodu ekleyin. Form uzerinde bulunan her bir listbox icin yapmaniz gerekli } procedure TForm1.FormCreate(Sender: TObject); begin SendMessage(ListBox1.Handle, LB_SetHorizontalExtent, 1000, // Kaydirma yapilcak uzunluk longint(0)); end;

    Gnderen: webmaster

  • 26

    Windows Taskbar'in saklanmasi ve tekrar gozukur hale getirilmesi

    procedure hideTaskbar; var wndHandle : THandle; wndClass : array[0..50] of Char; begin StrPCopy(@wndClass[0], 'Shell_TrayWnd'); wndHandle := FindWindow(@wndClass[0], nil); ShowWindow(wndHandle, SW_HIDE); // Sakla end; procedure showTaskbar; var wndHandle : THandle; wndClass : array[0..50] of Char; begin StrPCopy(@wndClass[0], 'Shell_TrayWnd'); wndHandle := FindWindow(@wndClass[0], nil); ShowWindow(wndHandle, SW_RESTORE); // Gster end; // Kullanimi: procedure TForm1.Button1Click(Sender: TObject); begin ShowTaskBar; end; procedure TForm1.Button2Click(Sender: TObject); begin HideTaskBar; end;

    Gnderen: webmaster

  • 27

    Verilen bir kredi karti numarasi'nin gecerli olup olmadiginin kontrol

    {------------------------------------------------- Credit card validator Returns: 0 : Card is invalid or unknown 1 : Card is a valid AmEx 2 : Card is a valid Visa 3 : Card is a valid MasterCard -------------------------------------------------} function Vc(c: string): integer; var card: string[21]; Vcard: array[0..21] of byte absolute card; Xcard: integer; Cstr: string[21]; y, x: integer; begin Cstr := ''; fillchar(Vcard, 22, #0); card := c; for x := 1 to 20 do if (Vcard[x] in [48..57]) then Cstr := Cstr + chr(Vcard[x]); card := ''; card := Cstr; Xcard := 0; if not odd(length(card)) then for x := (length(card) - 1) downto 1 do begin if odd(x) then y := ((Vcard[x] - 48) * 2) else y := (Vcard[x] - 48); if (y >= 10) then y := ((y - 10) + 1); Xcard := (Xcard + y) end else for x := (length(card) - 1) downto 1 do begin if odd(x) then y := (Vcard[x] - 48) else y := ((Vcard[x] - 48) * 2); if (y >= 10) then y := ((y - 10) + 1); Xcard := (Xcard + y) end;

  • 28

    x := (10 - (Xcard mod 10)); if (x = 10) then x := 0; if (x = (Vcard[length(card)] - 48)) then Vc := ord(Cstr[1])-ord('2') else Vc := 0 end;

    Gnderen: webmaster

  • 29

    Network'e baglanmis src listesinin alinmasi

    function GetNetworkDriveMappings(SList:TStrings):Integer; var I:Char; ThePath:string; MaxNetPathLen:DWord; begin SList.Clear; MaxNetPathLen:=MAX_PATH; SetLength(ThePath,MAX_PATH); for I := 'A' to 'Z' do if WNetGetConnection( PChar(''+I+':'),PChar(ThePath), MaxNetPathLen)=NO_ERROR then SList.Add(I+': '+ThePath); Result := SList.Count; end; // Kullanimi: procedure TForm1.Button1Click(Sender: TObject); begin GetNetworkDriveMappings(Form1.ListBox1.Items); end;

    Gnderen: webmaster

  • 30

    CD Srcnn kapagini acmak ve mak

    uses MMSystem; // Ac procedure Opendoor; begin mciSendString('Set cdaudio door open', nil, 0, 0); end; // procedure CloseDoor; begin mciSendString('Set cdaudio door closed', nil, 0, 0); end; //Kullanimi: procedure TForm1.Button1Click(Sender: TObject); begin Opendoor; end; procedure TForm1.Button2Click(Sender: TObject); begin Closedoor; end;

    Gnderen: webmaster

  • 31

    Dos Programini calistirip, input ve output'unu yonlendirmek ve bitene kadar beklemek

    {InputFile '' ise Dos programi klavyeden okuma yapar} function CreateDOSProcessRedirected(const CommandLine, InputFile, OutputFile, ErrMsg :string): boolean; const ROUTINE_ID = '[function: CreateDOSProcessRedirected]'; var OldCursor : TCursor; pCommandLine : array[0..MAX_PATH] of char; pInputFile, pOutPutFile : array[0..MAX_PATH] of char; StartupInfo : TStartupInfo; ProcessInfo : TProcessInformation; SecAtrrs : TSecurityAttributes; hAppProcess, hAppThread, hInputFile, hOutputFile : THandle; begin Result := FALSE; if (InputFile '') and (not FileExists(InputFile)) then raise Exception.CreateFmt(ROUTINE_ID + #10#10 + '* %s *' + #10 + 'does not exist' + #10#10 + ErrMsg, [InputFile]); hAppProcess := 0; hAppThread := 0; hInputFile := 0; hOutputFile := 0; OldCursor := Screen.Cursor; Screen.Cursor := crHourglass; try StrPCopy(pCommandLine, CommandLine); StrPCopy(pInputFile, InputFile); StrPCopy(pOutPutFile, OutputFile); FillChar(SecAtrrs, SizeOf(SecAtrrs), #0); SecAtrrs.nLength := SizeOf(SecAtrrs); SecAtrrs.lpSecurityDescriptor := nil; SecAtrrs.bInheritHandle := TRUE; if InputFile '' then begin hInputFile := CreateFile( pInputFile, GENERIC_READ or GENERIC_WRITE, FILE_SHARE_READ or FILE_SHARE_WRITE, @SecAtrrs,

  • 32

    OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL or FILE_FLAG_WRITE_THROUGH, 0); if hInputFile = INVALID_HANDLE_VALUE then raise Exception.CreateFmt(ROUTINE_ID + #10 + #10 + 'WinApi function returned an invalid handle value' + #10 +'for the input file * %s *' + #10 + #10 + ErrMsg, [InputFile]); end else hInputFile := 0; hOutputFile := CreateFile( pOutPutFile, GENERIC_READ or GENERIC_WRITE, FILE_SHARE_READ or FILE_SHARE_WRITE, @SecAtrrs, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL or FILE_FLAG_WRITE_THROUGH, 0 ); if hOutputFile = INVALID_HANDLE_VALUE then raise Exception.CreateFmt(ROUTINE_ID + #10 + #10 + 'WinApi function returned an invalid handle value' + #10 + 'for the output file * %s *' + #10 + #10 + ErrMsg, [OutputFile]); FillChar(StartupInfo, SizeOf(StartupInfo), #0); StartupInfo.cb := SizeOf(StartupInfo); StartupInfo.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES; StartupInfo.wShowWindow := SW_HIDE; StartupInfo.hStdOutput := hOutputFile; StartupInfo.hStdInput := hInputFile; Result := CreateProcess( nil, pCommandLine, nil, nil, TRUE, HIGH_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo); if Result then begin WaitforSingleObject(ProcessInfo.hProcess, INFINITE); hAppProcess := ProcessInfo.hProcess; hAppThread := ProcessInfo.hThread;

  • 33

    end else raise Exception.Create(ROUTINE_ID + #10 + #10 + 'Function failure' + #10 + #10 + ErrMsg); finally if hOutputFile 0 then CloseHandle(hOutputFile); if hInputFile 0 then CloseHandle(hInputFile); if hAppThread 0 then CloseHandle(hAppThread); if hAppProcess 0 then CloseHandle(hAppProcess); Screen.Cursor:= OldCursor; end; end; // Kullanimi: procedure TForm1.Button2Click(Sender: TObject); begin CreateDOSProcessRedirected('chkdsk c:\', '', 'C:\sil.txt', ''); Memo1.Lines.LoadFromFile('C:\sil.txt'); end;

    Gnderen: webmaster

  • 34

    Bilgisayar adinin alinmasi

    {Bilgisayar'a login olmus kullanici adi ile karistirmayiniz} function GetCompName: string; var buffer:array[0..MAX_COMPUTERNAME_LENGTH+1] of Char; length:Cardinal; begin length:=MAX_COMPUTERNAME_LENGTH+1; GetComputerName(@Buffer,length); Result := Buffer; end; // Kullanimi: procedure TForm1.Button1Click(Sender: TObject); begin Label1.Caption := GetCompName; end;

    Gnderen: webmaster

  • 35

    Bios bilgilerinin alinmasi

    procedure TForm1.Button1Click(Sender: TObject); begin with Memo1.Lines do begin Add('Tip:'+^I+string(Pchar(Ptr($FE061)))); Add('CopyRight:'+^I+string(Pchar(Ptr($FE091)))); Add('Bios Tarihi:'+^I+string(Pchar(Ptr($FFFF5)))); Add('Diger Bilgiler:'+^I+string(Pchar(Ptr($FEC71)))); end; end;

    Gnderen: webmaster

  • 36

    Sisteme login olmus kullanici adinin alinmasi

    function GetNetUser : Ansistring; var dwI : DWord; begin dwI := MAX_PATH; SetLength (Result, dwI + 1); if WNetGetUser (nil, PChar (Result), dwI) = NO_ERROR then SetLength (Result, StrLen (PChar (Result))) else SetLength (Result, 0) end;

    Gnderen: webmaster

    Programdan Start Menu'yu acmak

    Sendmessage(Application.Handle,WM_SYSCOMMAND,SC_TASKLIST,0); Gnderen: webmaster

  • 37

    Windows Explorer'dan program'a srklenen dosyalarin program tarafindan alinmasi

    uses ShellApi; procedure TForm1.FormCreate(Sender: TObject); begin DragAcceptFiles(Form1.Handle, true); Application.OnMessage := AppMessage; end; procedure TForm1.AppMessage(var Msg: Tmsg; var Handled: Boolean); const BufferLength : DWORD = 511; var DroppedFilename : string; FileIndex : DWORD; NumDroppedFiles : DWORD; pDroppedFilename : array [0..511] of Char; DroppedFileLength : DWORD; begin if Msg.message = WM_DROPFILES then begin FileIndex := $FFFFFFFF; NumDroppedFiles := DragQueryFile(Msg.WParam, FileIndex, pDroppedFilename, BufferLength); Memo1.Lines.Clear; for FileIndex := 0 to (NumDroppedFiles - 1) do begin DroppedFileLength := DragQueryFile(Msg.WParam, FileIndex, pDroppedFilename, BufferLength); DroppedFilename := StrPas(pDroppedFilename); Memo1.Lines.Add(pDroppedFilename); end; DragFinish(Msg.WParam); Handled := true; end; end;

    Gnderen: webmaster

  • 38

    Recycle Bin'in program icinden bosaltilmasi

    procedure EmptyRecycleBin; const SHERB_NOCONFIRMATION = $00000001; SHERB_NOPROGRESSUI = $00000002; SHERB_NOSOUND = $00000004; type TSHEmptyRecycleBin = function (Wnd: HWND; LPCTSTR: PChar; DWORD: Word): integer; stdcall; var SHEmptyRecycleBin: TSHEmptyRecycleBin; LibHandle: THandle; begin LibHandle := LoadLibrary(PChar('Shell32.dll')); if LibHandle 0 then @SHEmptyRecycleBin := GetProcAddress(LibHandle, 'SHEmptyRecycleBinA') else begin MessageDlg('Failed to load Shell32.dll.', mtError, [mbOK], 0); Exit; end; if @SHEmptyRecycleBin nil then SHEmptyRecycleBin(Application.Handle, '', SHERB_NOCONFIRMATION or SHERB_NOPROGRESSUI or SHERB_NOSOUND); FreeLibrary(LibHandle); @SHEmptyRecycleBin := nil; end;

    Gnderen: webmaster

  • 39

    TImage yazicidan nasil yazdirilir ?

    // Printers unit'ini eklemeyi unutmayin. procedure TForm1.PrintBitmap(TheImage : TImage); var SourceRect, PrintRect: TRect; Info: PBitmapInfo; InfoSize: dword; Image: Pointer; ImageSize: dword; Bits: HBitmap; DIBWidth, DIBHeight: LongInt; PrintWidth, PrintHeight: LongInt; PrintBitmap: TBitmap; begin Printer.BeginDoc; PrintBitmap := TBitmap.Create; SourceRect.Left := TheImage.Left; SourceRect.Top := TheImage.Top; SourceRect.Right := TheImage.Left + Image1.Width; SourceRect.Bottom := TheImage.Top + Image1.Height; { Set up the height and width of the destination bitmap } PrintBitmap.Height := SourceRect.Bottom - SourceRect.Top + 1; PrintBitmap.Width := SourceRect.Right - SourceRect.Left + 1; { Set the destination coordinates } PrintRect.Top := 0; PrintRect.Left := 0; PrintRect.Right := PrintBitmap.Width; PrintRect.Bottom := PrintBitmap.Height; { Copy from the screen to the printer } PrintBitmap.Canvas.CopyRect(PrintRect, self.Canvas, SourceRect); { Here we will stretch the bitmap, and do the printing } with Printer, Canvas do begin { Get the handle to the Print bitmap } Bits := PrintBitmap.Handle; { Get the information from the bitmap } GetDIBSizes(Bits, InfoSize, ImageSize); { Allocate the required memory for the operation } GetMem(Info, InfoSize); try GetMem(Image, ImageSize); try GetDIB(Bits, 0, Info^, Image^); with Info^.bmiHeader do begin DIBWidth := biWidth;

  • 40

    DIBHeight := biHeight; end; { Adjust the print sizes (expand or contract) } PrintWidth := MulDiv(DIBWidth, GetDeviceCaps(Handle, LOGPIXELSX), PixelsPerInch); PrintHeight := MulDiv(DIBHeight, GetDeviceCaps(Handle, LOGPIXELSY), PixelsPerInch); { Move from one canvas to the other while stretching or compressing the image } StretchDIBits(Canvas.Handle, 0, 0, PrintWidth, PrintHeight, 0, 0,DIBWidth, DIBHeight, Image, Info^, DIB_RGB_COLORS, SRCCOPY); finally FreeMem(Image, ImageSize); end; finally FreeMem(Info, InfoSize); end; end; Printer.EndDoc; end;

    Gnderen: webmaster

  • 41

    Ip adresinden herhangi bir bilgisayar adinin bulunmasi

    uses winsock; function IPAddrToName(IPAddr : string): string; var SockAddrIn: TSockAddrIn; HostEnt: PHostEnt; WSAData: TWSAData; begin WSAStartup($101, WSAData); SockAddrIn.sin_addr.s_addr:= inet_addr(PChar(IPAddr)); HostEnt:= gethostbyaddr(@SockAddrIn.sin_addr.S_addr, 4, AF_INET); if HostEntnil then begin result:=StrPas(Hostent^.h_name) end else begin result:=''; end; end; procedure TForm1.Button1Click(Sender: TObject); begin label1.Caption:=IPAddrToName(edit1.text); end;

    Gnderen: webmaster

  • 42

    Programin End Task menusunde gorunmesini engellemek (CTRL-ALT-DEL)

    ... implementation function RegisterServiceProcess (dwProcessID, dwType: DWord) : DWord; stdcall; external 'KERNEL32.DLL'; {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); begin // sakla RegisterServiceProcess(GetCurrentProcessID,1); end; procedure TForm1.Button2Click(Sender: TObject); begin // tekrar gster RegisterServiceProcess(GetCurrentProcessID,0); end;

    Gnderen: webmaster

  • 43

    Host adindan IP adresini bulmak

    function HostToIPAddr(Name: string; var Ip: string): Boolean; var wsdata : TWSAData; hostName : array [0..255] of char; hostEnt : PHostEnt; addr : PChar; begin WSAStartup ($0101, wsdata); try gethostname (hostName, sizeof (hostName)); StrPCopy(hostName, Name); hostEnt := gethostbyname (hostName); if Assigned (hostEnt) then if Assigned (hostEnt^.h_addr_list) then begin addr := hostEnt^.h_addr_list^; if Assigned (addr) then begin IP := Format ('%d.%d.%d.%d', [byte (addr [0]), byte (addr [1]), byte (addr [2]), byte (addr [3])]); Result := True; end else Result := False; end else Result := False else begin Result := False; end; finally WSACleanup; end end; // Kullanimi: procedure TForm1.Button1Click(Sender: TObject); var IP: string; begin if HostToIpAddr(Edit1.Text, IP) then Label1.Caption := IP; end;

    Gnderen: webmaster

  • 44

    Exe dosyasina her hangibir dosya (Txt, mid vb) nasil gomulur ? { Projenize resource eklemek icin Sirayla takip ediniz. Delphi 4.0 icin: 1. Project|Resources komutu veriniz. 2. Gelen pencerede sag tiklayip New|User Data 3. Resource tipini yaziniz. Ornek: EXE (RcData gelecektir) 3. Hangi dosyayi eklemek istiyorsaniz seciniz 4. Exe_1 olarak Exe tipinde eklenecektir. EXE_1 in zerinde sag tiklayip Rename dedikten sonra EXE_1'i herhangi bir tamsayi ile adini degistirin. r: 1 (EXE_1 -> 1) } procedure SaveRessourceToFile(const FileName, ResType: string; ResId: Integer); var MStream: TResourceStream; begin MStream := TResourceStream.CreateFromID(HInstance, ResId, PChar(ResType)); try MStream.SaveToFile(FileName); finally MStream.Free; end; end; // Kullanimi: (Yukardaki islemden sonra SaveRessourceToFile('c:\deneme.exe', 'EXE', 1);

    Gnderen: webmaster

  • 45

    Herhangi bir internet adresinin (HTTP, FTP, Bilgisayar Adi) gecerli olup olmadigi kontrol etmek, IP adresini bulmak

    uses winsock; function HostToIPAddr(Name: string; var Ip: string): Boolean; var wsdata : TWSAData; hostName : array [0..255] of char; hostEnt : PHostEnt; addr : PChar; begin WSAStartup ($0101, wsdata); try gethostname (hostName, sizeof (hostName)); StrPCopy(hostName, Name); hostEnt := gethostbyname (hostName); if Assigned (hostEnt) then if Assigned (hostEnt^.h_addr_list) then begin addr := hostEnt^.h_addr_list^; if Assigned (addr) then begin IP := Format ('%d.%d.%d.%d', [byte (addr [0]), byte (addr [1]), byte (addr [2]), byte (addr [3])]); Result := True; end else Result := False; end else Result := False else begin Result := False; end; finally WSACleanup; end end; // Kullanimi: procedure TForm1.Button1Click(Sender: TObject); var IP: string; begin if HostToIpAddr(Edit1.Text, IP) then ShowMessage(Format('Gecerli Adres. IP: %s', [IP])) else ShowMessage('Gecerisiz adres'); end;

    Gnderen: webmaster

  • 46

    Ayri bir dosya (program) nasil calistirilir? print edilir?

    //Ayri bir dosya (program) nasil calistirilir? //Herhangi bir programi calistirmak icin ShellExecute(Handle, 'open', PChar('c:\test\Tanz_AnthroX.exe'), nil, nil, SW_SHOW); //NOTEPAD'I calistirmak ShellExecute(Handle, 'open', PChar('notepad'), nil, nil, SW_SHOW); //NOTEPAD'e BeniOku.TXT dosyasini actirmak ShellExecute(Handle, 'open', PChar('notepad'), PChar('c:\AnthroX\benioku.txt', nil, SW_SHOW); //Web sayfasini actirmak ShellExecute(Handle, 'open', PChar('http://www.delphiturk.com/'), nil, nil, SW_SHOW); //Print ettirmek ShellExecute(Handle, 'print', PChar('c:\test\readme.txt'), nil, nil, SW_SHOW); //WINDOWS EXPLORER la dizinlere bakmak ShellExecute(Handle, 'explore', PChar('c:\windows)', nil, nil, SW_SHOW);

    Gnderen: Tanz_AnthroX

  • 47

    Sanirim degil :)) Neyse al sana hem TaskManagerden hemde TaskBardan gizleme ile ilgili bilgiler. Kisa ve acik! Isin sirri toolwindow olmasinda... // Make the Form invisible Application.ShowMainForm := False; // Hide from the Taskbar for ever ShowWindow (Application.Handle, SW_HIDE); SetWindowLong(Application.Handle, GWL_EXSTYLE, GetWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW); // Hide from Task-Manager RegisterServiceProcess (0, 1) Look in the WinApi help for more informaton about RegisterServiceProcess I use this code in the OnCreate-Event

  • 48

    !************************************** ! Name: File Splitter / Joiner ! Description:The Functions Can Split A ! File Into Many Pieces And Then Rejoin At ! A Later Date. ! By: wrastus ! ! Inputs:Two Sample Calls: SplitFile('C:\afilename.exe',40000); UnSplit('C:\samefilenameasabovewith-rtr-extension.rtr',40000); ! !This code is copyrighted and has ! limited warranties.Please see http://w ! ww.Planet-Source-Code.com/xq/ASP/txtCode ! Id.311/lngWId.7/qx/vb/scripts/ShowCode.h ! tm !for details. !************************************** function Smaller(const a,b:LongInt) :LongInt; begin if(a < b)then begin Result := a; end else if(b > 0)then begin Result := b end else Result := 0; end; Function SplitFile(FFileName : AnsiString; SplitSize : Longint): Boolean; Var InFile : TFileStream; OutFile : TFileStream; FilePlace : Integer; INI : TIniFile; FileInfo : TFinfo; Begin InFile := TFileStream.Create(FFileName,fmOpenRead); If InFile.Size > SplitSize Then Begin FilePlace := 0; While InFile.Position < InFile.Size Do Begin Inc(FilePlace); OutFile := TFileStream.Create(FFileName + '.' + FormatFloat('000',FilePlace),fmCreate); OutFile.CopyFrom(InFile,Smaller(SplitSize,InFile.Size - InFile.Position)); OutFile.Free; End; End Else ShowMessage('The File Is To Small To Split'); InFile.Free; INI := TIniFile.Create(ChangeFileExt(FFileName,'.rtr')); INI.WriteString('Files','Number',IntToStr(FilePlace)); INI.WriteString('Files','Name',FFileName); INI.Free; Result := True; End; Function UnSplit(FFileName : TFileName; BufferSize : LongInt):Boolean; Var INI : TIniFile; InFile : TFileStream; OutFile : TFileStream; FilePlace : Integer; NFiles : Integer; FFile : TFileName; BytesRead : LongInt; Buffer : Pointer;

  • 49

    FString : TFileName; Begin GetMem(Buffer,BufferSize); INI := TIniFile.Create(FFileName); NFiles := StrToInt(INI.ReadString('Files','Number','0')); FFile := INI.ReadString('Files','Name','0'); OutFile := TFileStream.Create(FFile,fmCreate); FilePlace := 1; While FilePlace

  • 50

    Source for Non-Rectangular Windows

    unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) procedure FormClick(Sender: TObject); procedure FormCreate(Sender: TObject); private IsRound : Boolean; public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.FormClick(Sender: TObject); var R : HRgn; begin if IsRound then begin SetWindowRgn(Handle,0,True); DeleteObject(R); IsRound := False; end else begin R := CreateEllipticRgn(-15,-15,Width+15,Height+15); SetWindowRgn(Handle,R,True); IsRound := True; end; end; procedure TForm1.FormCreate(Sender: TObject); begin IsRound := False; end; end.

  • 51

    The application code

    Listing A shows our example application's main unit. We've added some painting code to outline the window in black so it's easier to see. We've also added code that lets you drag the window by clicking anywhere in it. Note that the title bar of the window is still there--it's just invisible. You can still close the application by pressing [Alt][F4]. Listing A: StarRgnU.pas unit StarRgnU; interface uses Windows, Forms, Controls, StdCtrls, Classes, Messages; type TForm1 = class(TForm) CloseBtn: TButton; Label1: TLabel; procedure FormCreate(Sender: TObject); procedure FormPaint(Sender: TObject); procedure CloseBtnClick(Sender: TObject); private { Private declarations } procedure WmNCHitTest(var Msg : TWMNCHitTest); message WM_NCHITTEST; public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} const { An array of points for the star region. } RgnPoints : array[1..10] of TPoint = ((X:203;Y:22), (X:157;Y:168), (X:3;Y:168), (X:128;Y:257), (X:81;Y:402), (X:203;Y:334), (X:325;Y:422), (X:278;Y:257), (X:402;Y:168), (X:249;Y:168)); { An array of points used to draw a line } { around the region in the OnPaint handler. } LinePoints : array[1..11] of TPoint = ((X:199;Y:0), (X:154;Y:146), (X:2;Y:146), (X:127;Y:235), (X:79;Y:377), (X:198;Y:308), (X:320;Y:396), (X:272;Y:234),(X:396;Y:146), (X:244;Y:146), (X:199;Y:0)); procedure TForm1.FormCreate(Sender: TObject); var Rgn : HRGN; begin { Create a polygon region from our points. } Rgn := CreatePolygonRgn( RgnPoints, High(RgnPoints), ALTERNATE); { Set the window region. } SetWindowRgn(Handle, Rgn, True); end;

  • 52

    procedure TForm1.FormPaint(Sender: TObject); begin { Draw a line around the star. } Canvas.Pen.Width := 3; Canvas.Polyline(LinePoints); end; procedure TForm1.CloseBtnClick(Sender: TObject); begin Close(); end; { Catch the WM_NCHITTEST message so the user } { can drag the window around the screen. } procedure TForm1. WmNCHitTest(var Msg: TWMNCHitTest); begin DefaultHandler(Msg); if Msg.Result = HTCLIENT then Msg.Result := HTCAPTION; end; end.

  • 53

    All I was asking was how to create a irregular window from a region, cause I missed the function that does the trick!!!! I found it... It is the SetWindowRgn function. I can now have a form in any shape... Thank you for replying to my question, and here is the answer: ---- Example - Making a form in the shape of a baloon ----- { Put the following code in the event handler of a button in a form. Put the button in the center of the form. When the button is clicked, the form will change shape. See the Win32.Hlp and look into the Region Reference to be able to create any Region for the window } procedure TForm1.Button1Click(Sender: TObject); var Reg1: HRGN; Reg2: HRGN; Reg: HRGN; Apoint: Array[0..2] of TPoint; begin APoint[0] := Point(40,ClientHeight-30); APoint[1] := Point(30,ClientHeight); APoint[2] := Point(20,ClientHeight-20); Reg1 := CreatePolygonRgn(Apoint, 3, WINDING); Reg2 := CreateRoundRectRgn ( Width-ClientWidth, Height-ClientHeight, ClientWidth, ClientHeight - 10, 55, 55); Reg := CreateRectRgn(150,50,200,100); CombineRgn(Reg, Reg1, Reg2, RGN_OR); SetWindowRgn (handle, Reg, true); DeleteObject(Reg1); DeleteObject(Reg2); { Do not delete Reg object cause it is now owned by the OS } end; { You can make the form to be dragged when the user clicks inside it by setting the OnMouseDownEvent for it to the following .} procedure TForm2.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin If button = mbleft then begin ReleaseCapture; Perform (WM_syscommand, $F012, 0); end; end; { COMMENTS: --------- $F012 is the WParam of the SysCommand message received when the user click in the window caption. Whe can fool it into thinking that the Caption was hit and then begin to drag the Window. The value $F012 is not documented in the Win32 API, so o made the following event handler and discovered it: Declared this function in the private section of Form1: procedure WMSysCommand(var Message: TMessage); message WM_SYSCOMMAND; Implemented it this way: procedure TForm2.WMSysCommand(var Message: TMessage); begin ShowMessage(IntToHex(Message.WParam,4) ); inherited; end; When you Hit the caption of the form if shows a message box with $F012 Why didn't those pretty useful thing aren't documented? } Following is the help for the SetWindowRgn function >>> ---- Help for SetWindowRgn ------ SetWindowRgn (WIN32.HLP) [New - Windows NT] The SetWindowRgn function sets the window region of a window. The window region determines the area

  • 54

    within the window where the operating system permits drawing. The operating system does not display any portion of a window that lies outside of the window region int SetWindowRgn( HWND hWnd, // handle to window whose window region is to be set HRGN hRgn, // handle to region BOOL bRedraw // window redraw flag ); Parameters hWnd Handle to the window whose window region is to be set. hRgn Handle to a region. The function sets the window region of the window to this region. If hRgn is NULL, the function sets the window region to NULL. bRedraw Boolean value that specifies whether the operating system redraws the window after setting the window region. If bRedraw is TRUE, the operating system does so; otherwise, it does not. Typically, you set bRedraw to TRUE if the window is visible. Return Value If the function succeeds, the return value is non-zero. If the function fails, the return value is zero. Comments If the bRedraw parameter is TRUE, the system sends the WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED messages to the window. The coordinates of a window's window region are relative to the upper-left corner of the window, not the client area of the window. After a successful call to SetWindowRgn, the operating system owns the region specified by the region handle hRgn. The operating system does not make a copy of the region. Thus, you should not make any further function calls with this region handle. In particular, do not close this region handle. To obtain the window region of a window, call the GetWindowRgn function. ---- End of help Sometimes it is cool to make some research by our own, Bye, Felipe Rocha Machado GPS Tecnologia Ltda.

  • 55

    Ag ortamindayken, ayni aga giris yapmaya yetkili kullanicilarin (bilgisayarlarin), isimlerini bulup getiren bir bilesene ait unit asagidadir. Kullanilabilmesi icin, sisteme bilesen olarak tanimlanmasi gereklidir. Bunun icin, Components | Install components mens kullanilir. unit NetUsers; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs; type TNetUsers = class(TComponent) private { Private declarations } fServer : string; protected { Protected declarations } procedure SetServer(Server : string); public { Public declarations } UserList: TStringList; constructor Create(Owner:TComponent); override; destructor Destroy; override; function Execute : Boolean; published { Published declarations } property Server :string read fServer write SetServer; end; PnetResourceArr = ^TNetResource; procedure register; implementation procedure TNetUsers.SetServer(Server : string); begin if fServer Server then fServer := Server; end; constructor TNetUsers.Create(Owner:TComponent); begin inherited Create(Owner); if not ( csDesigning in ComponentState ) then begin UserList := TStringList.Create; UserList.Sorted := True; end; end; destructor TNetUsers.Destroy; begin

  • 56

    if not( csDesigning in ComponentState ) then UserList.Destroy; inherited Destroy; end; function TNetUsers.Execute : Boolean; var NetResource: TNetResource; Buf:Pointer; Count, BufSize, Res: DWORD; i : Integer; lphEnum: THandle; p : PnetResourceArr; begin Execute := False; UserList.Clear; GetMem(Buf, 8192); try FillChar(NetResource, SizeOf(NetResource), 0); NetResource.lpRemoteName := PChar(fServer); NetResource.dwDisplayType := RESOURCEDISPLAYTYPE_SERVER; NetResource.dwUsage := RESOURCEUSAGE_CONTAINER; NetResource.dwScope := RESOURCETYPE_DISK; Res := WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_DISK, RESOURCEUSAGE_CONTAINER, @NetResource,lphEnum); if Res 0 then Exit; while true do begin Count := -1; BufSize := 8192; Res := WNetEnumResource(lphEnum, Count, Pointer(Buf), BufSize); if Res = ERROR_NO_MORE_ITEMS then Exit; if (Res 0) then Exit; p := PNetResourceArr(Buf); for i := 0 to Count - 1 do begin { Agdaki kullanici isimlerini Userlist listesine ekle} UserList.Add(p^.lpRemoteName + 2); Inc(p); end; end; Res := WNetCloseEnum(lphEnum); if Res 0 then raise Exception(Res); finally FreeMem(Buf); Execute := True; end; end; procedure register; begin RegisterComponents('Sil', [TNetUsers]); end; end.

  • 57

    //kullanimi { procedure TForm1.Button1Click(Sender: TObject); begin NETUSERS1.EXECUTE; listbox1.items.assign(netusers1.userlist) end;}

  • 58

    Masast grntsnn yakalanip, form zerine aktarilmasi; procedure Tform1.GrabScreen; var DeskTopDC: HDc; DeskTopCanvas: TCanvas; DeskTopRect: TRect; begin DeskTopDC := GetWindowDC(GetDeskTopWindow); DeskTopCanvas := TCanvas.Create; DeskTopCanvas.Handle := DeskTopDC; DeskTopRect := Rect(0,0,Screen.Width,Screen.Height); Canvas.CopyRect(DeskTopRect,DeskTopCanvas,DeskTopRect); ReleaseDC(GetDeskTopWindow,DeskTopDC); end; veya; var width, height : word; desktop : HDC; begin width := Screen.Width; height := Screen.Height; desktop := GetWindowDC(GetDesktopWindow); Image1.Picture.Bitmap.Width := width; Image1.Picture.Bitmap.Height := height; BitBlt( Image1.Picture.Bitmap.Canvas.Handle, 0, 0, width, height, desktop, 0, 0, SRCCOPY ); end;

  • 59

    Yildiz (*****) Sifrelerinin Gsterilmesi Kapat

    //**********************************************************// //** Copyright 2001 *// //** Bu Programin Tm Haklari Kemal GLOL'a Aittir ... *// //** Programcinin izni olmaksizin bu programin icerigi *// //** degistirilemez ve kullanilamaz ... *// //** *// //** e-mail : [email protected] *// //** Tel : 0312 2807980 cep Tel : 0535 666 6762 Turkey *// //**********************************************************// unit AsterixUnt; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Buttons; var HSonrakiWinMsg : HWND; type TAsterix = class(TForm) OrnekEdit: TEdit; Zamanlayici: TTimer; ShowPanel: TPanel; Ornek: TLabel; BitBtn1: TBitBtn; Bilgi: TLabel; BilgiLabel: TLabel; ShowTime: TTimer; Reklam: TBitBtn; Ticari: TLabel; procedure ZamanlayiciTimer(Sender: TObject); procedure ShowTimeTimer(Sender: TObject); procedure ReklamClick(Sender: TObject); private { Private declarations } public procedure AsterixSifreleriniCoz(); end; var Asterix: TAsterix; implementation uses Reklam; {$R *.DFM} procedure TAsterix.AsterixSifreleriniCoz(); var

  • 60

    HFare : HWND; // Mouse isaretleyici isaretleyici : TPOINT; // isaretleyici SifreUzunlugu : integer; // Sifre Uzunlugu Sifre : string; // Sifre begin GetCursorPos(isaretleyici); HFare := WindowFromPoint(isaretleyici); if HFare = HSonrakiWinMsg then Exit; HSonrakiWinMsg := HFare; if SendMessage(HSonrakiWinMsg, EM_GETPASSWORDCHAR, 0, 0) = 0 then Exit; SifreUzunlugu := SendMessage(HFare, WM_GETTEXTLENGTH, 0, 0) + 1; SetLength(Sifre, SifreUzunlugu); SendMessage(HSonrakiWinMsg, WM_GETTEXT, SifreUzunlugu,LongInt(@Sifre[1])); ShowPanel.Caption:='Sifre Uzunlugu = '+IntToStr(SifreUzunlugu-1) +' Buluna Sifre = '+PChar(Sifre); end; procedure TAsterix.ZamanlayiciTimer(Sender: TObject); begin AsterixSifreleriniCoz; end; procedure TAsterix.ShowTimeTimer(Sender: TObject); begin if not (ShowPanel.Caption='') then begin if ShowPanel.Font.Color=ClBlack then ShowPanel.Font.Color:=ClRed else ShowPanel.Font.Color:=ClBlack; end; end; end. // Programlar Blmnde Tm Kod ve exe Dahildir.

  • 61

    Windows icon ve bitmap'lerini program icinden almak Kapat

    { Cesitli icon sabitleri: (Daha fazlasi icin Windows unit'ine bakin) - IDI_APPLICATION - IDI_ASTERISK - IDI_EXCLAMATION - IDI_HAND - IDI_QUESTION } //Icons procedure TForm1.Button1Click(Sender: TObject); begin Image1.Picture.Icon.Handle:=LoadIcon(0,IDI_HAND); end; { Bitmap sabitleri: (Daha fazlasi icin Windows unit'ine bakin) - OBM_BTNCORNERS - OBM_BTSIZE - OBM_CHECK - OBM_CHECKBOXES - OBM_CLOSE - OBM_COMBO - OBM_DNARROW - OBM_DNARROWD - OBM_DNARROWI - OBM_LFARROW - OBM_LFARROWD - OBM_LFARROWI - OBM_MNARROW - OBM_REDUCE - OBM_RESTORE - OBM_REDUCED - OBM_SIZE - OBM_UPARROW - OBM_ZOOM } //Bitmap: procedure TForm1.Button2Click(Sender: TObject); begin image1.picture.bitmap.Handle:=LoadBitmap(0,makeintresource(OBM_RESTORE)); end;

    Gnderen: webmaster

  • 62

    Exe dosyasina her hangibir dosya (Txt, mid vb) nasil gomulur ? Kapat

    { Projenize resource eklemek icin Sirayla takip ediniz. Delphi 4.0 icin: 1. Project|Resources komutu veriniz. 2. Gelen pencerede sag tiklayip New|User Data 3. Resource tipini yaziniz. Ornek: EXE (RcData gelecektir) 3. Hangi dosyayi eklemek istiyorsaniz seciniz 4. Exe_1 olarak Exe tipinde eklenecektir. EXE_1 in zerinde sag tiklayip Rename dedikten sonra EXE_1'i herhangi bir tamsayi ile adini degistirin. r: 1 (EXE_1 -> 1) } procedure SaveRessourceToFile(const FileName, ResType: string; ResId: Integer); var MStream: TResourceStream; begin Mstream := TResourceStream.CreateFromID(HInstance, ResId, PChar(ResType)); try Mstream.SaveToFile(FileName); finally Mstream.Free; end; end; // Kullanimi: (Yukardaki islemden sonra SaveRessourceToFile('c:\deneme.exe', 'EXE', 1);

  • 63

    Istenilen font'u programinizda windows'a install etmeden kullanmak Kapat

    { Programinizla beraber kullandiginiz font dosyasini kuracaginiz bilgisayara kopyalamaniz gereklidir. (C:\programim\fuente.ttf gibi) } procedure TForm1.FormCreate(Sender: TObject); begin AddFontResource('c:\programim\FUENTE.TTF'); SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0); end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin RemoveFontResource('c:\programim\FUENTE.TTF'); SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0); end;

  • 64

    Harici bir ortamdan basilan tusu anlamak Keyboard Hook Kapat{*************************************************************} { TKeySpy Component for Delphi 16/32 } { Version: 2.8 } { E-Mail: [email protected] } { Home page: www.utilmind.com } { Created: August, 16, 1998 } { Modified: June, 6, 2000 } { Legal: Copyright (c) 1998-2000, UtilMind Solutions } {*************************************************************} { KEYBOARD SPY: } { This component is intended for interception of pressing the } { keyboard. The KeySpy is possible to apply for interception } { of the typed text of the another's programs, as keyboard } { spy, or for processing events at type certain keywords etc..} {*************************************************************} { Properties: ************************************************} { Enabled: as it usual... } { Keyword: At a set of this word event will be } { carried out (See OnKeyword event). } { ActiveLayout: Active keyboard layout (string) Win32 only } { SpyLayout: now present English, Russian, German } { & Italian } {ActiveWindowTitle: Title of active window (Read only) } { Events: ************************************************} { OnKeySpyDown: as OnKeyDown, but in any place (window). } { OnKeySpyUp: as OnKeyUp, but in any place (window). } { OnKeyword: The Keyword has been typed (See Keyword). } { OnLayoutChanged: The Keyboard layout was changed. Win32 only} { OnActiveWindowChanged: } {*************************************************************} { IMPORTANT NOTE: } { This code may be used and modified by anyone so long as } { this header and copyright information remains intact. By } { using this code you agree to indemnify UtilMind Solutions } { from any liability that might arise from its use. You must } { obtain written consent before selling or redistributing } { this code. } {*************************************************************} { Changes: } { 20.I.1999: Added 32-bit support } { 14.V.1999: Added OnChangeLayout event. } { Added Italian and Russian keyboard layouts. } { 28.V.1999: Added ActiveWindowTitle property. } { 27.VII.1999: Added Portugese keyboard layout. } { Thanks to Tiago Correia ([email protected])} { 19.IX.1999: Added German keyboard layout (added by Slaine, } { [email protected]) } { 5.V.2000: Added French keyboard layout (added by Vincent } { CALLIES, [email protected]) } {*************************************************************} unit KeySpy; interface

  • 65

    uses {$IFDEF WIN32} Windows, {$ELSE} WinTypes, WinProcs,{$ENDIF} SysUtils, Controls, Classes, Messages, Forms; type TSpyLayout = (klAmerican, klItalian, klRussian, klPortuguese, klGerman, klFrench); TOnKeySpy = procedure(Sender: Tobject; Key: Byte; KeyStr: string) of object; {$IFDEF Win32} TOnLayoutChanged = procedure(Sender: TObject; Layout: string) of object; {$ENDIF} TOnActiveWindowChanged = procedure(Sender: TObject; ActiveTitle: string) of object; TKeySpy = class(TComponent) private {$IFDEF Win32} CurrentLayout: string; FActiveLayout: string; {$ENDIF} CurrentActiveWindowTitle: string; FActiveWindowTitle: string; FSpyLayout: TSpyLayout; FWindowHandle: HWnd; FOnKeySpyDown, FOnKeySpyUp: TOnKeySpy; FOnKeyword: TNotifyEvent; {$IFDEF Win32} FOnLayoutChanged: TOnLayoutChanged; {$ENDIF} FOnActiveWindowChanged: TOnActiveWindowChanged; FEnabled: Boolean; FKeyword, KeyComp: string; OldKey: Byte; LShiftUp, RShiftUp: Boolean; procedure UpdateTimer; procedure SetEnabled(Value: Boolean); procedure SetKeyword(Value: string); procedure WndProc(var Msg: TMessage); procedure SetNothingStr(Value: string); protected procedure KeySpy; dynamic; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; published property ActiveWindowTitle: string read FActiveWindowTitle write SetNothingStr; property Enabled: Boolean read FEnabled write SetEnabled; property Keyword: string read FKeyword write SetKeyword; property SpyLayout: TSpyLayout read FSpyLayout write FSpyLayout; {$IFDEF Win32} property ActiveLayout: string read FActiveLayout write FActiveLayout; {$ENDIF} property OnKeySpyDown: TOnKeySpy read FOnKeySpyDown write FOnKeySpyDown; property OnKeySpyUp: TOnKeySpy read FOnKeySpyUp write FOnKeySpyUp; property OnKeyword: TNotifyEvent read FOnKeyword write FOnKeyword;

  • 66

    {$IFDEF Win32} property OnLayoutChanged: TOnLayoutChanged read FOnLayoutChanged write FOnLayoutChanged; {$ENDIF} property OnActiveTitleChanged: TonActiveWindowChanged read FOnActiveWindowChanged write FOnActiveWindowChanged; end; procedure register; implementation {$I KLayouts.inc} constructor TKeySpy.Create(AOwner: Tcomponent); begin inherited Create(AOwner); LShiftUp := True; RShiftUp := True; FEnabled := True; FWindowHandle := AllocateHWnd(WndProc); if FEnabled then UpdateTimer; end; destructor TKeySpy.Destroy; begin FEnabled := False; UpdateTimer; DeallocateHWnd(FWindowHandle); inherited Destroy; end; procedure TKeySpy.WndProc(var Msg: TMessage); begin with Msg do if Msg = WM_TIMER then try KeySpy; except Application.HandleException(Self); end else Result := DefWindowProc(FwindowHandle, Msg, wParam, lParam); end; procedure TKeySpy.UpdateTimer; var b: Byte; begin KillTimer(FWindowHandle, 1); if FEnabled then begin asm mov al, 60h mov b, al

  • 67

    end; OldKey := b; if SetTimer(FWindowHandle, 1, 1, nil) = 0 then raise EOutOfResources.Create('No timers'); end; end; procedure TKeySpy.SetEnabled(Value: Boolean); begin if Value FEnabled then begin FEnabled := Value; UpdateTimer; end; end; procedure TKeySpy.SetKeyword(Value: string); begin Value := LowerCase(Value); if Value FKeyword then FKeyword := Value; end; procedure TKeySpy.KeySpy; var PC: array[0..$FFF] of Char; Key: Byte; St: string; Wnd: hWnd; begin {$IFDEF Win32} Wnd := GetForegroundWindow; {$ELSE} Wnd := GetActiveWindow; {$ENDIF} SendMessage(Wnd, wm_GetText, $FFF, LongInt(@PC)); FActiveWindowTitle := StrPas(PC); if CurrentActiveWindowTitle FActiveWindowTitle then begin CurrentActiveWindowTitle := FActiveWindowTitle; if Assigned(FOnActiveWindowChanged) then FOnActiveWindowChanged(Self, FactiveWindowTitle); end; {$IFDEF Win32} GetKeyboardLayoutName(PC); FActiveLayout := StrPas(PC); if (FActiveLayout CurrentLayout) then begin CurrentLayout := FActiveLayout; if Assigned(FOnLayoutChanged) then FOnLayoutChanged(Self, FActiveLayout); end; {$ENDIF}

  • 68

    asm in al, 60h mov Key, al end; if Key = 170 then begin Key := 84; LShiftUp := True; end; if Key = 182 then begin Key := 85; RShiftUp := True; end; if Key = 42 then LShiftUp := False; if Key = 54 then RShiftUp := False; if Key OldKey then begin OldKey := Key; if Key Length(FKeyword) then begin

  • 69

    Move(KeyComp[Length(St) + 1], KeyComp[1], Length(KeyComp)); {$IFDEF WIN32} SetLength(KeyComp, Length(FKeyword)); {$ELSE} KeyComp[0] := char(Length(FKeyword)); {$ENDIF} end; if LowerCase(KeyComp) = FKeyword then FOnKeyword(Self); end; end else if Key - 128

  • 70

    Calisma Esnasinda Program Icerisinden Bilesen Yaratma... Kapatvar Label1: TLabel ; ComboBox1:TComboBox; SpinEdit1:TSpinEdit; DateTimePicker1:TDateTimePicker; implementation {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); begin //Label1 Bileseni Olusturuldu Label1 := TLabel.Create(self) ; with Label1 do begin Parent:=Self; Left := 5; Top := 70; Width := 70; Height := 13; Alignment := taRightJustify; AutoSize := False; Caption := 'Listeler:'; end; //ComboBox1 Bileseni Olusturuldu ComboBox1:=TComboBox.Create(self); with ComboBox1 do begin Parent:=Self; Left := 85; Top := 65; Width := 145; Height := 21; ItemHeight := 13; TabOrder := 3; Text := 'Liste1'; Items.Clear; Items.Add('Liste1'); Items.Add('Liste2'); Items.Add('Liste3');; end; //DateTimePicker1 Bileseni Olusturuldu DateTimePicker1:=TDateTimePicker.Create(self); with DateTimePicker1 do begin Parent:=Self; Left := 85; Top := 90; Width := 146; Height := 21; CalAlignment := dtaLeft; Date := 36964.028340625; Time := 36964.028340625; DateFormat := dfShort; DateMode := dmComboBox; Kind := dtkDate; ParseInput := False; TabOrder := 4; end;

  • 71

    end; end;

  • 72

    Bir DOS komutunun kullanilmasi Kapat

    Windows 95 ortamindayken, bir DOS komutunun calistirilmasi icin gereken yordam sudur. procedure doskomutu(komut:string;mesajver:boolean); var Startupinfo:TStartupinfo; ProcessInfo:TProcessInformation; begin if terminateprocess(processinfo.hProcess,0)=NULL then begin if mesajver then showmessage('Devam eden islem iptal edilemedi'); exit; end; FillChar(StartupInfo,Sizeof(StartupInfo),#0); StartupInfo.cb := Sizeof(StartupInfo); StartupInfo.wShowWindow := SW_HIDE; StartupInfo.dwFlags:=STARTF_USESHOWWINDOW; if not CreateProcess(nil, Pchar('c:\command.com /c '+komut), nil, nil, true, NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo) then begin if mesajver then ShowMessage('Islem gerceklestirilemedi') end else begin if mesajver then ShowMessage('Islem tamam') end; end; Bu yordamin kullanimi; procedure TForm1.Button1Click(Sender: TObject); begin doskomutu('copy c:\autoexec.bat a:\autoexec.dat', false); end;

  • 73

    Cep Telefonlari icin Genel AT Komutlari Kapat

    Cep Telefonuna Gnderilen AT Komutlari AT+CBC // Batarya Durumu AT+CGMI // retici Firma AT+CGMM // Telefonun Modeli AT+CGSN // Telefonun Seri numarasi AT+CPBF // Rehberden Buldurma AT+CPBR // Tm Adres Defterinin okutulmasi AT+CPBS // SIM yada Telefonun hafizasinin secilmesi ATD0535XXXXXXX; // Telefon numarasi cevirme AT*EKEB="123456" // TUSLAMA AT*EICO=X,Y // X:ICON Y:ON(1)-OFF(0) Mesaj veya diger iconlari degistirme AT*ESOM=1,"aAffFgaAgfEpgGefgeafDC" // Melodi Yazdirma AT*ETXT=1,"SELAM" // KARSILAMA MESAJI AT+COPS? // OPERATORU BELIRTIYOR TURKCELL VEYA TELSIM MI ? AT+CKPD="C",20 // EKRANI TEMIZLE AT+CKPD="",20 // SAG MENUYE GEC AT*EMMI=1,1,1 //!! oRTADAKI KLAVYE ENABLE 1 DISABLE 0 ENSONDAKI EKRAN ISIGI 1-0 AT+CPBW // Rehbere Telefon numarasi Ekleme AT+CSQ // Telefonun Sinyal degerinin lclmesi AT+CSMS // Mesaj Servisini Belirle AT+CMGF // Mesajin Formatini belirle AT+CSCA // Mesaj Merkezi AT+CSMP // Text modu telefonun AT+CSDH // Text Modun paremetrelerini gster AT+CSCB // Telefondaki Mesaj Ayarini sec AT+CSAS // Ayarlari Kaydet AT+CRES // Ayarlari dzenle AT+CNMI // TE de yeni mesaj indikatr ac AT+CMGL // Mesajlari Listele AT+CMGR // Mesaj Oku AT+CMGS // Mesaj Gnder AT+CMSS // Hafizadaki Mesaji Gnder AT+CMGW // Hafizaya Mesaj Yaz AT+CMGD // Mesaj Sil AT+CMGL // Mesajlari Listele AT+CMGR // Mesajlari Oku AT+CMGS // Mesaj Gnder AT+CMGW // Hafizaya Mesaj Yaz not : Mesajlari her islemden Sonra konulacak Win98 isletim sistemlerinda DADCom98 cekilmesi gerkiyor Mesajlariniz icin [email protected] adresine bildiriniz iyi calismalar ...

  • 74

    Bir resmin seffaf olarak baska bir resim zerine yapistirilmasi Kapat

    Unit1.pas unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Image1: TImage; ColorDialog1: TColorDialog; Panel1: TPanel; Button2: TButton; Image2: TImage; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } procedure DrawTransparent(t: TCanvas; x,y: Integer; s: TBitmap; TrCol: TColor); end; var Form1: TForm1; bmp:tbitmap; clr:tcolor; implementation {$R *.DFM} procedure tform1.DrawTransparent(t: TCanvas; x,y: Integer; s: TBitmap; TrCol: TColor); var bmpXOR, bmpAND, bmpINVAND, bmpTarget: TBitmap; oldcol: Longint; begin try bmpAND := TBitmap.Create; bmpAND.Width := s.Width; bmpAND.Height := s.Height; bmpAND.Monochrome := True; oldcol := SetBkColor(s.Canvas.Handle, ColorToRGB(TrCol)); BitBlt(bmpAND.Canvas.Handle, 0,0,s.Width,s.Height, s.Canvas.Handle, 0,0, SRCCOPY);

  • 75

    SetBkColor(s.Canvas.Handle, oldcol); bmpINVAND := TBitmap.Create; bmpINVAND.Width := s.Width; bmpINVAND.Height := s.Height; bmpINVAND.Monochrome := True; BitBlt(bmpINVAND.Canvas.Handle, 0,0,s.Width,s.Height, bmpAND.Canvas.Handle, 0,0, NOTSRCCOPY); bmpXOR := TBitmap.Create; bmpXOR.Width := s.Width; bmpXOR.Height := s.Height; BitBlt(bmpXOR.Canvas.Handle, 0,0,s.Width,s.Height, s.Canvas.Handle, 0,0, SRCCOPY); BitBlt(bmpXOR.Canvas.Handle, 0,0,s.Width,s.Height, bmpINVAND.Canvas.Handle, 0,0, SRCAND); bmpTarget := TBitmap.Create; bmpTarget.Width := s.Width; bmpTarget.Height := s.Height; BitBlt(bmpTarget.Canvas.Handle, 0,0,s.Width,s.Height, t.Handle, x,y, SRCCOPY); BitBlt(bmpTarget.Canvas.Handle, 0,0,s.Width,s.Height, bmpAND.Canvas.Handle, 0,0, SRCAND); BitBlt(bmpTarget.Canvas.Handle, 0,0,s.Width,s.Height, bmpXOR.Canvas.Handle, 0,0, SRCINVERT); BitBlt(t.Handle, x,y,s.Width,s.Height, bmpTarget.Canvas.Handle, 0,0, SRCCOPY); finally bmpXOR.Free; bmpAND.Free; bmpINVAND.Free; bmpTarget.Free; end;{End of TRY section} end; procedure TForm1.Button1Click(Sender: TObject); begin DrawTransparent(image1.Canvas, 1,1, bmp, clr); image1.Invalidate; image1.repaint; end; procedure TForm1.FormCreate(Sender: TObject); begin bmp:=tbitmap.create; bmp.width:=image1.width; bmp.height:=image1.height; bmp.assign(image2.picture); // clr:=tcolor.create;; clr:=clgreen; panel1.color:=clr; end; procedure TForm1.FormDestroy(Sender: TObject); begin bmp.free;

  • 76

    end; procedure TForm1.Button2Click(Sender: TObject); begin if colordialog1.execute then clr:=colordialog1.Color; panel1.color:=clr; end; end. Unit1.dfm object Form1: TForm1 Left = 200 Top = 108 Width = 617 Height = 302 Caption = 'Form1' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OnCreate = FormCreate OnDestroy = FormDestroy PixelsPerInch = 96 TextHeight = 13 object Image1: TImage Left = 264 Top = 8 Width = 329 Height = 201 Stretch = True end object Image2: TImage Left = 8 Top = 8 Width = 249 Height = 201 Stretch = True end object Button1: TButton Left = 144 Top = 224 Width = 75 Height = 25 Caption = 'Button1' TabOrder = 0 OnClick = Button1Click end object Panel1: TPanel Left = 304 Top = 216 Width = 113 Height = 41 Caption = 'Panel1'

  • 77

    TabOrder = 1 object Button2: TButton Left = 22 Top = 8 Width = 75 Height = 25 Caption = 'Button2' TabOrder = 0 OnClick = Button2Click end end object ColorDialog1: TColorDialog Ctl3D = True Left = 112 Top = 352 end end

  • 78

    { "My application is minimized in the Tray and I want to know how can a short-cut key, for example Alt-Shift-F9, bring my application on the front of the screen?" } //In the main forms //OnClose event remove the handler: UnRegisterHotkey( Handle, 1 ); //Add a handler for the //WM_HOTKEY message to the form: private // form declaration Procedure WMHotkey( Var msg: TWMHotkey ); message WM_HOTKEY; Procedure TForm1.WMHotkey( Var msg: TWMHotkey ); Begin If msg.hotkey = 1 Then Begin If IsIconic( Application.Handle ) Then Application.Restore; BringToFront; End; End;

  • 79

    { Here's a function that will check if a given string exist in a string list. You can use it when you want to add only the unique strings to any object with a string list property such as list boxes, memos, etc. } function StrIsInList( sl : TStrings; s : string; bCaseSensitive : boolean ) : boolean; var n : integer; begin Result := False; if (not bCaseSensitive) then s := LowerCase(s); for n := 0 to (sl.Count - 1) do begin if((bCaseSensitive and (s = LowerCase( sl.Strings[n]))) or (s = sl.Strings[n])) then begin Result := True; Exit; end; end; end; { Usage: } procedure TForm1.Button1Click(Sender: TObject); begin if (not StrIsInList(ListBox1.Items, Edit1.Text, False)) then ListBox1.Items.Add(Edit1.Text); end;

  • 80

    Here's a little unit placing an application as an icon in the Tray to the left of the clock in the task bar. The program also remover itself from the taskbar and doesn't appear there even when the main form is visible. unit Unit1; interface uses SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, ShellAPI, Menus; const WM_MINIMALIZE = WM_USER + 1; // our own message type TForm1 = class(TForm) PopupMenu1: TPopupMenu; Show1: TMenuItem; Hide1: TMenuItem; Quit1: TMenuItem; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure Show1Click(Sender: TObject); procedure Hide1Click(Sender: TObject); procedure Quit1Click(Sender: TObject); private FIconData : TNotifyIconData; public // a proceudre reacting to our own message: procedure WMMinimalize(var Message : TMessage); message WM_MINIMALIZE; end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.FormCreate(Sender: TObject); var i : Integer; begin with FIconData do begin cbSize := SizeOf(FIconData); Wnd := Self.Handle; uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP; hIcon := Application.Icon.Handle; uCallbackMessage := WM_MINIMALIZE; // ties our message to the icon szTip := 'My own application'; // "tip" end; Shell_NotifyIcon(NIM_ADD, @FIconData); end; procedure TForm1.FormDestroy(Sender: TObject); begin

  • 81

    Shell_NotifyIcon(NIM_DELETE, @FIconData); end; procedure TForm1.WMMinimalize(var Message : TMessage); var p : TPoint; begin case Message.LParam of WM_RBUTTONUP: begin GetCursorPos(p); PopupMenu1.Popup(p.x, p.y); end; // here, you can react to other standard // messages, for example WM_LBUTTONDBLCLK end; end; procedure TForm1.Show1Click(Sender: TObject); begin Form1.Visible := TRUE; // this takes the program away from the Task Bar: ShowWindow(Application.Handle, SW_HIDE); end; procedure TForm1.Hide1Click(Sender: TObject); begin Self.Visible := FALSE; end; procedure TForm1.Quit1Click(Sender: TObject); begin Application.Terminate; end; end. And one more thing. To make the form desapear directly after start, add the following to your *.dpr file: Application.ShowMainForm := FALSE;

  • 82

    { One of those things that Delphi does not have is a sleep function, where a program will wait a number of seconds before proceding on to its next task. In the meantime, it will allow Windows background operations to process. The Turbo Pascal equivalent to this is delay, but unfortunately, I haven't been able to find any documentation on it, so I don't know if it is still available. It should be, but to be safe, I came up with a new function, called Sleep. The procedure makes use of a Windows API function called GetTickCount, which returns the number of milliseconds that have elapsed since Windows has started. The WinAPI documentation states that after 49 days of continuous use, the tick count recycles back to zero, so if your machine runs on a continuous basis with Windows, you may consider this. } procedure GoSleep(SleepSecs : Integer); var StartValue : LongInt; begin StartValue := GetTickCount; While ((GetTickCount - StartValue)

  • 83

    var MemoryStatus: TMemoryStatus; begin Memo1.Lines.Clear; MemoryStatus.dwLength := SizeOf(MemoryStatus); GlobalMemoryStatus(MemoryStatus); with MemoryStatus do begin Memo1.Lines.Add(IntToStr(dwLength) + ' Size of ''MemoryStatus'' record'); Memo1.Lines.Add(IntToStr(dwMemoryLoad) + '% memory in use'); Memo1.Lines.Add(IntToStr(dwTotalPhys) + ' Total Physical Memory in bytes'); Memo1.Lines.Add(IntToStr(dwAvailPhys) + ' Available Physical Memory in bytes'); Memo1.Lines.Add(IntToStr(dwTotalPageFile) + ' Total Bytes of Paging File'); Memo1.Lines.Add(IntToStr(dwAvailPageFile) + ' Available bytes in paging file'); Memo1.Lines.Add(IntToStr(dwTotalVirtual) + ' User Bytes of Address space'); Memo1.Lines.Add(IntToStr(dwAvailVirtual) + ' Available User bytes of address space'); end; end; 19/2001. Get Cursor Image (draw in on a Canvas) { The DrawCursor procedure draws a current cursor image on ACanvas at the Position point. } procedure DrawCursor (ACanvas:TCanvas; Position:TPoint); var HCursor : THandle; begin HCursor := Screen.Cursors [Ord(Screen.Cursor)]; DrawIconEx(ACanvas.Handle, Position.X, Position.Y, HCursor, 32, 32, 0, 0, DI_NORMAL); end; { Usage (top-left on a form1): DrawCursor(form1.Canvas,Point(0,0)); } 18/2001. Activate/Deactivate the Screen Saver { Sometimes you want to deactivate the current screensaver when performing some very long process. You can use this function to activate or deactivate the screensaver. Pass True to activate it, or False to deactivate it. } function ActivateScreenSaver (Activate: boolean): boolean; var IntActive: byte; begin if Activate then IntActive := 1 else IntActive := 0; Result := SystemParametersInfo

  • 84

    (SPI_SETSCREENSAVEACTIVE, IntActive, nil, 0); end; 17/2001. List All Network Drives { To show a list of all mapped network drives, use the GetNetworkDriveMappings() function. Example usage: GetNetworkDriveMappings(Memo1.Lines); } function GetNetworkDriveMappings (SList: TStrings): integer; var i: Char; ThePath: string; MaxNetPathLen: DWord; begin SList.Clear; MaxNetPathLen := MAX_PATH; SetLength(ThePath, MAX_PATH); for i := 'A' to 'Z' do if WNetGetConnection(PChar('' + i + ':'), PChar(ThePath), MaxNetPathLen) = NO_ERROR then SList.Add(i + ': ' + ThePath); Result := SList.Count; end; 16/2001. Get IE favorites { The GetIEFavourites function called from the OnClick event of a button returns a list of all the favorites from your Internet Explorer in a ListBox. } function GetIEFavourites (const favpath: string):TStrings; var searchrec:TSearchrec; str:TStrings; path,dir,filename:String; Buffer: array[0..2047] of Char; found:Integer; begin str:=TStringList.Create; try path:=FavPath+'\*.url'; dir:=ExtractFilepath(path); found:=FindFirst(path,faAnyFile,searchrec); while found=0 do begin SetString(filename, Buffer, GetPrivateProfileString('InternetShortcut', PChar('URL'), NIL, Buffer, SizeOf(Buffer), PChar(dir+searchrec.Name))); str.Add(filename); found:=FindNext(searchrec); end; found:=FindFirst(dir+'\*.*',faAnyFile,searchrec); while found=0 do begin if ((searchrec.Attr and faDirectory) > 0) and (searchrec.Name[1]'.') then str.AddStrings(GetIEFavourites

  • 85

    (dir+'\'+searchrec.name)); found:=FindNext(searchrec); end; FindClose(searchrec); finally Result:=str; end; end; procedure TForm1.Button1Click(Sender: TObject); var pidl: PItemIDList; FavPath: array[0..MAX_PATH] of char; begin SHGetSpecialFolderLocation(Handle, CSIDL_FAVORITES, pidl); SHGetPathFromIDList(pidl, favpath); ListBox1.Items:=GetIEFavourites(StrPas(FavPath)); end; 15/2001. Change glyphs of TBDNavigator Buttons { Form1 has DBNavigator1. In the OnCreate event for the form the custom bitmap ('GoFirst') for the First button is loaded from the resource. } procedure TForm1.FormCreate(Sender: TObject); var i : Integer; tempGlyph : tBitmap; begin tempGlyph :=TBitmap.Create; try tempGlyph.LoadFromResourceName (HInstance,'GoFirst'); with DBNavigator1 do begin for i := 0 to ControlCount - 1 do if Controls[c] is TNavigateBtn then with TNavigateBtn(Controls[c]) do begin case Index of nbFirst: Glyph := tempGlyph; end; end; end; finally tempGlyph.Free; end; end; 14/2001. Height/Width of a Character { When using OwnerDrawing or Printing it is good to know the (max) Height and Width of character for a given Canvas - in pixels. The SomeComponents represents a component with a Canvas (the one derived from TWinControl) } SomeSomponent.Canvas.TextWidth('H'); SomeSomponent.Canvas.TextHeight('I'); 13/2001. Paint the Form with a Tiled Bitmap type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure FormPaint(Sender: TObject); procedure FormClose(Sender: TObject;

  • 86

    var Action: TCloseAction); private public end; var Form1: TForm1; Bitmap: TBitmap; ... procedure TForm1.FormCreate(Sender: TObject); begin Bitmap := TBitmap.Create; Bitmap.LoadFromFile('C:\WINDOWS\cars.BMP'); end; procedure TForm1.FormClose (Sender: TObject; var Action: TCloseAction); begin Bitmap.Free; end; procedure TForm1.FormPaint(Sender: TObject); var X, Y, W, H: LongInt; begin with Bitmap do begin W := Width; H := Height; end; Y := 0; while Y < Height do begin X := 0; while X < Width do begin Canvas.Draw(X, Y, Bitmap); Inc(X, W); end; Inc(Y, H); end; end; 12/2001. Convert a BMP to a JPG { Usage: BMPtoJPG('mybitmap.bmp','myjpeg.jpg') } function BMPtoJPG (var BMPpic, JPGpic: string):boolean; var Bitmap: TBitmap; JpegImg: TJpegImage; begin Result:=False; Bitmap := TBitmap.Create; try Bitmap.LoadFromFile(BMPpic); JpegImg := TJpegImage.Create; try JpegImg.Assign(Bitmap); JpegImg.SaveToFile(JPGpic); Result:=True; finally JpegImg.Free

  • 87

    end; finally Bitmap.Free end; end; 11/2001. Save Text From Clipboard to a File { Usage: ClipboardTxtToFile(c:\dir\cliptext.txt) } uses Clipbrd; function ClipboardTxtToFile (sFileTXT : string) : boolean; var ps1, ps2 : PChar; dwLen : DWord; tf : TextFile; hData : THandle; begin Result := False; with Clipboard do begin try Open; if(HasFormat(CF_TEXT)) then begin hData := GetClipboardData(CF_TEXT); ps1 := GlobalLock(hData); dwLen := GlobalSize(hData); ps2 := StrAlloc(1 + dwLen); StrLCopy( ps2, ps1, dwLen ); GlobalUnlock( hData ); AssignFile(tf, sFileTXT); ReWrite(tf); Write(tf, ps2); CloseFile(tf); StrDispose( ps2 ); Result := True; end; finally Close; end; end; end; 10/2001. TColor to Hex & Hex to TColor function TColorToHex(Color : TColor) : string; begin Result := IntToHex(GetRValue(Color), 2) + IntToHex(GetGValue(Color), 2) + IntToHex(GetBValue(Color), 2); end; function HexToTColor(sColor : string) : TColor; begin Result := RGB( StrToInt('$'+Copy(sColor, 1, 2)), StrToInt('$'+Copy(sColor, 3, 2)), StrToInt('$'+Copy(sColor, 5, 2)) ); end;

  • 88

    . 09/2001. Capture the Output From a DOS Window { The example runs 'chkdsk.exe c:\' and displays the output to Memo1 Put a TMemo (Memo1) and a TButton (Button1) in your form Put this code in the OnCLick of Button1: } procedure TForm1.Button1Click(Sender: TObject); procedure RunDosInMemo(DosApp:String;AMemo:TMemo); const ReadBuffer = 2400; var Security : TSecurityAttributes; ReadPipe,WritePipe : THandle; start : TStartUpInfo; ProcessInfo : TProcessInformation; Buffer : Pchar; BytesRead : DWord; Apprunning : DWord; begin With Security do begin nlength := SizeOf(TSecurityAttributes); binherithandle := true; lpsecuritydescriptor := nil; end; if Createpipe (ReadPipe, WritePipe, @Security, 0) then begin Buffer := AllocMem(ReadBuffer + 1); FillChar(Start,Sizeof(Start),#0); start.cb := SizeOf(start); start.hStdOutput := WritePipe; start.hStdInput := ReadPipe; start.dwFlags := STARTF_USESTDHANDLES + STARTF_USESHOWWINDOW; start.wShowWindow := SW_HIDE; if CreateProcess(nil, PChar(DosApp), @Security, @Security, true, NORMAL_PRIORITY_CLASS, nil, nil, start, ProcessInfo) then begin repeat Apprunning := WaitForSingleObject (ProcessInfo.hProcess,100); Application.ProcessMessages; until (Apprunning WAIT_TIMEOUT); Repeat BytesRead := 0; ReadFile(ReadPipe,Buffer[0], ReadBuffer,BytesRead,nil); Buffer[BytesRead]:= #0; OemToAnsi(Buffer,Buffer); AMemo.Text := AMemo.text + String(Buffer); until (BytesRead < ReadBuffer); end;

  • 89

    FreeMem(Buffer); CloseHandle(ProcessInfo.hProcess); CloseHandle(ProcessInfo.hThread); CloseHandle(ReadPipe); CloseHandle(WritePipe); end; end; begin {button 1 code} RunDosInMemo('chkdsk.exe c:\',Memo1); end; 04/2001. Exit From Windows //reboot windows ExitWindowsEx(EWX_REBOOT,0); //shut down windows ExitWindowsEx(EWX_SHUTDOWN,0); // log off and prompt for login ExitWindowsEx(EWX_LOGOFF,0); 08/2000. Copying Group of Files - Standard Animation Dialog. { The following example demonstrates using the SHFileOperation function to copy a group of files and display a progress dialog. You can also use the following flags to delete, move and rename a group of files. FO_COPY FO_DELETE FO_MOVE FO_RENAME Note: The buffer that contains the file names to copy must end with a double null terminating character The following example copies three files to 'e' drive. } uses ShellAPI; procedure TForm1.Button1Click(Sender: TObject); var Fos : TSHFileOpStruct; Buf : array[0..4096] of char; p : pchar; sDest : string; begin FillChar(Buf, sizeof(Buf), #0); p := @buf; p := StrECopy(p, 'C:\FirstFile.ext1') + 1; p := StrECopy(p, 'C:\SecondFile.ext2') + 1; StrECopy(p, 'C:\ThirdFile.ext3'); sDest := 'e:\'; FillChar(Fos, sizeof(Fos), #0); with Fos do begin Wnd := Handle; wFunc := FO_COPY; pFrom := @Buf; pTo := sDest; fFlags := 0; end; if ((SHFileOperation(Fos) 0) or

  • 90

    (Fos.fAnyOperationsAborted false)) then ShowMessage('Cancelled') end; 07/2001. Long ListBox entries as Hints { Sometimes the data you want to display in a list is too long for the size of ListBox you can use. When this happens, you can use the simple code to display the ListBox entries as Hints when the mouse passes over the ListBox. Just make sure that ShowHints is True. } procedure TForm1.ListBox1MouseMove (Sender: TObject; Shift: TShiftState; X, Y: Integer); var lstIndex : Integer ; begin with ListBox1 do begin lstIndex:=SendMessage(Handle, LB_ITEMFROMPOINT, 0, MakeLParam(x,y)); if (lstIndex >= 0) and (lstIndex

  • 91

    Top := 121; Left := 8; end; if (ShowModal = ID_YES) then begin if ACheckBox.Checked then begin //... do if checked end; //... do if NOT checked end; finally ACheckBox.Free; Free; end; end; . 05/2001. Get Memory Status { To retrieve the current memory status, use the GlobalMemoryStatus() function: } var Status : TMemoryStatus; begin Status.dwLength := sizeof( TMemoryStatus ); GlobalMemoryStatus( Status ); ... { The TMemoryStatus contains several fields indicating the status of the memory: .dwMemoryLoad: Total memory used in percentage (%). .dwTotalPhys: Total physical memory in bytes. .dwAvailPhys: Physical memory left in bytes. .dwTotalPageFile: Total page file in bytes. .dwAvailPageFile:Page file left in bytes. .dwTotalVirtual: Total virtual memory in bytes. .dwAvailVirtual: Virtual memory left in bytes. Before presenting the memory values, convert them into giga, mega or kilobytes. } 04/2001. Exit From Windows //reboot windows ExitWindowsEx(EWX_REBOOT,0); //shut down windows ExitWindowsEx(EWX_SHUTDOWN,0); // log off and prompt for login ExitWindowsEx(EWX_LOGOFF,0); 03/2000. Empty Recycle Bin {Put a Button on Form1 and replace Unit1 code with:} unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, ShellApi,Controls, Forms, Dialogs,StdCtrls, ExtCtrls; type TForm1 = class(TForm) Button1: TButto