1 // **********************************************************************
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
8 // **********************************************************************
11 #include "HelloServer.h"
12 #include "HelloServerDlg.h"
19 CHelloServerDlg::CHelloServerDlg(const Ice::CommunicatorPtr
& communicator
, const LogIPtr
& log
,
20 CWnd
* pParent
/*=NULL*/) :
21 CDialog(CHelloServerDlg::IDD
, pParent
), _communicator(communicator
), _log(log
)
23 _hIcon
= AfxGetApp()->LoadIcon(IDR_MAINFRAME
);
27 CHelloServerDlg::DoDataExchange(CDataExchange
* pDX
)
29 CDialog::DoDataExchange(pDX
);
32 BEGIN_MESSAGE_MAP(CHelloServerDlg
, CDialog
)
36 ON_BN_CLICKED(IDC_SHUTDOWN
, OnShutdown
)
37 ON_BN_CLICKED(IDC_CLEAR
, OnClear
)
38 ON_MESSAGE(WM_USER
, OnLog
)
42 CHelloServerDlg::OnInitDialog()
44 CDialog::OnInitDialog();
46 // Set the icon for this dialog. The framework does this automatically
47 // when the application's main window is not a dialog
48 SetIcon(_hIcon
, TRUE
); // Set big icon
49 SetIcon(_hIcon
, FALSE
); // Set small icon
52 // Retrieve the edit control.
54 _edit
= (CEdit
*)GetDlgItem(IDC_LOG
);
55 _log
->setHandle(m_hWnd
);
58 // Set the focus to the shutdown button, so that the text in the log
59 // is not initially highlighted.
61 ((CButton
*)GetDlgItem(IDC_SHUTDOWN
))->SetFocus();
63 return FALSE
; // return FALSE because we explicitly set the focus
67 CHelloServerDlg::OnCancel()
73 // If you add a minimize button to your dialog, you will need the code below
74 // to draw the icon. For MFC applications using the document/view model,
75 // this is automatically done for you by the framework.
78 CHelloServerDlg::OnPaint()
82 CPaintDC
dc(this); // device context for painting
84 SendMessage(WM_ICONERASEBKGND
, reinterpret_cast<WPARAM
>(dc
.GetSafeHdc()), 0);
86 // Center icon in client rectangle
87 int cxIcon
= GetSystemMetrics(SM_CXICON
);
88 int cyIcon
= GetSystemMetrics(SM_CYICON
);
91 int x
= (rect
.Width() - cxIcon
+ 1) / 2;
92 int y
= (rect
.Height() - cyIcon
+ 1) / 2;
95 dc
.DrawIcon(x
, y
, _hIcon
);
103 // The system calls this function to obtain the cursor to display while the user drags
104 // the minimized window.
106 CHelloServerDlg::OnQueryDragIcon()
108 return static_cast<HCURSOR
>(_hIcon
);
112 CHelloServerDlg::OnShutdown()
118 CHelloServerDlg::OnClear()
120 _edit
->SetWindowText(CString(""));
124 CHelloServerDlg::OnLog(WPARAM wParam
, LPARAM lParam
)
126 char* text
= (char*)lParam
;
128 _edit
->SetSel(-1, -1);
129 _edit
->ReplaceSel(CString(text
));