1999-01-27 05:01:14 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: client.h
|
|
|
|
// Purpose: DDE sample: client
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 25/01/99
|
|
|
|
// Copyright: (c) Julian Smart
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-02-10 18:43:39 -05:00
|
|
|
#include "connection.h"
|
|
|
|
|
2005-09-11 14:31:34 -04:00
|
|
|
#define ID_START 10000
|
|
|
|
#define ID_DISCONNECT 10001
|
|
|
|
#define ID_STARTADVISE 10002
|
|
|
|
#define ID_LOG 10003
|
|
|
|
#define ID_SERVERNAME 10004
|
|
|
|
#define ID_STOPADVISE 10005
|
|
|
|
#define ID_POKE 10006
|
|
|
|
#define ID_REQUEST 10007
|
|
|
|
#define ID_EXECUTE 10008
|
|
|
|
#define ID_TOPIC 10009
|
|
|
|
#define ID_HOSTNAME 10010
|
|
|
|
|
1999-01-27 05:01:14 -05:00
|
|
|
// Define a new application
|
2005-09-11 14:31:34 -04:00
|
|
|
class MyClient;
|
|
|
|
class MyFrame;
|
|
|
|
|
1999-01-27 05:01:14 -05:00
|
|
|
class MyApp: public wxApp
|
|
|
|
{
|
2000-01-15 17:34:29 -05:00
|
|
|
public:
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool OnInit() wxOVERRIDE;
|
|
|
|
virtual int OnExit() wxOVERRIDE;
|
2005-09-11 14:31:34 -04:00
|
|
|
MyFrame *GetFrame() { return m_frame; };
|
|
|
|
|
|
|
|
protected:
|
|
|
|
MyFrame *m_frame;
|
1999-01-27 05:01:14 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// Define a new frame
|
|
|
|
class MyFrame: public wxFrame
|
|
|
|
{
|
2000-01-15 17:34:29 -05:00
|
|
|
public:
|
|
|
|
MyFrame(wxFrame *frame, const wxString& title);
|
1999-01-27 05:01:14 -05:00
|
|
|
|
|
|
|
void OnExit(wxCommandEvent& event);
|
2005-09-11 14:31:34 -04:00
|
|
|
void OnClose(wxCloseEvent& event);
|
2006-01-16 11:09:49 -05:00
|
|
|
void EnableControls();
|
2005-09-11 14:31:34 -04:00
|
|
|
void Disconnect();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
wxButton* GetStart() { return (wxButton*) FindWindow( ID_START ); }
|
|
|
|
wxChoice* GetServername() { return (wxChoice*) FindWindow( ID_SERVERNAME ); }
|
|
|
|
wxChoice* GetHostname() { return (wxChoice*) FindWindow( ID_HOSTNAME ); }
|
|
|
|
wxChoice* GetTopic() { return (wxChoice*) FindWindow( ID_TOPIC ); }
|
|
|
|
wxButton* GetDisconnect() { return (wxButton*) FindWindow( ID_DISCONNECT ); }
|
|
|
|
wxButton* GetStartAdvise() { return (wxButton*) FindWindow( ID_STARTADVISE ); }
|
|
|
|
wxButton* GetStopAdvise() { return (wxButton*) FindWindow( ID_STOPADVISE ); }
|
|
|
|
wxButton* GetRequest() { return (wxButton*) FindWindow( ID_REQUEST ); }
|
|
|
|
wxButton* GetPoke() { return (wxButton*) FindWindow( ID_POKE ); }
|
|
|
|
wxButton* GetExecute() { return (wxButton*) FindWindow( ID_EXECUTE ); }
|
|
|
|
wxTextCtrl* GetLog() { return (wxTextCtrl*) FindWindow( ID_LOG ); }
|
|
|
|
|
|
|
|
MyClient *m_client;
|
|
|
|
|
|
|
|
void OnStart( wxCommandEvent &event );
|
|
|
|
void OnServername( wxCommandEvent &event );
|
|
|
|
void OnHostname( wxCommandEvent &event );
|
|
|
|
void OnTopic( wxCommandEvent &event );
|
|
|
|
void OnDisconnect( wxCommandEvent &event );
|
|
|
|
void OnStartAdvise( wxCommandEvent &event );
|
|
|
|
void OnStopAdvise( wxCommandEvent &event );
|
1999-01-27 05:01:14 -05:00
|
|
|
void OnExecute(wxCommandEvent& event);
|
|
|
|
void OnPoke(wxCommandEvent& event);
|
|
|
|
void OnRequest(wxCommandEvent& event);
|
2000-01-15 17:34:29 -05:00
|
|
|
|
2005-09-11 14:31:34 -04:00
|
|
|
protected:
|
2014-03-30 03:07:55 -04:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
1999-01-27 05:01:14 -05:00
|
|
|
};
|
|
|
|
|
2008-02-10 18:43:39 -05:00
|
|
|
class MyConnection : public MyConnectionBase
|
1999-01-27 05:01:14 -05:00
|
|
|
{
|
2000-01-15 17:34:29 -05:00
|
|
|
public:
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool DoExecute(const void *data, size_t size, wxIPCFormat format) wxOVERRIDE;
|
|
|
|
virtual const void *Request(const wxString& item, size_t *size = NULL, wxIPCFormat format = wxIPC_TEXT) wxOVERRIDE;
|
|
|
|
virtual bool DoPoke(const wxString& item, const void* data, size_t size, wxIPCFormat format) wxOVERRIDE;
|
|
|
|
virtual bool OnAdvise(const wxString& topic, const wxString& item, const void *data, size_t size, wxIPCFormat format) wxOVERRIDE;
|
|
|
|
virtual bool OnDisconnect() wxOVERRIDE;
|
1999-01-27 05:01:14 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
class MyClient: public wxClient
|
|
|
|
{
|
2000-01-15 17:34:29 -05:00
|
|
|
public:
|
2005-09-11 14:31:34 -04:00
|
|
|
MyClient();
|
|
|
|
~MyClient();
|
|
|
|
bool Connect(const wxString& sHost, const wxString& sService, const wxString& sTopic);
|
|
|
|
void Disconnect();
|
2014-03-29 20:02:23 -04:00
|
|
|
wxConnectionBase *OnMakeConnection() wxOVERRIDE;
|
2005-09-11 14:31:34 -04:00
|
|
|
bool IsConnected() { return m_connection != NULL; };
|
|
|
|
MyConnection *GetConnection() { return m_connection; };
|
|
|
|
|
|
|
|
protected:
|
|
|
|
MyConnection *m_connection;
|
1999-01-27 05:01:14 -05:00
|
|
|
};
|