ViewDetailDlg.cpp
上传用户:zslianheng
上传日期:2013-04-03
资源大小:946k
文件大小:4k
源码类别:

Linux/Unix编程

开发平台:

Visual C++

  1. /***************************************************************************
  2.  *                                                                         *
  3.  *   This program is free software; you can redistribute it and/or modify  *
  4.  *   it under the terms of the GNU General Public License as published by  *
  5.  *   the Free Software Foundation; either version 2 of the License, or     *
  6.  *   (at your option) any later version.                                   *
  7.  *                                                                         *
  8.  *   copyright            : (C) 2002 by Zhang Yong                         *
  9.  *   email                : z-yong163@163.com                              *
  10.  ***************************************************************************/
  11. // ViewDetailDlg.cpp : implementation file
  12. //
  13. #include "stdafx.h"
  14. #include "myicq.h"
  15. #include "ViewDetailDlg.h"
  16. #include "serversession.h"
  17. #include "icqlink.h"
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CViewDetailDlg
  25. IMPLEMENT_DYNAMIC(CViewDetailDlg, CPropertySheet)
  26. CViewDetailDlg::CViewDetailDlg(uint32 uin)
  27. :CPropertySheet(IDS_VIEW_DETAIL), IcqWindow(WIN_VIEW_DETAIL, uin)
  28. {
  29. contact = icqLink->findContact(uin);
  30. m_psh.dwFlags |= PSH_USEHICON;
  31. m_psh.hIcon = getApp()->m_hIcon;
  32. basicPage.m_uin = uin;
  33. AddPage(&basicPage);
  34. AddPage(&commPage);
  35. AddPage(&miscPage);
  36. }
  37. CViewDetailDlg::~CViewDetailDlg()
  38. {
  39. }
  40. void CViewDetailDlg::enableButtons(BOOL enable)
  41. {
  42. basicPage.GetDlgItem(IDC_REMARK)->EnableWindow(enable);
  43. basicPage.GetDlgItem(IDC_UPDATE)->EnableWindow(enable);
  44. commPage.GetDlgItem(IDC_REMARK)->EnableWindow(enable);
  45. commPage.GetDlgItem(IDC_UPDATE)->EnableWindow(enable);
  46. miscPage.GetDlgItem(IDC_REMARK)->EnableWindow(enable);
  47. miscPage.GetDlgItem(IDC_UPDATE)->EnableWindow(enable);
  48. }
  49. void CViewDetailDlg::setData(IcqContact *c)
  50. {
  51. basicPage.setData(c);
  52. commPage.setData(c);
  53. miscPage.setData(c);
  54. }
  55. void CViewDetailDlg::onUpdateContactReply(IcqContact *c)
  56. {
  57. setData(c);
  58. enableButtons(TRUE);
  59. }
  60. void CViewDetailDlg::onSendError(uint32 seq)
  61. {
  62. myMessageBox(IDS_TIMEOUT_RETRY, IDS_SORRY, this, MB_OK | MB_ICONERROR);
  63. DestroyWindow();
  64. }
  65. BEGIN_MESSAGE_MAP(CViewDetailDlg, CPropertySheet)
  66. //{{AFX_MSG_MAP(CViewDetailDlg)
  67. // NOTE - the ClassWizard will add and remove mapping macros here.
  68. //}}AFX_MSG_MAP
  69. ON_COMMAND(IDC_UPDATE, OnUpdate)
  70. END_MESSAGE_MAP()
  71. BOOL CViewDetailDlg::Create(CWnd *pParentWnd)
  72. {
  73. DWORD dwStyle = WS_SYSMENU | WS_POPUP | WS_CAPTION | DS_MODALFRAME | WS_MINIMIZEBOX;
  74. BOOL res = CPropertySheet::Create(pParentWnd, dwStyle);
  75. int n = GetPageCount();
  76. while (--n >= 0)
  77. SetActivePage(n);
  78. basicPage.enableAll(FALSE);
  79. commPage.enableAll(FALSE);
  80. miscPage.enableAll(FALSE);
  81. if (!contact) {
  82. basicPage.GetDlgItem(IDC_REMARK)->ShowWindow(SW_HIDE);
  83. basicPage.GetDlgItem(IDC_UPDATE)->ShowWindow(SW_HIDE);
  84. basicPage.GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
  85. commPage.GetDlgItem(IDC_REMARK)->ShowWindow(SW_HIDE);
  86. commPage.GetDlgItem(IDC_UPDATE)->ShowWindow(SW_HIDE);
  87. commPage.GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
  88. miscPage.GetDlgItem(IDC_REMARK)->ShowWindow(SW_HIDE);
  89. miscPage.GetDlgItem(IDC_UPDATE)->ShowWindow(SW_HIDE);
  90. miscPage.GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
  91. OnUpdate();
  92. } else {
  93. AddPage(&customPage);
  94. setData(contact);
  95. CString str;
  96. str.LoadString(IDS_UPDATE);
  97. basicPage.GetDlgItem(IDC_UPDATE)->SetWindowText(str);
  98. commPage.GetDlgItem(IDC_UPDATE)->SetWindowText(str);
  99. miscPage.GetDlgItem(IDC_UPDATE)->SetWindowText(str);
  100. }
  101. ShowWindow(SW_NORMAL);
  102. return res;
  103. }
  104. /////////////////////////////////////////////////////////////////////////////
  105. // CViewDetailDlg message handlers
  106. void CViewDetailDlg::OnUpdate()
  107. {
  108. seq = serverSession()->updateContact(uin);
  109. enableButtons(FALSE);
  110. }
  111. void CViewDetailDlg::PostNcDestroy() 
  112. {
  113. delete this;
  114. }