📄 mainunit.pas
字号:
procedure TfrmMain.Disconnect1Click(Sender: TObject);
begin
FBus1.PhoneBeep;
FBus1.Disconnect;
MFBUSStatusBar1.Panels[0].text:='Disconnected';
MFBUSStatusBar1.panels[1].text:='';
end;
procedure TfrmMain.ChangeComport1Click(Sender: TObject);
begin
ChangeComport;
// FBUS1.Comport:=TCOMPORT(ComportToUse);
end;
procedure TfrmMain.SoftReset1Click(Sender: TObject);
begin
fBus1.ResetPhone(rsSoft);
end;
procedure TfrmMain.HardReset1Click(Sender: TObject);
begin
fBus1.ResetPhone(rsHard);
end;
procedure TfrmMain.Button3Click(Sender: TObject);
begin
FBUS1.SetAlarmTime(StrToTime(txtTime.text));
end;
procedure TfrmMain.FormCreate(Sender: TObject);
begin
bFirstTime:=true;
//sApplicationPath:=ExtractFilePath(Paramstr(0));
sApplicationPath:=GetCurrentDir+'\';
bContinueLoop:=true;
Outlook1.ActiveTab:=1;
Notebook1.PageIndex:=0;
cmbpMemType.itemindex:=1;
rgrpDTMFType.itemindex:=0;
cmboLogoType.itemindex:=2;
fWin95:= (GetVersion() and $80000000)<>0;
if Not fWin95 then
begin
rgrpPlayDevice.Items.add('PC Speaker');
rgrpPlayDevice.Items.add('MIDI Device');
rgrpPlayDevice.Items.add('Phone');
rgrpPlayDevice.itemindex:=1;
end
else
begin
rgrpPlayDevice.Items.add('MIDI Device');
rgrpPlayDevice.Items.add('Phone');
rgrpPlayDevice.itemindex:=0;
end
end;
procedure TfrmMain.Outlook1ItemClick(Sender: TObject; Item: String);
begin
if item='Phone Book' then
begin
lblText.caption:='Phone Book';
if fBus1.Connected then
begin
application.processmessages;
//LoadPhoneBook;
PhoneBookGet(TMemType(cmbpMemType.itemindex));
end
else
Notebook1.PageIndex:=1;
end;
if item='SMS' then
begin
Notebook1.PageIndex:=2;
lblText.caption:='SMS Messages';
application.processmessages;
cmboSMSMemType.itemindex:=2;
LoadSMSMessages(cmboSMSMemType.itemindex+11);
end;
if item='Ring Tone' then
begin NoteBook1.pageindex:=4; lblText.caption:='Ringtone'; end;
if item='Information' then
begin NoteBook1.pageindex:=0; lblText.caption:='Phone Information'; end;
if Item='Speed Dial' then
begin NoteBook1.pageindex:=3; lblText.caption:='Speed Dial'; end;
if Item='DTMF' then
begin NoteBook1.pageindex:=5; lblText.caption:='DTMF'; end;
if Item='Logo' then
begin NoteBook1.pageindex:=6; lblText.caption:='Logo'; end;
if Item='Net Monitor' then
begin NoteBook1.pageindex:=7; lblText.caption:='Net Monitor'; end;
end;
procedure TfrmMain.cmbpMemTypeClick(Sender: TObject);
begin
if fBus1.Connected then
LoadPhoneBook
else
Notebook1.PageIndex:=1;
end;
procedure TfrmMain.btnPBRefreshClick(Sender: TObject);
begin
if messageDlg('This will check the Phone book entries on the Phone with the local database. This may take a few minutes. Continue?',mtConfirmation,[mbYes,mbNo],0)=mrYes then
begin
if fBus1.Connected then
//LoadPhoneBook
CompareAndUpdatePhoneBooks(TMemType(cmbpMemType.itemindex))
else
begin
Notebook1.PageIndex:=1;
messagedlg('The phone is not connected. Plece connect phone and try again',mtinformation,[mbOk],0);
end;
end;
end;
procedure TfrmMain.btnPBAddnewClick(Sender: TObject);
begin
application.Createform(TfrmAddNewPBEntry,frmAddNewPBEntry);
frmAddNewPBEntry.execute;
//if frmAddNewPBEntry.execute then
// btnPBRefreshClick(self);
end;
procedure TfrmMain.Exit1Click(Sender: TObject);
begin
if fBus1.Connected then Disconnect1Click(Self);
application.terminate;
end;
procedure TfrmMain.btnPBDeleteClick(Sender: TObject);
begin
if messagedlg('Are you sure you want to delete this entry?',mtConfirmation,[mbYes,mbNo],0) = mrYes then
begin
//FBUS1.PhoneBook.DeleteEntry(TMemType(cmbpMemType.itemindex),lvPhoneBook.Selected.Caption,lvPhoneBook.items[lvPhoneBook.Selected.Index].SubItems[1]);
//lvPhoneBook.Items.Delete(lvPhoneBook.Selected.Index);
PhoneBookDelete(lvPhoneBook.Selected.Caption,lvPhoneBook.items[lvPhoneBook.Selected.Index].SubItems[0],TMemType(cmbpMemType.itemindex));
end;
end;
procedure TfrmMain.imgPhoneMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
image4.visible:=false;
end;
procedure TfrmMain.imgPhoneMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
var
bNormalCursor:boolean;
begin
bNormalCursor:=true;
if ((y>207) and (y<220)) then
begin
bNormalCursor:=false;
if((x>11) and (x<31)) or((x>39) and (x<59)) or ((x>65) and (x<85)) then
screen.Cursor:=crHandPoint
else
screen.Cursor:=crDefault;
end;
if ((y>225) and (y<236)) then
begin
bNormalCursor:=false;
if((x>11) and (x<31)) or((x>39) and (x<59)) or ((x>65) and (x<85)) then
screen.Cursor:=crHandPoint
else
screen.Cursor:=crDefault;
end;
if ((y>243) and (y<256)) then
begin
bNormalCursor:=false;
if((x>11) and (x<31)) or((x>39) and (x<59)) or ((x>65) and (x<85)) then
screen.Cursor:=crHandPoint
else
screen.Cursor:=crDefault;
end;
if bNormalCursor then
screen.Cursor:=crDefault;
end;
procedure TfrmMain.imgPhoneMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if ((y>207) and (y<220)) then //first row of keyboad
begin
if ((x>11) and (x<31)) then
FindSpeedDialDetails(1); // - Only keys 2 - 9 are uesed for speed dials
if ((x>39) and (x<59)) then
FindSpeedDialDetails(2);
if ((x>65) and (x<85)) then
FindSpeedDialDetails(3);
end;
if ((y>225) and (y<236)) then //Second row of keyboad
begin
if ((x>11) and (x<31)) then
FindSpeedDialDetails(4);
if ((x>39) and (x<59)) then
FindSpeedDialDetails(5);
if ((x>65) and (x<85)) then
FindSpeedDialDetails(6);
end;
if ((y>243) and (y<256)) then //Third row of keyboad
begin
if ((x>11) and (x<31)) then
FindSpeedDialDetails(7);
if ((x>39) and (x<59)) then
FindSpeedDialDetails(8);
if ((x>65) and (x<85)) then
FindSpeedDialDetails(9);
end;
end;
procedure TfrmMain.FindSpeedDialDetails(iValue:integer);
var
PhoneBookEntry : TPhoneBookEntry;
begin
PhoneBookEntry:=FBUS1.PhoneBook.FindSpeedDial(iValue);
lblLocation.caption:=IntToStr(PhoneBookEntry.location);
lblSpeedPosition.caption:=IntToStr(PhoneBookEntry.location);
txtSpeedName.text:='';
txtSpeedNumber.text:='';
txtSpeedGroup.text:='';
txtSpeedName.text:=PhoneBookEntry.name;
txtSpeedNumber.text:=PhoneBookEntry.number;
txtSpeedGroup.text:=IntToStr(PhoneBookEntry.Group);
cmboSpeedMem.itemindex:=Ord(PhoneBookEntry.memType);
btnAddSpeedDial.visible:=false;
lvSpeedDial.visible:=false;
if (PhoneBookEntry.name='') and (PhoneBookEntry.number='') then
begin
txtSpeedName.enabled:=True;
txtSpeedNumber.enabled:=True;
txtSpeedGroup.enabled:=True;
btnAddSpeedDial.visible:=True;
lvSpeedDial.items.clear;
lvSpeedDial.items:=lvPhoneBook.items;
lvSpeedDial.visible:=True;
end;
end;
procedure TfrmMain.btnAddSpeedDialClick(Sender: TObject);
begin
//.$IFDEF REGISTRED}
if lvSpeedDial.selcount =0 then
messagedlg('Select the name and number from the list of PhoneBook entries.',mtInformation,[mbOk],0)
else
begin
//FBUS1.PhoneBook.AddSpeedDial(StrToInt(lblLocation.caption),lvSpeedDial.Selected.Caption,TmemType(cmboSpeedMem.itemindex));
FBUS1.PhoneBook.AddSpeedDial(StrToInt(lblLocation.caption),lvSpeedDial.Selected.Caption,TmemType(cmboSpeedMem.itemindex),(lvSpeedDial.Selected.index+1));
lvSpeedDial.visible:=false;
FindSpeedDialDetails(StrToInt(lblLocation.caption)); //refresh the screen with the new entry
end;
//.$ELSE}
// messagedlg('This Feature is not availble in the Demo version',mtInformation,[mbOk],0);
//.$ENDIF}
end;
procedure TfrmMain.btnEditSpeedDialClick(Sender: TObject);
begin
//.$IFDEF REGISTRED}
if lvSpeedDial.visible=True then
begin
FBUS1.PhoneBook.EditSpeedDial(StrToInt(lblLocation.caption),txtSpeedName.text,TmemType(cmboSpeedMem.itemindex),(lvSpeedDial.Selected.index+1));
lvSpeedDial.visible:=false;
FindSpeedDialDetails(StrToInt(lblLocation.caption)); //refresh the screen with the new entry
end
else
begin
lvSpeedDial.items.clear;
lvSpeedDial.items:=lvPhoneBook.items;
lvSpeedDial.visible:=True;
end;
//.$ELSE}
// messagedlg('This Feature is not availble in the Demo version',mtInformation,[mbOk],0);
//.$ENDIF}
end;
procedure TfrmMain.cmboSMSMemTypeClick(Sender: TObject);
begin
LoadSMSMessages(cmboSMSMemType.itemindex+11);
end;
procedure TfrmMain.FBUS1DelivaryCount(iSMSCount: Integer);
begin
if cmboSMSMemType.itemindex = 0 then smsMemory.position:=iSMSCount;
end;
procedure TfrmMain.FBUS1InboxCount(iSMSCount: Integer);
begin
if cmboSMSMemType.itemindex = 2 then smsMemory.position:=iSMSCount;
end;
procedure TfrmMain.FBUS1OutBoxCount(iSMSCount: Integer);
begin
if cmboSMSMemType.itemindex = 1 then smsMemory.position:=iSMSCount;
end;
procedure TfrmMain.lvSMSClick(Sender: TObject);
begin
if lvSMS.SelCount >0 then
btnDeleteSMS.Visible:=true
else
btnDeleteSMS.Visible:=false;
end;
procedure TfrmMain.btnSMSSendSMSClick(Sender: TObject);
begin
application.CreateForm(TfrmSendSMS,frmSendSMS);
frmSendSMS.showmodal;
end;
procedure TfrmMain.lvSMSDblClick(Sender: TObject);
var
sSender:string;
begin
if lvSMS.SelCount >0 then
begin
Application.createForm(TfrmSMSView,frmSMSView);
frmSMSView.lblSMSDate.caption:=lvSMS.Selected.Caption;
sSender:=FindSendersName(lvSMS.items[lvSMS.Selected.Index].SubItems[0]);
if sSender ='' then
frmSMSView.lblSMSFrom.caption:=lvSMS.items[lvSMS.Selected.Index].SubItems[0]
else
frmSMSView.lblSMSFrom.caption:=lvSMS.items[lvSMS.Selected.Index].SubItems[0]+', '+sSender;
frmSMSView.moMessage.text:=lvSMS.items[lvSMS.Selected.Index].SubItems[2];
frmSMSView.showmodal;
end;
end;
function TfrmMain.FindSendersName(sNumber:string):string;
var
iPos:integer;
res:string;
begin
res:='';
for iPos:=0 to lvPhoneBook.items.count-1 do
if Pos(Copy(sNumber,4,length(sNumber)),lvPhoneBook.items[iPos].subitems[0]) >0 then
begin
res:= lvPhoneBook.items[ipos].caption;
break;
end;
Result:=res;
end;
procedure TfrmMain.FBUS1SMSSent;
begin
frmSendSMS.close;
MessageDlg('SMS Delivered',mtInformation,[mbok],0);
end;
procedure TfrmMain.FBUS1SMSSendError;
begin
MessageDlg('There was an erro Delivering the SMS Message.',mtInformation,[mbok],0);
end;
procedure TfrmMain.FBUS1NewSMSMessage;
begin
messagedlg('You have received a new SMS Message.',mtInformation,[mbOk],0);
LoadSMSMessages(fbIncommingMessage);
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -