ICE 3.4.2
[php5-ice-freebsdport.git] / cpp / demo / IcePatch2 / MFC / PatchClient.cpp
blob26119171f185555d97e855849eae42f31303db8f
1 // **********************************************************************
2 //
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
4 //
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
7 //
8 // **********************************************************************
10 #include "stdafx.h"
11 #include "PatchClient.h"
12 #include "PatchClientDlg.h"
14 #ifdef _DEBUG
15 #define new DEBUG_NEW
16 #endif
18 BEGIN_MESSAGE_MAP(CPatchClientApp, CWinApp)
19 ON_COMMAND(ID_HELP, CWinApp::OnHelp)
20 END_MESSAGE_MAP()
22 using namespace std;
24 CPatchClientApp::CPatchClientApp()
26 // Place all significant initialization in InitInstance
29 // The one and only CPatchClientApp object
31 CPatchClientApp theApp;
33 BOOL
34 CPatchClientApp::InitInstance()
36 // InitCommonControls() is required on Windows XP if an application
37 // manifest specifies use of ComCtl32.dll version 6 or later to enable
38 // visual styles. Otherwise, any window creation will fail.
39 InitCommonControls();
41 CWinApp::InitInstance();
44 // Create a communicator.
46 Ice::CommunicatorPtr communicator;
47 try
49 Ice::StringSeq args;
50 for(int i = 0; i < __argc; ++i)
52 args.push_back(IceUtil::wstringToString(__wargv[i]));
54 communicator = Ice::initialize(args);
56 catch(const IceUtil::Exception& ex)
58 ostringstream ostr;
59 ostr << ex;
60 string s = ostr.str();
61 AfxMessageBox(CString(s.c_str()), MB_OK|MB_ICONEXCLAMATION);
62 return FALSE;
65 Ice::PropertiesPtr properties = communicator->getProperties();
66 if(properties->getProperty("IcePatch2.Endpoints").empty())
68 properties->setProperty("IcePatch2.Endpoints", "tcp -h 127.0.0.1 -p 10000");
71 CPatchDlg dlg(communicator);
72 m_pMainWnd = &dlg;
73 dlg.DoModal();
76 // Clean up.
78 try
80 communicator->destroy();
82 catch(const IceUtil::Exception&)
86 // Since the dialog has been closed, return FALSE so that we exit the
87 // application, rather than start the application's message pump.
88 return FALSE;