home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 11
/
Freelog011.iso
/
BestOf
/
PhoenixMail
/
Source
/
phoenix
/
FMSearch.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1999-02-05
|
5KB
|
169 lines
{*****************************************************************************
*
* FMSearch.pas - Search Mails and Addresses (12-September-1998)
*
* Copyright (c) 1998-99 Michael Haller
*
* Author: Michael Haller
* E-mail: michael@discountdrive.com
* Homepage: http://www.discountdrive.com/sunrise
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
*----------------------------------------------------------------------------
*
* Revision history:
*
* DATE REV DESCRIPTION
* ----------- --- ----------------------------------------------------------
*
*****************************************************************************}
unit FMSearch;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, PXStuff, LangSup;
type
TSearchForm = class(TForm)
Animate1: TAnimate;
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
SearchIndex, Method: Integer;
end;
var
SearchForm: TSearchForm;
implementation
{$R *.DFM}
uses
Main, FMAddress;
procedure TSearchForm.Button1Click(Sender: TObject);
var
I, E, Y: Integer;
F: Boolean;
S: String;
P: TPoint;
Item: TListItem;
begin
Button1.Caption := Label4.Caption;
F := False;
if Method = 0 then begin//Mainform
if SaveMessage then MainForm.DoSaveMessage;
for I := 0 to MainForm.ListView1.Items.Count-1 do
MainForm.ListView1.Items[I].Selected := False;
MainForm.ListView1MouseUp(Self, mbLeft, [ssLeft], 0, 0);
for I := SearchIndex to MainForm.ListView1.Items.Count-1 do begin
S := '';
for E := 0 to 3 do S := S + MainForm.ListView1.Items[I].SubItems[E];
S := LowerCase(S);
if Pos(LowerCase(Edit1.Text), S) <> 0 then begin
MainForm.ListView1.Selected := MainForm.ListView1.Items[I];
MainForm.ListView1MouseUp(Self, mbLeft, [ssLeft], 0, 0);
SearchIndex := I+1;
F := True;
Item := MainForm.ListView1.GetItemAt(2, 20);
if Assigned(Item) then begin
P := MainForm.ListView1.Selected.GetPosition;
Y := P.Y;
P := Item.GetPosition;
MainForm.ListView1.Scroll(0, -(P.Y - Y));
end;
Break;
end;
end;
end;
if Method = 1 then begin //AddressForm
for I := 0 to AddressForm.ListView1.Items.Count-1 do
AddressForm.ListView1.Items[I].Selected := False;
AddressForm.SetMenusEnable;
AddressForm.SetStatusBar;
for I := SearchIndex to AddressForm.ListView1.Items.Count-1 do begin
S := AddressForm.ListView1.Items[I].SubItems[0]+AddressForm.ListView1.Items[I].SubItems[1]+
AddressForm.ListView1.Items[I].SubItems[2]+AddressForm.ListView1.Items[I].SubItems[3]+
AddressForm.ListView1.Items[I].SubItems[4];
S := LowerCase(S);
if Pos(LowerCase(Edit1.Text), S) <> 0 then begin
AddressForm.ListView1.Selected := AddressForm.ListView1.Items[I];
AddressForm.SetMenusEnable;
AddressForm.SetStatusBar;
SearchIndex := I+1;
F := True;
Item := AddressForm.ListView1.GetItemAt(2, 20);
if Assigned(Item) then begin
P := AddressForm.ListView1.Selected.GetPosition;
Y := P.Y;
P := Item.GetPosition;
AddressForm.ListView1.Scroll(0, -(P.Y - Y));
end;
Break;
end;
end;
end;
if F = False then
MessageDlg(Format(Mainform.ListBox1.Items[75]+' ', [Edit1.Text]), mtInformation, [mbOK], 0);
end;
procedure TSearchForm.FormCreate(Sender: TObject);
begin
AttachLanguageToForm(Self);
SearchIndex := 0;
Button1.Caption := Label5.Caption;
if bOfficeFonts then Font.Name := sOfficeFontName;
end;
procedure TSearchForm.Edit1Change(Sender: TObject);
begin
SearchIndex := 0;
Button1.Caption := Label5.Caption;
if Edit1.Text = '' then
Button1.Enabled := False
else
Button1.Enabled := True;
end;
procedure TSearchForm.FormShow(Sender: TObject);
begin
if Method = 1 then begin
Label2.Visible := False;
Caption := Label3.Caption;
end;
end;
end.