轻舞肥羊您好:这是做的一个语音卡的程序,调用USB语音卡的电话号信息,我对消息不了解,这是厂家的示例写法,用showmodal方式运行此窗体,可以正常捕捉电话卡信息,一但将将窗体嵌入到主窗体的页面中去就可行了,无法捕捉电话卡的信息了,多谢。 Procedure OnDeviceMsg(var msg: TMessage); Message WM_USBLINEMSG;==============================unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Menus, ComCtrls, Buttons, StdCtrls;const WM_USBLINEMSG = WM_USER + 180; MCU_BACKID = $07 ; // Return Device ID MCU_BACKSTATE= $08 ; // Return Device State MCU_BACKCID = $09 ; // Return Device CallerID MCU_BACKDIGIT =$0A ;// Return Device Dial Digit MCU_BACKDEVICE = $0B ; // Return Device Back Device ID MCU_BACKPARAM =$0C ; // Return Device Paramter MCU_BACKCPUID =$0D ; // Return Device CPU ID MCU_BACKCOLLATERAL=$0E; // Return Collateral phone dialed MCU_BACKDISABLE= $FF ; // Return Device Init MCU_BACKENABLE =$EE ; MCU_BACKMISSED =$AA ;// Call missed MCU_BACKTALK =$BB ;// Start Talktype AD101DEVICEPARAMETER=record nRingOn,nRingOff,nHookOn,nHookOff,nStopCID,nNoLine:integer; end;type LEDTYPE=(LED_CLOSE =1,LED_RED,LED_GREEN,LED_YELLOW,LED_REDSLOW, LED_GREENSLOW,LED_YELLOWSLOW,LED_REDQUICK,LED_GREENQUICK,LED_YELLOWQUICK);type pAD101DEVICEPARAMETER=^AD101DEVICEPARAMETER;type ENUMLINEBUSY=(LINEBUSY,LINEFREE);type LINESTATE=( HKONSTATEPRA = $01, // hook on pr+ HOOKON_PRA HKONSTATEPRB = $02, // hook on pr- HOOKON_PRR HKONSTATENOPR = $03, // have pr HAVE_PR HKOFFSTATEPRA = $04, // hook off pr+ HOOKOFF_PRA HKOFFSTATEPRB = $05, // hook off pr- HOOKOFF_PRR NO_LINE = $06, // no line NULL_LINE RINGONSTATE = $07, // ring on RING_ON RINGOFFSTATE = $08, // ring off RING_OFF NOHKPRA = $09, // NOHOOKPRA= 0x09, // no hook pr+ NOHKPRB = $0a, // NOHOOKPRR= 0x0a, // no hook pr- NOHKNOPR = $0b // NOHOOKNPR= 0x0b, // no hook no pr);function AD101_InitDevice(APP:THandle):integer;stdcall;external 'AD101Device.dll';function AD101_GetDevice():integer;stdcall;external 'AD101Device.dll';procedure AD101_FreeDevice();stdcall;external 'AD101Device.dll';procedure AD101_ChangeWindowHandle(hWnd:THandle) stdcall;external 'AD101Device.DLL';procedure AD101_ReadParameter(nLine:integer);stdcall;external 'AD101Device.DLL' ;procedure AD101_GetParameter(nLine:integer;tagParameter
AD101DEVICEPARAMETER);stdcall;external 'AD101Device.dll' ;// Set systematic parameterfunction AD101_SetParameter(nLine:integer;tagParameter
AD101DEVICEPARAMETER):integer;stdcall;external 'AD101Device.DLL' ;function AD101_GetCallerID(nLine:integer;szCallerIDBuffer
Char;szName
char;szTime
char):integer;stdcall;external 'AD101Device.DLL' ;function AD101_GetDialDigit(nLine:integer;szDialDigitBuffer
Char):integer;stdcall;external 'AD101Device.DLL' ; // Get collateral phone dialed numberfunction AD101_GetCollateralDialDigit(nLine:integer;szDialDigitBuffer
Char):integer;stdcall;external 'AD101Device.DLL' ;function AD101_GetState(nLine:integer):integer;stdcall;external 'AD101Device.DLL';function AD101_GetRingIndex(nLine:integer):integer;stdcall;external 'AD101Device.DLL';function AD101_GetTalkTime(nLine:integer):integer;stdcall;external 'AD101Device.DLL';function AD101_GetCPUVersion(nLine:integer;szCPUVersion
Char):integer;stdcall;external 'AD101Device.DLL' ;procedure AD101_ReadCPUID(nLine :integer);stdcall;external 'AD101Device.DLL' ;function AD101_GetCPUID(nLine:integer;szCPUID
Char):integer;stdcall;external 'AD101Device.DLL' ;// Show or don't show collateral phone dialed numberprocedure AD101_ShowCollateralPhoneDialed(bShow:boolean);stdcall;external 'AD101Device.DLL';procedure AD101_SetLED(nLine:integer;enumLed :LEDTYPE);stdcall;external 'AD101Device.DLL';procedure AD101_SetBusy(cnLine:integer;LineBusy :ENUMLINEBUSY);stdcall;external 'AD101Device.DLL';procedure AD101_SetStartTalk(nLine:integer);stdcall;external 'AD101Device.DLL';procedure AD101_SetDialOutStartTalkingTime(nSecond:integer);stdcall;external 'AD101Device.DLL';procedure AD101_SetRingOffTime(nSecond:integer);stdcall;external 'AD101Device.DLL';type TForm1 = class(TForm) GroupBox2: TGroupBox; RadioButton1: TRadioButton; RadioButton2: TRadioButton; RadioButton16: TRadioButton; RadioButton17: TRadioButton; RadioButton4: TRadioButton; RadioButton14: TRadioButton; RadioButton5: TRadioButton; RadioButton6: TRadioButton; RadioButton8: TRadioButton; RadioButton10: TRadioButton; GroupBox1: TGroupBox; Label2: TLabel; Label3: TLabel; Label4: TLabel; IDC_EDIT3: TEdit; IDC_EDIT4: TEdit; IDC_EDIT5: TEdit; Button1: TButton; Button2: TButton; GroupBox3: TGroupBox; ListView1: TListView; ComboBox1: TComboBox; Label1: TLabel; IDC_EDIT2: TEdit; IDC_EDIT1: TEdit; btnREAD: TButton; btnSet: TButton; BtnLineBusy: TButton; BtnLineFree: TButton; Label5: TLabel; IDC_EDIT7: TEdit; IDC_EDIT6: TEdit; Label6: TLabel; BitBtn2: TBitBtn; Button3: TButton; Label7: TLabel; CheckBoxSHOWPHONENUMBER: TCheckBox; CheckBoxSHOWNUMBER: TCheckBox; Label8: TLabel; Edit1: TEdit; // Procedure WMUserSHOWLINETM(var msg: TMessage); // Message WM_SHOWLINETM; procedure FormCreate(Sender: TObject); procedure ComboBox1Change(Sender: TObject); procedure RadioButton1Click(Sender: TObject); procedure RadioButton2Click(Sender: TObject); procedure RadioButton10Click(Sender: TObject); procedure RadioButton5Click(Sender: TObject); procedure RadioButton16Click(Sender: TObject); procedure RadioButton4Click(Sender: TObject); procedure RadioButton6Click(Sender: TObject); procedure RadioButton17Click(Sender: TObject); procedure RadioButton14Click(Sender: TObject); procedure RadioButton8Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure BtnLineBusyClick(Sender: TObject); procedure BtnLineFreeClick(Sender: TObject); procedure btnREADClick(Sender: TObject); procedure btnSetClick(Sender: TObject); procedure BitBtn2Click(Sender: TObject); Procedure OnDeviceMsg(var msg: TMessage); Message WM_USBLINEMSG; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure CheckBoxSHOWNUMBERClick(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1; nLineIndex:integer;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);var nLine :integer; tempItem :tlistitem;begin for nLine := 1 to 4 do begin ComboBox1.Items.Add(('Line'+ IntToStr(nLine))); end; combobox1.ItemIndex :=0; for nLine :=1 to 4 do begin tempItem:=listview1.Items.Add; tempItem.Caption:= ('Line'+ IntToStr(nLine)); tempItem.SubItems.Add('Disable'); tempItem.SubItems.Add(''); tempItem.SubItems.Add(''); tempItem.SubItems.Add(''); tempItem.SubItems.Add(''); tempItem.SubItems.Add(''); tempItem.SubItems.Add(''); tempItem.SubItems.Add(''); end; RadioButton1.Checked :=true;// listview1.Items[1].SubItems[2] :='ming' ; nLineIndex:=0; if( AD101_InitDevice(self.Handle)= 0 ) then begin showmessage('canot init device'); close(); end; AD101_GetDevice(); IDC_EDIT6.Text :='3'; IDC_EDIT7.Text :='7'; AD101_SetDialOutStartTalkingTime(3); AD101_SetRingOffTime(7); CheckBoxSHOWPHONENUMBER.checked :=TRUE; CheckBoxSHOWNUMBER.Checked :=TRUE;end;procedure TForm1.ComboBox1Change(Sender: TObject);begin case combobox1.ItemIndex of 0:nLineIndex:=0; 1:nLineIndex:=1; 2:nLineIndex:=2; 3:nLineIndex:=3; end;end;procedure TForm1.RadioButton1Click(Sender: TObject);begin AD101_SetLED( nLineIndex ,LED_CLOSE);end;procedure TForm1.RadioButton2Click(Sender: TObject);begin AD101_SetLED(nLineIndex,LED_RED);end;procedure TForm1.RadioButton10Click(Sender: TObject);begin AD101_SetLED(nLineIndex,LED_REDSLOW);end;procedure TForm1.RadioButton5Click(Sender: TObject);begin AD101_SetLED(nLineIndex,LED_REDQUICK);end;procedure TForm1.RadioButton16Click(Sender: TObject);begin AD101_SetLED(nLineIndex,LED_GREEN);end;procedure TForm1.RadioButton4Click(Sender: TObject);begin AD101_SetLED(nLineIndex,LED_GREENSLOW); end;procedure TForm1.RadioButton6Click(Sender: TObject);begin AD101_SetLED(nLineIndex,LED_GREENQUICK);end;procedure TForm1.RadioButton17Click(Sender: TObject);begin AD101_SetLED(nLineIndex,LED_YELLOW);end;procedure TForm1.RadioButton14Click(Sender: TObject);begin AD101_SetLED(nLineIndex,LED_YELLOWSLOW);end;procedure TForm1.RadioButton8Click(Sender: TObject);begin AD101_SetLED(nLineIndex,LED_YELLOWQUICK);end;procedure TForm1.Button3Click(Sender: TObject);beginclose;end;procedure TForm1.BtnLineBusyClick(Sender: TObject);begin AD101_SetBusy(nLineIndex,LINEBUSY);end;procedure TForm1.BtnLineFreeClick(Sender: TObject);begin AD101_SetBusy(nLineIndex,LINEFREE);end;procedure TForm1.btnREADClick(Sender: TObject);begin AD101_ReadParameter(nLineIndex); IDC_EDIT1.TEXT:=''; IDC_EDIT2.TEXT:=''; IDC_EDIT3.TEXT:=''; IDC_EDIT4.TEXT:=''; IDC_EDIT5.TEXT:=''; Edit1.TEXT:='';end;procedure TForm1.btnSetClick(Sender: TObject);var tagParameter : AD101DEVICEPARAMETER; nHookOnTime:string; nHookOffTime:string; nRingOnTime:string; nRingOffTime:string; nStopCIDTime:string; nNoLine :string;begin nHookOnTime:=IDC_EDIT1.Text; nHookOffTime:=IDC_EDIT2.Text; nRingOnTime:=IDC_EDIT3.Text; nRingOffTime:=IDC_EDIT4.Text; nStopCIDTime:=IDC_EDIT5.Text; nNoLine := Edit1.text; tagParameter.nRingOn :=StrToInt(nHookOnTime); tagParameter.nRingOff :=StrToInt(nHookOffTime); tagParameter.nHookOn :=StrToInt(nRingOnTime); tagParameter.nHookOff :=StrToInt(nRingOffTime); tagParameter.nStopCID :=StrToInt(nStopCIDTime); tagParameter.nNoLine :=strtoint(nNoLine) ; if AD101_SetParameter(nLineIndex,@tagParameter)=0 then begin showmessage('Set parameters failed!'); end;end;procedure TForm1.BitBtn2Click(Sender: TObject);begin AD101_SetDialOutStartTalkingTime(strtoint(IDC_EDIT6.Text)); AD101_SetRingOffTime(strtoint(IDC_EDIT7.Text));end;Procedure TForm1.OnDeviceMsg (var msg: TMessage);var nMsg :integer; nWaparam :integer; nLine :integer; nLparam :integer; szCPUVersion
char; szCallerID
char; szTime
char; szName
char; szRing :string[32]; szDialDigit
char; tagParameter:AD101DEVICEPARAMETER; szCPUID
char; szTalk:string[32];begin nWaparam:=msg.WParam; nLparam :=msg.LParam; nMsg := nWaparam Mod 65536 ; nLine :=Trunc(nWaparam / 65536 ) ; case nMsg of MCU_BACKDISABLE : begin listview1.Items[nLine].SubItems[0]:='Disable'; listview1.Items[nLine].SubItems[1]:=''; listview1.Items[nLine].SubItems[2]:=''; listview1.Items[nLine].SubItems[3]:=''; listview1.Items[nLine].SubItems[4]:=''; listview1.Items[nLine].SubItems[5]:=''; listview1.Items[nLine].SubItems[6]:=''; listview1.Items[nLine].SubItems[7]:=''; end; MCU_BACKENABLE : begin listview1.Items[nLine].SubItems[0]:='Enable'; end; MCU_BACKID: begin GetMem(szCPUVersion,32); listview1.Items[nLine].SubItems[0]:='Enable'; AD101_GetCPUVersion(nLine,szCPUVersion); listview1.Items[nLine].SubItems[1]:=szCPUVersion; FreeMem(szCPUVersion); end; MCU_BACKSTATE: begin case nLparam of 1://HKONSTATEPRA: listview1.Items[nLine].SubItems[2]:='HOOK ON PR+'; 2://HKONSTATEPRB: listview1.Items[nLine].SubItems[2]:='HOOK ON PR-'; 3://HKONSTATENOPR listview1.Items[nLine].SubItems[2]:='HOOK ON NOPR'; 4://HKOFFSTATEPRA begin GetMem(szCallerID,128); listview1.Items[nLine].SubItems[2]:='HOOK OFF PR+'; if (AD101_GetCallerID(nLine,szCallerID,nil,nil) < 1) and ( AD101_GetRingIndex(nLine) < 1) then begin listview1.Items[nLine].SubItems[3]:=''; end; listview1.Items[nLine].SubItems[4]:=''; listview1.Items[nLine].SubItems[5]:=''; listview1.Items[nLine].SubItems[6]:=''; FreeMem(szCallerID); end; //end 4 5: //HKOFFSTATEPRB begin listview1.Items[nLine].SubItems[2]:='HOOK OFF PR-'; GetMem(szCallerID,128); if (AD101_GetCallerID(nLine,szCallerID,nil,nil) < 1) and ( AD101_GetRingIndex(nLine) < 1) then begin listview1.Items[nLine].SubItems[3]:=''; end; listview1.Items[nLine].SubItems[4]:=''; listview1.Items[nLine].SubItems[5]:=''; listview1.Items[nLine].SubItems[6]:=''; FreeMem(szCallerID); end; //end HKOFFSTATEPRB 6: // NO_LINE begin listview1.Items[nLine].SubItems[2]:='No Line'; GetMem(szCallerID,128); if (AD101_GetCallerID(nLine,szCallerID,nil,nil) < 1) and ( AD101_GetRingIndex(nLine) < 1) then begin listview1.Items[nLine].SubItems[3]:=''; end; listview1.Items[nLine].SubItems[4]:=''; listview1.Items[nLine].SubItems[5]:=''; listview1.Items[nLine].SubItems[6]:=''; FreeMem(szCallerID); end;//end NO_LINE 7://RINGONSTATE begin szRing :=FormatFloat('Ring:00',AD101_GetRingIndex(nLine)); listview1.Items[nLine].SubItems[2]:=szRing; listview1.Items[nLine].SubItems[4]:=''; listview1.Items[nLine].SubItems[5]:=''; listview1.Items[nLine].SubItems[6]:=''; end; 8://RINGOFFSTATE listview1.Items[nLine].SubItems[2]:='Ring Off'; 9://NOHKPRA listview1.Items[nLine].SubItems[2]:='NO HOOK PR+'; 10://NOHKPRB listview1.Items[nLine].SubItems[2]:='NO HOOK PR-'; 11://NOHKNOPR listview1.Items[nLine].SubItems[2]:='NO HOOK NOPR'; end;//end case nLparm; end; //MCU_BACKSTATE MCU_BACKCID: begin GetMem(szCallerID,128); GetMem(szName,128); GetMem(szTime,128); AD101_GetCallerID(nLine,szCallerID,szName,szTime); listview1.Items[nLine].SubItems[3]:=szCallerID; listview1.Items[nLine].SubItems[4]:=''; listview1.Items[nLine].SubItems[5]:=''; listview1.Items[nLine].SubItems[6]:=''; FreeMem(szName); FreeMem(szTime); FreeMem(szCallerID); end; MCU_BACKDIGIT: begin if CheckBoxSHOWPHONENUMBER.Checked=true then begin GetMem( szDialDigit,128); AD101_GetDialDigit(nLine, szDialDigit ); listview1.Items[nLine].SubItems[4]:= szDialDigit; FreeMem(szDialDigit); end; end; MCU_BACKCOLLATERAL: begin GetMem( szDialDigit,128); AD101_GetCollateralDialDigit(nLine, szDialDigit ); listview1.Items[nLine].SubItems[5]:= szDialDigit; FreeMem(szDialDigit); end; MCU_BACKDEVICE: begin GetMem(szCPUVersion,32); listview1.Items[nLine].SubItems[0]:='Enable'; AD101_GetCPUVersion(nLine,szCPUVersion); listview1.Items[nLine].SubItems[1]:=szCPUVersion; FreeMem(szCPUVersion); end; MCU_BACKPARAM: begin AD101_GetParameter(nLine,@tagParameter); IDC_EDIT1.text :=inttostr(tagParameter.nRingOn); IDC_EDIT2.text :=inttostr(tagParameter.nRingOff); IDC_EDIT3.text :=inttostr(tagParameter.nHookOn); IDC_EDIT4.text :=inttostr(tagParameter.nHookOff); IDC_EDIT5.text :=inttostr(tagParameter.nStopCID); Edit1.Text := inttostr(tagParameter.nNoLine); end; MCU_BACKCPUID: begin GetMem(szCPUID,32); AD101_GetCPUID(nLine,szCPUID); listview1.Items[nLine].SubItems[7]:=szCPUID; fREEmEM(szCPUID); end; MCU_BACKMISSED: listview1.Items[nLine].SubItems[2]:='Missed Call'; MCU_BACKTALK: begin szTalk :=FormatFloat('00',nLparam); listview1.Items[nLine].SubItems[6]:=szTalk; end; end;//nMsgend;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);begin AD101_FreeDevice();end;procedure TForm1.CheckBoxSHOWNUMBERClick(Sender: TObject);var bShow:boolean;begin bShow :=CheckBoxSHOWNUMBER.checked; AD101_ShowCollateralPhoneDialed(bShow);end;end.