diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2005-08-05 15:53:13 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2005-08-05 15:53:13 +0000 |
commit | b5f94f45983f648b8857f1df7376c68ae7a0adfc (patch) | |
tree | 6a0d781cd9bbaca06b2a68ee2fbffdf97a7da7b2 /cppe/demo/IceE/chat/ChatClientDlg.cpp | |
parent | cleanup. (diff) | |
download | ice-b5f94f45983f648b8857f1df7376c68ae7a0adfc.tar.bz2 ice-b5f94f45983f648b8857f1df7376c68ae7a0adfc.tar.xz ice-b5f94f45983f648b8857f1df7376c68ae7a0adfc.zip |
Some cleanup
Diffstat (limited to 'cppe/demo/IceE/chat/ChatClientDlg.cpp')
-rw-r--r-- | cppe/demo/IceE/chat/ChatClientDlg.cpp | 234 |
1 files changed, 122 insertions, 112 deletions
diff --git a/cppe/demo/IceE/chat/ChatClientDlg.cpp b/cppe/demo/IceE/chat/ChatClientDlg.cpp index 74e7076913f..c9a47be021f 100644 --- a/cppe/demo/IceE/chat/ChatClientDlg.cpp +++ b/cppe/demo/IceE/chat/ChatClientDlg.cpp @@ -7,22 +7,21 @@ // // ********************************************************************** -
-#include "stdafx.h"
-#include "ChatClient.h"
-#include "ChatClientDlg.h"
-#include "ChatConfigDlg.h"
-#include "Router.h"
+ +#include "stdafx.h" +#include "ChatClient.h" +#include "ChatClientDlg.h" +#include "ChatConfigDlg.h" +#include "Router.h" #ifdef ICEE_HAS_ROUTER -
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
+#ifdef _DEBUG +#define new DEBUG_NEW +#endif + CChatClientDlg::CChatClientDlg(const Ice::CommunicatorPtr& communicator, const LogIPtr& log, - CWnd* pParent /*=NULL*/) :
+ CWnd* pParent /*=NULL*/) : CDialog(CChatClientDlg::IDD, pParent), _communicator(communicator), _chat(0), @@ -31,10 +30,10 @@ CChatClientDlg::CChatClientDlg(const Ice::CommunicatorPtr& communicator, const L _password(""), _host(""), _port("10005") -{
- _hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
-}
-
+{ + _hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); +} + void CChatClientDlg::setSession(const Demo::ChatSessionPrx& chat, CString user, CString password, CString host, CString port) @@ -45,45 +44,46 @@ CChatClientDlg::setSession(const Demo::ChatSessionPrx& chat, CString user, CStri _host = host; _port = port; + // + // Create a ping thread to keep the session alive. + // _ping = new SessionPingThread(_chat); _ping->start(); } -void
-CChatClientDlg::DoDataExchange(CDataExchange* pDX)
-{
- CDialog::DoDataExchange(pDX);
-}
-
-BEGIN_MESSAGE_MAP(CChatClientDlg, CDialog)
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- //}}AFX_MSG_MAP
- ON_BN_CLICKED(IDC_CONFIG, OnLogin)
- ON_BN_CLICKED(IDC_SEND, OnSend)
-END_MESSAGE_MAP()
-
-BOOL
-CChatClientDlg::OnInitDialog()
-{
- CDialog::OnInitDialog();
-
- // Set the icon for this dialog. The framework does this automatically
- // when the application's main window is not a dialog
- SetIcon(_hIcon, TRUE); // Set big icon
- SetIcon(_hIcon, FALSE); // Set small icon
-
- //
- // Retrieve the text input edit control.
- //
- _edit = (CEdit*)GetDlgItem(IDC_LOG);
- -
+void +CChatClientDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CChatClientDlg, CDialog) + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + ON_BN_CLICKED(IDC_CONFIG, OnLogin) + ON_BN_CLICKED(IDC_SEND, OnSend) +END_MESSAGE_MAP() + +BOOL +CChatClientDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // Set the icon for this dialog. The framework does this automatically + // when the application's main window is not a dialog + SetIcon(_hIcon, TRUE); // Set big icon + SetIcon(_hIcon, FALSE); // Set small icon + + // + // Retrieve the text input edit control. + // + _edit = (CEdit*)GetDlgItem(IDC_LOG); + // // Retrieve the chat display edit control for // log output. // - CEdit* disp = (CEdit*)GetDlgItem(IDC_LOG2);
+ CEdit* disp = (CEdit*)GetDlgItem(IDC_LOG2); _log->setControl(disp); // @@ -94,66 +94,70 @@ CChatClientDlg::OnInitDialog() disp->EnableWindow(FALSE); ((CButton*)GetDlgItem(IDC_SEND))->EnableWindow(FALSE); - //
+ // // Set the focus to the login button - //
- ((CButton*)GetDlgItem(IDC_LOGIN))->SetFocus();
-
- return FALSE; // return FALSE because we explicitly set the focus
-}
-
-void
-CChatClientDlg::OnCancel()
-{
+ // + ((CButton*)GetDlgItem(IDC_LOGIN))->SetFocus(); + + return FALSE; // return FALSE because we explicitly set the focus +} + +void +CChatClientDlg::OnCancel() +{ _log->setControl(0); - CDialog::OnCancel();
-}
-
-// If you add a minimize button to your dialog, you will need the code below
-// to draw the icon. For MFC applications using the document/view model,
-// this is automatically done for you by the framework.
-
-void
-CChatClientDlg::OnPaint()
-{
-#ifdef _WIN32_WCE
- CDialog::OnPaint();
-#else
- if (IsIconic())
- {
- CPaintDC dc(this); // device context for painting
-
- SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
-
- // Center icon in client rectangle
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
-
- // Draw the icon
- dc.DrawIcon(x, y, _hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
-#endif
-}
-
-// The system calls this function to obtain the cursor to display while the user drags
-// the minimized window.
-HCURSOR
-CChatClientDlg::OnQueryDragIcon()
-{
- return static_cast<HCURSOR>(_hIcon);
-}
-
-void
-CChatClientDlg::OnSend()
-{
+ CDialog::OnCancel(); +} + +// +// If you add a minimize button to your dialog, you will need the code below +// to draw the icon. For MFC applications using the document/view model, +// this is automatically done for you by the framework. +// + +void +CChatClientDlg::OnPaint() +{ +#ifdef _WIN32_WCE + CDialog::OnPaint(); +#else + if (IsIconic()) + { + CPaintDC dc(this); // device context for painting + + SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); + + // Center icon in client rectangle + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + + // Draw the icon + dc.DrawIcon(x, y, _hIcon); + } + else + { + CDialog::OnPaint(); + } +#endif +} + +// +// The system calls this function to obtain the cursor to display while the user drags +// the minimized window. +// +HCURSOR +CChatClientDlg::OnQueryDragIcon() +{ + return static_cast<HCURSOR>(_hIcon); +} + +void +CChatClientDlg::OnSend() +{ // // Get text from the input edit box and forward it // on to the chat server. @@ -185,12 +189,12 @@ CChatClientDlg::OnSend() // Clear text input and reset focus. // _edit->SetWindowText(CString("")); - ((CButton*)GetDlgItem(IDC_LOG))->SetFocus();
-}
+ _edit->SetFocus(); +} -void
-CChatClientDlg::OnLogin()
-{
+void +CChatClientDlg::OnLogin() +{ if(_chat == 0) { // @@ -223,6 +227,9 @@ CChatClientDlg::OnLogin() // if(_chat == 0) { + // + // Logged out: Disable all except Login. + // _edit->EnableWindow(FALSE); ((CButton*)GetDlgItem(IDC_SEND))->EnableWindow(FALSE); (CEdit*)GetDlgItem(IDC_LOG2)->EnableWindow(FALSE); @@ -234,6 +241,9 @@ CChatClientDlg::OnLogin() } else { + // + // Logged in: Enable all and change Login to Logout + // _edit->EnableWindow(TRUE); ((CButton*)GetDlgItem(IDC_SEND))->EnableWindow(TRUE); (CEdit*)GetDlgItem(IDC_LOG2)->EnableWindow(TRUE); @@ -244,6 +254,6 @@ CChatClientDlg::OnLogin() #endif ((CEdit*)GetDlgItem(IDC_LOG))->SetFocus(); } -}
+} -#endif +#endif // ICEE_HAS_ROUTER |