]>
git.saurik.com Git - wxWidgets.git/blob - samples/ipc/client.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: DDE sample: client
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "connection.h"
14 #define ID_START 10000
15 #define ID_DISCONNECT 10001
16 #define ID_STARTADVISE 10002
18 #define ID_SERVERNAME 10004
19 #define ID_STOPADVISE 10005
21 #define ID_REQUEST 10007
22 #define ID_EXECUTE 10008
23 #define ID_TOPIC 10009
24 #define ID_HOSTNAME 10010
26 // Define a new application
30 class MyApp
: public wxApp
33 virtual bool OnInit();
35 MyFrame
*GetFrame() { return m_frame
; };
42 class MyFrame
: public wxFrame
45 MyFrame(wxFrame
*frame
, const wxString
& title
);
47 void OnExit(wxCommandEvent
& event
);
48 void OnClose(wxCloseEvent
& event
);
49 void EnableControls();
53 wxButton
* GetStart() { return (wxButton
*) FindWindow( ID_START
); }
54 wxChoice
* GetServername() { return (wxChoice
*) FindWindow( ID_SERVERNAME
); }
55 wxChoice
* GetHostname() { return (wxChoice
*) FindWindow( ID_HOSTNAME
); }
56 wxChoice
* GetTopic() { return (wxChoice
*) FindWindow( ID_TOPIC
); }
57 wxButton
* GetDisconnect() { return (wxButton
*) FindWindow( ID_DISCONNECT
); }
58 wxButton
* GetStartAdvise() { return (wxButton
*) FindWindow( ID_STARTADVISE
); }
59 wxButton
* GetStopAdvise() { return (wxButton
*) FindWindow( ID_STOPADVISE
); }
60 wxButton
* GetRequest() { return (wxButton
*) FindWindow( ID_REQUEST
); }
61 wxButton
* GetPoke() { return (wxButton
*) FindWindow( ID_POKE
); }
62 wxButton
* GetExecute() { return (wxButton
*) FindWindow( ID_EXECUTE
); }
63 wxTextCtrl
* GetLog() { return (wxTextCtrl
*) FindWindow( ID_LOG
); }
67 void OnStart( wxCommandEvent
&event
);
68 void OnServername( wxCommandEvent
&event
);
69 void OnHostname( wxCommandEvent
&event
);
70 void OnTopic( wxCommandEvent
&event
);
71 void OnDisconnect( wxCommandEvent
&event
);
72 void OnStartAdvise( wxCommandEvent
&event
);
73 void OnStopAdvise( wxCommandEvent
&event
);
74 void OnExecute(wxCommandEvent
& event
);
75 void OnPoke(wxCommandEvent
& event
);
76 void OnRequest(wxCommandEvent
& event
);
82 class MyConnection
: public MyConnectionBase
85 virtual bool DoExecute(const void *data
, size_t size
, wxIPCFormat format
);
86 virtual const void *Request(const wxString
& item
, size_t *size
= NULL
, wxIPCFormat format
= wxIPC_TEXT
);
87 virtual bool DoPoke(const wxString
& item
, const void* data
, size_t size
, wxIPCFormat format
);
88 virtual bool OnAdvise(const wxString
& topic
, const wxString
& item
, const void *data
, size_t size
, wxIPCFormat format
);
89 virtual bool OnDisconnect();
92 class MyClient
: public wxClient
97 bool Connect(const wxString
& sHost
, const wxString
& sService
, const wxString
& sTopic
);
99 wxConnectionBase
*OnMakeConnection();
100 bool IsConnected() { return m_connection
!= NULL
; };
101 MyConnection
*GetConnection() { return m_connection
; };
104 MyConnection
*m_connection
;