- // Create the main frame window
- frame = new MyFrame(NULL, "Client", wxPoint(400, 0), wxSize(400, 300));
-
- // Give it an icon
- frame->SetIcon(wxICON(mondrian));
+ // service name (DDE classes) or port number (TCP/IP based classes)
+ wxString service = IPC_SERVICE;
+
+ // ignored under DDE, host name in TCP/IP based classes
+ wxString hostName = _T("localhost");
+
+ if (argc > 1)
+ service = argv[1];
+ if (argc > 2)
+ hostName = argv[2];
+
+ // Create a new client
+ my_client = new MyClient;
+
+ // suppress the log messages from MakeConnection()
+ {
+ wxLogNull nolog;
+ the_connection = (MyConnection *)
+ my_client->MakeConnection(hostName, service, IPC_TOPIC);
+
+ while ( !the_connection )
+ {
+ if ( wxMessageBox(_T("Failed to make connection to server.\nRetry?"),
+ _T("Client Demo Error"),
+ wxICON_ERROR | wxYES_NO | wxCANCEL ) != wxYES )
+ {
+ // no server
+ return FALSE;
+ }
+
+ the_connection = (MyConnection *)my_client->MakeConnection(hostName, service, _T("IPC TEST"));
+ }
+ }
+
+ if (!the_connection->StartAdvise(IPC_ADVISE_NAME))
+ wxMessageBox(_T("StartAdvise failed"), _T("Client Demo Error"));
+
+ // Create the main frame window
+ (new MyFrame(NULL, _T("Client")))->Show(TRUE);