The following are ocx controls for use:
1. Open Initialization:
txUDP1.UDPConnect ()
Returns:
0. Description Success
1. Description Failure: Reason may have been another device port or disable
' error returns an error message
2. End Close
txUDP1.UDPclose
3. obtain data events
txUDP1_UDPdata
---------------------------------------------- ---------------------
'5 states: ----- mark symbol ( state ) , Caller ID , user name / line number, channel , E ( terminator )
' the first one kind of call number : M, 075526664777,26664777,01, E
' first two kinds of outgoing calls : T, 075526664777,26664777,01, E
' s three kinds of call -hook : A, 26664777,01, E ( effective when used in the incoming channel status )
' fourth -hook : B, 26664777,01, E
' first five kinds of missed calls : X, 26664777,01, E
Use jacob call, which method can call succeeds, but the event did not activate .
The following is my code :
public static void main (String [] args) {
JFrame f = new JFrame ();
JTextArea ta = new JTextArea ();
f.add (ta);
f.setSize (400, 500);
f.setVisible (true);
ActiveXComponent com = new ActiveXComponent ("txUDPOCX.txUDP");
Dispatch disp = com.getObject ();
/ / Initialize - 0 for success 1 for failure
System.out.println (Dispatch.call (disp, "UDPConnect"));
Listener listener = new Listener ();
listener.setTa (ta);
/ / listen for events
DispatchEvents de = new DispatchEvents (disp, listener, "txUDPOCX.txUDP");
/ / Dispatch.call (disp, "UDPclose");
}
event code :
public class Listener {
JTextArea ta;
public JTextArea getTa () {
return ta;
}
public void setTa (JTextArea ta) {
this.ta = ta;
}
public void txUDP1_UDPdata (Variant [] txUDP1_UDPdata) {
ta.append ("aaaa");
}
}
wrong it is not there ? Great God seeking guidance ......
------ Solution ------------------------------------ --------
import com.jacob.com.ComThread;
import com.jacob.com.Dispatch;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.DispatchEvents;
import com.jacob.com.Variant;
import java.io.IOException;
public class ocx {
public ocx () {
ComThread.InitMTA (true);
ActiveXComponent iTunesCom = new ActiveXComponent ("clsid: 287B48B3-80CA-4D0A-AE8E-F97A824FF279");
Dispatch testOcx = (Dispatch) iTunesCom.getObject ();
Dispatch.call (testOcx, "BaseConnect", new Variant ("COM3"), new Variant ("1,3-5"));
Dispatch.call (testOcx, "VoteNew");
Dispatch.call (testOcx, "VoteMode", new Variant ("5"), new Variant ("1,4,1"));
Dispatch.call (testOcx, "VoteStart");
DispatchEvents events = new DispatchEvents (testOcx, new KeyVoteA ());
try {
System.in.read ();
} catch (IOException e) {}
ComThread.Release ();
System.exit (0);
}
public class KeyVoteA {
/ / ocx event returned to the java class parameters to obtain
public void KeyVote (Variant [] args) {
System.out.println ("args [0] [" + args [0]. getInt ( ) ) ;
System.out.println ("args [1] [" + args [1]. getInt ( ) ) ;
System.out.println ("args [2] [" + args [2]. getString ( ) ) ;
}
}
public static void main (String args []) throws Exception {
ocx test = new ocx ();
}
}
------ Solution ----------------------------------- ---------
dll modulation method may be similar , the compiler generates stubs , agent. You can also use the OBJECT classid = "clsid: CAFEEFAC-0015-0000-0007-ABCDEFFEDCBA> This way calling
------ For reference only ------------- --------------------------
reference to the comments in the code section
------ For reference only ---- -----------------------------------
DispatchEvents events = new DispatchEvents (testOcx, new KeyVoteA ());
/ / ocx event returned to the java class parameters to obtain
public void KeyVote (Variant [] args) {
System.out.println ("args [0] [" + args [0]. getInt ());
System.out.println ("args [1] [" + args [1]. getInt ());
System.out.println ("args [2] [" + args [2]. getString ());
}
red font can understand
------ For reference only ----------------------------- ----------
Thank you god !
------ For reference only -------------------------------------- -
this way simply did not respond
------ For reference only -------------------------- -------------
jacob nine consecutive event listener to listen less , and after a period of time to wait before they can return to continue to return , is swollen thing ah
- ---- For reference only ---------------------------------------
< br /> upstairs how big God is listening ? Can be attached demo code does not ?
------ For reference only -------------------------------------- -
brethren, I have such a problem but also look advice twelve , QQ: 97604448
------ For reference only ------------- --------------------------
brethren, I have such a problem but also look advice twelve , QQ: 97604448
brother, I would not , did not do it , then gave up, which may require JAVA development and OCX development engineers jointly developed between the FBI tests , otherwise unsupported mismatch can not do this forever .
没有评论:
发表评论