SendDataDlg.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. // SendDataDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "LYFZIPManage.h"
  5. #include "SendDataDlg.h"
  6. #include "ConnectDlg.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. extern HWND g_hSendWnd;
  13. /////////////////////////////////////////////////////////////////////////////
  14. // SendDataDlg dialog
  15. SendDataDlg::SendDataDlg(CWnd* pParent /*=NULL*/)
  16. : CDialog(SendDataDlg::IDD, pParent)
  17. {
  18. //{{AFX_DATA_INIT(SendDataDlg)
  19. // NOTE: the ClassWizard will add member initialization here
  20. //}}AFX_DATA_INIT
  21. pData=NULL;
  22. m_trytimes=0;
  23. }
  24. void SendDataDlg::DoDataExchange(CDataExchange* pDX)
  25. {
  26. CDialog::DoDataExchange(pDX);
  27. //{{AFX_DATA_MAP(SendDataDlg)
  28. // NOTE: the ClassWizard will add DDX and DDV calls here
  29. //}}AFX_DATA_MAP
  30. }
  31. BEGIN_MESSAGE_MAP(SendDataDlg, CDialog)
  32. //{{AFX_MSG_MAP(SendDataDlg)
  33. ON_WM_TIMER()
  34. ON_WM_DESTROY()
  35. ON_WM_CLOSE()
  36. //}}AFX_MSG_MAP
  37. END_MESSAGE_MAP()
  38. /////////////////////////////////////////////////////////////////////////////
  39. // SendDataDlg message handlers
  40. void SendDataDlg::OnOK()
  41. {
  42. // TODO: Add extra validation here
  43. }
  44. void SendDataDlg::OnCancel()
  45. {
  46. // TODO: Add extra cleanup here
  47. }
  48. BOOL SendDataDlg::OnInitDialog()
  49. {
  50. CDialog::OnInitDialog();
  51. // TODO: Add extra initialization here
  52. g_bSendOK=1;
  53. g_hSendWnd=m_hWnd;
  54. SetTimer(1, 100, NULL);
  55. SetTimer(2, 10000, NULL);
  56. return TRUE; // return TRUE unless you set the focus to a control
  57. // EXCEPTION: OCX Property Pages should return FALSE
  58. }
  59. HWND g_hConnectWnd=NULL;
  60. extern BOOL g_bNeedCoon;
  61. void SendDataDlg::OnTimer(UINT nIDEvent)
  62. {
  63. // TODO: Add your message handler code here and/or call default
  64. if(nIDEvent==1)
  65. {
  66. KillTimer(nIDEvent);
  67. ll: if(g_bNeedCoon)
  68. {
  69. CConnectDlg dlg;
  70. dlg.DoModal();
  71. if(g_bSendOK)
  72. g_bNeedCoon=0;
  73. else
  74. return;
  75. }
  76. if(pData)
  77. {
  78. if(g_pMainWnd->ProcessChatMessageRequest((void*)pData, length)==0)
  79. {
  80. g_bNeedCoon=1;
  81. goto ll;
  82. }
  83. }
  84. else if(sql.IsEmpty ())
  85. {
  86. if(g_pMainWnd->ProcessChatMessageRequest(&code, sizeof(BYTE))==0)
  87. {
  88. g_bNeedCoon=1;
  89. goto ll;
  90. }
  91. }
  92. else
  93. {
  94. const char *szDataBuf = sql.GetBuffer(0);
  95. sql.ReleaseBuffer();
  96. if(g_pMainWnd->ProcessChatMessageRequest((void*)szDataBuf, strlen(szDataBuf) + 1)==0)
  97. {
  98. g_bNeedCoon=1;
  99. goto ll;
  100. }
  101. }
  102. g_bSendOK=1;
  103. }
  104. else if(nIDEvent==2)
  105. {
  106. KillTimer(2);
  107. g_bSendOK=0;g_bNeedCoon=1;
  108. if(g_hConnectWnd)
  109. ::SendMessage (g_hConnectWnd, WM_CLOSE, 0, 0);
  110. // MessageBox("fd");
  111. SetTimer(1, 10, NULL);
  112. }
  113. }
  114. void SendDataDlg::OnDestroy()
  115. {
  116. // MessageBox("");
  117. CDialog::OnDestroy();
  118. // TODO: Add your message handler code here
  119. g_hSendWnd=NULL;
  120. }
  121. void SendDataDlg::OnClose()
  122. {
  123. // TODO: Add your message handler code here and/or call default
  124. // MessageBox("close message");
  125. CDialog::OnCancel ();g_hSendWnd=NULL;
  126. }