📄 note.pas
字号:
// GridLoadData(UndoSeek+1);
ListView.Items.BeginUpdate;
CurItem:=ListView.Items.Insert(UndoSeek);
CurItem.Caption:=NoteMess.Name;
if FieldShow[1]=0 then
CurItem.SubItems.Add(NoteMess.Birthday);
if FieldShow[2]=0 then
CurItem.SubItems.Add(NoteMess.MoveTel);
if FieldShow[3]=0 then
CurItem.SubItems.Add(NoteMess.HomeTel);
if FieldShow[4]=0 then
CurItem.SubItems.Add(NoteMess.OfficeTel);
if FieldShow[5]=0 then
CurItem.SubItems.Add(NoteMess.Fax);
if FieldShow[6]=0 then
CurItem.SubItems.Add(NoteMess.Company);
if FieldShow[7]=0 then
CurItem.SubItems.Add(NoteMess.PostCode);
if FieldShow[8]=0 then
CurItem.SubItems.Add(NoteMess.Web);
if FieldShow[9]=0 then
CurItem.SubItems.Add(NoteMess.Email);
if FieldShow[10]=0 then
CurItem.SubItems.Add(NoteMess.Address);
FileSeek(CfgFile,1000+UndoSeek*1000,0);
FileRead(CfgFile,FieldText,1000);
for j:=0 to CustomCount-1 do
if FieldShow[11+j]=0 then
CurItem.SubItems.Add(FieldText[j]);
ListView.Items.EndUpdate;
UndelBtn.Enabled:=False;
U1.Enabled:=False;
end;
procedure TMainForm.ListViewLoadData(IsModify:Boolean;Index:Integer);
var
i:Integer;
j:Byte;
CurItem:TListItem;
begin
// SetListViewColume;
if IsModify then
begin
// i:=ListView.Selected.Index;
try
FileSeek(MainFile,5+Index*NoteSize,0);
FileRead(MainFile,NoteMess,NoteSize);
ListView.Items.BeginUpdate;
if Index<ListView.Items.Count then
ListView.Items.Delete(Index);
CurItem:=ListView.Items.Insert(Index);
CurItem.Caption:=NoteMess.Name;
if FieldShow[1]=0 then
CurItem.SubItems.Add(NoteMess.Birthday);
if FieldShow[2]=0 then
CurItem.SubItems.Add(NoteMess.MoveTel);
if FieldShow[3]=0 then
CurItem.SubItems.Add(NoteMess.HomeTel);
if FieldShow[4]=0 then
CurItem.SubItems.Add(NoteMess.OfficeTel);
if FieldShow[5]=0 then
CurItem.SubItems.Add(NoteMess.Fax);
if FieldShow[6]=0 then
CurItem.SubItems.Add(NoteMess.Company);
if FieldShow[7]=0 then
CurItem.SubItems.Add(NoteMess.PostCode);
if FieldShow[8]=0 then
CurItem.SubItems.Add(NoteMess.Web);
if FieldShow[9]=0 then
CurItem.SubItems.Add(NoteMess.Email);
if FieldShow[10]=0 then
CurItem.SubItems.Add(NoteMess.Address);
FileSeek(CfgFile,1000+Index*1000,0);
FileRead(CfgFile,FieldText,1000);
for j:=0 to CustomCount-1 do
if FieldShow[11+j]=0 then
CurItem.SubItems.Add(FieldText[j]);
finally
ListView.Items.EndUpdate;
end;
end
else begin
try
if Index>=1 then
ListView.Items.Delete(Index)
else begin
ListView.Items.Clear;
FileSeek(MainFile,5,0);
FileSeek(CfgFile,1000,0);
ListView.Items.BeginUpdate;
for i:=1 to TotalUser do
begin
FileRead(MainFile,NoteMess,NoteSize);
FileRead(CfgFile,FieldText,1000);
TheList.Append(NoteMess.Name);
CurItem:=ListView.Items.Add;
CurItem.Caption:=NoteMess.Name;
if FieldShow[1]=0 then
CurItem.SubItems.Add(NoteMess.Birthday);
if FieldShow[2]=0 then
CurItem.SubItems.Add(NoteMess.MoveTel);
if FieldShow[3]=0 then
CurItem.SubItems.Add(NoteMess.HomeTel);
if FieldShow[4]=0 then
CurItem.SubItems.Add(NoteMess.OfficeTel);
if FieldShow[5]=0 then
CurItem.SubItems.Add(NoteMess.Fax);
if FieldShow[6]=0 then
CurItem.SubItems.Add(NoteMess.Company);
if FieldShow[7]=0 then
CurItem.SubItems.Add(NoteMess.PostCode);
if FieldShow[8]=0 then
CurItem.SubItems.Add(NoteMess.Web);
if FieldShow[9]=0 then
CurItem.SubItems.Add(NoteMess.Email);
if FieldShow[10]=0 then
CurItem.SubItems.Add(NoteMess.Address);
for j:=0 to CustomCount-1 do
if FieldShow[11+j]=0 then
CurItem.SubItems.Add(FieldText[j]);
{ CurItem.SubItems.Add(NoteMess.Email);
CurItem.SubItems.Add(NoteMess.OfficeTel);
CurItem.SubItems.Add(NoteMess.HomeTel);
CurItem.SubItems.Add(NoteMess.MoveTel);}
end;
end;
finally
ListView.Items.EndUpdate;
end;
end;
end;
procedure TMainForm.D1Click(Sender: TObject);
begin
winexec('rundll32.exe rnaui.dll,RnaDial '+'连接Internet',9);
end;
procedure TMainForm.M1Click(Sender: TObject);
begin
if ListView.Selected<>nil then
ShellExecute(handle,nil,pchar('mailto:'+ListView.Selected.SubItems[0]),nil,nil,
sw_shownormal)
else MessageDlg('请选定要发送邮件的对象!',mtInformation,[mbOk],0);
end;
procedure TMainForm.ListGridDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
{ ImageList2.Draw(ListGrid.Canvas,1,20,0);
ListGrid.Canvas.Brush.Style:=bsClear;
ListGrid.CAnvas.TextOut(30,25,ListGrid.Cells[0,1]);}
end;
procedure TMainForm.N13Click(Sender: TObject);
begin
if ListView.Selected<>nil then
begin
FileSeek(MainFile,5+NoteSize*(ListView.Selected.Index),0);
FileRead(MainFile,NoteMess,NoteSize);
CanPaste:=True;
end;
end;
procedure TMainForm.N14Click(Sender: TObject);
begin
if CanPaste then
begin
Inc(TotalUser);
FileSeek(MainFile,5+NoteSize*(TotalUser-1),0);
FileWrite(MainFile,NoteMess,NoteSize);
FileSeek(MainFile,1,0);
FileWrite(MainFile,TotalUser,4);
// ListGrid.RowCount:=TotalUser+1;
ListViewLoadData(True,TotalUser-1);
end;
end;
procedure TMainForm.E2Click(Sender: TObject);
begin
// if (ListGrid.RowCount>2)or((ListGrid.RowCount=2)and(ListGrid.Cells[0,1]<>''))then
if ListView.Selected<>nil then
begin
FileSeek(MainFile,5+NoteSize*TheList.IndexOf(ListView.Selected.Caption),0);
FileRead(MainFile,NoteMess,NoteSize);
FileSeek(CfgFile,1000+1000*TheList.IndexOf(ListView.Selected.Caption),0);
FileRead(CfgFile,FieldText,1000);
IsModify:=True;
Application.CreateForm(TNewUserf,NewUserf);
NewUserf.LoadMessages;
NewUserf.Caption:='编辑联系人信息';
NewUserf.ShowModal;
end
else
MessageDlg('未选定联系人!',mtInformation,[mbOk],0);
end;
procedure TMainForm.NewDirClick(Sender: TObject);
var
sDir:ShortString;
begin
sDir:=InputBox('输入文件夹名','请输入盘号和文件夹名','');
if not CreateDir(sDir) then
MessageDlg('创建文件夹失败!',mtInformation,[mbOk],0);
end;
procedure TMainForm.S1Click(Sender: TObject);
begin
Application.CreateForm(TSetupf, Setupf);
Setupf.ShowModal;
end;
procedure TMainForm.N22Click(Sender: TObject);
begin
with Sender as TMenuItem do
begin
Checked:=True;
if Caption='姓名(&N)' then
ListView.SortType:=stText
// SortIndex:=1
else if Caption='电子邮件(&E)' then
ListView.SortType:=stData
// SortIndex:=2
else if Caption='办公电话(&O)' then
SortIndex:=3
else if Caption='住宅电话(&H)' then
SortIndex:=4
else if Caption='递增(&A)' then
SortStyle:=1
else if Caption='递减(&D)' then
SortStyle:=2;
end;
SortUser;
end;
procedure TMainForm.SearchUser;
var
i:Integer;
begin
for i:=1 to TotalUser do
begin
end;
end;
procedure TMainForm.SortUser;
begin
end;
procedure TMainForm.InputEditKeyPress(Sender: TObject; var Key: Char);
var
i:Word;
begin
if Key=#13 then
begin
for i:=0 to ListView.Items.Count-1 do
begin
if ListView.Items.Item[i].Caption=InputEdit.Text then
begin
ListView.ItemIndex:=i;
ListView.SetFocus;
// ListView.Scroll(0,i*14);
Break;
end;
end;
end;
end;
procedure TMainForm.SearchBtnClick(Sender: TObject);
begin
Application.CreateForm(TFindf, Findf);
Findf.ShowModal;
end;
procedure TMainForm.N40Click(Sender: TObject);
begin
with Sender as TMenuItem do
begin
Checked:=True;
ListView.ViewStyle:=TViewStyle(Tag);
CfgData:=Tag;
end;
Case CfgData of
0:begin
N40.Checked:=True;
G0.Checked:=N40.Checked;
end;
1:begin
N41.Checked:=True;
G1.Checked:=N41.Checked;
end;
2:begin
N42.Checked:=True;
G2.Checked:=N42.Checked;
end;
3:begin
N43.Checked:=True;
G3.Checked:=N43.Checked;
end;
end;
end;
procedure TMainForm.SetListViewColume;
var
i:Byte;
Capl:String[20];
begin
with ListView.Columns do
begin
Clear;
for i:=0 to 10+CustomCount do
begin
if FieldShow[i]=0 then
begin
if i<=10 then
Capl :=StandardText[i]
else
Capl:=Fields[i-11];
if Capl<>'' then
begin
with add do
begin
Caption :=Capl;
Width := ColumnHeaderWidth;
Alignment := taCenter;
end;
end;
end;
end;
end;
end;
procedure TMainForm.ListViewDblClick(Sender: TObject);
begin
OptionBtnClick(Sender);
end;
procedure TMainForm.ListViewKeyPress(Sender: TObject; var Key: Char);
begin
if Key=#13 then
OptionBtnClick(Sender);
end;
procedure TMainForm.R1Click(Sender: TObject);
begin
ListViewLoadData(False,0);
end;
procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
FileClose(MainFile);
FileSeek(CfgFile,0,0);
FileWrite(CfgFile,CfgData,1);
FileWrite(CfgFile,BtnWord,2);
FileWrite(CfgFile,IsShowToolBar,1);
FileWrite(CfgFile,IsShowStatus,1);
FileClose(CfgFile);
TheList.Free;
end;
procedure TMainForm.H2Click(Sender: TObject);
begin
H2.Checked:=not H2.Checked;
ToolBar.ShowCaptions:=H2.Checked;
BtnWord:=(BtnWord+1)mod 2;
end;
procedure TMainForm.A1Click(Sender: TObject);
begin
ShowMessage(' 通 讯 簿(1.0版)'+#13#10+#13#10+
'版权所有:2002.6.'+#13#10+
'作者:李培方');
end;
procedure TMainForm.N16Click(Sender: TObject);
begin
ListView.SelectAll;
end;
procedure TMainForm.Timer1Timer(Sender: TObject);
begin
StatusBar.Panels[2].Text:=TimeToStr(Now);
end;
procedure TMainForm.FormResize(Sender: TObject);
begin
StatusBar.Panels[0].Width:=Width-120;
end;
procedure TMainForm.FormShow(Sender: TObject);
var
Kbs:TKeyBoardState;
begin
GetKeyBoardState(Kbs);
if Odd(Kbs[VK_NUMLOCK]) then
StatusBar.Panels[1].Text:='数字'
else StatusBar.Panels[1].Text:='';
end;
procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
Kbs:TKeyBoardState;
begin
GetKeyBoardState(Kbs);
if Odd(Kbs[VK_NUMLOCK]) then
StatusBar.Panels[1].Text:='数字'
else StatusBar.Panels[1].Text:='';
end;
procedure TMainForm.F1Click(Sender: TObject);
begin
Application.CreateForm(TFindf, Findf);
Findf.TabbedNoteBook1.PageIndex:=1;
Findf.Caption:='设置字体';
Findf.ShowModal;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -