ConnectDlg.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. // ConnectDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "ConnectDlg.h"
  6. #include "ClientTunnel.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CConnectDlg dialog
  14. CConnectDlg::CConnectDlg(CWnd* pParent /*=NULL*/)
  15. : CDialog(CConnectDlg::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(CConnectDlg)
  18. // NOTE: the ClassWizard will add member initialization here
  19. //}}AFX_DATA_INIT
  20. m_pBk=NULL;
  21. }
  22. void CConnectDlg::DoDataExchange(CDataExchange* pDX)
  23. {
  24. CDialog::DoDataExchange(pDX);
  25. //{{AFX_DATA_MAP(CConnectDlg)
  26. // NOTE: the ClassWizard will add DDX and DDV calls here
  27. //}}AFX_DATA_MAP
  28. }
  29. BEGIN_MESSAGE_MAP(CConnectDlg, CDialog)
  30. //{{AFX_MSG_MAP(CConnectDlg)
  31. ON_WM_TIMER()
  32. ON_WM_CLOSE()
  33. ON_WM_DESTROY()
  34. ON_WM_PAINT()
  35. ON_WM_ERASEBKGND()
  36. //}}AFX_MSG_MAP
  37. END_MESSAGE_MAP()
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CConnectDlg message handlers
  40. BOOL CConnectDlg::OnEraseBkgnd(CDC* pDC)
  41. {
  42. // TODO: Add your message handler code here and/or call default
  43. #ifdef NEW_SKIN
  44. return 1;
  45. #else
  46. return CDialog::OnEraseBkgnd (pDC);
  47. #endif
  48. }
  49. void CConnectDlg::OnOK()
  50. {
  51. // TODO: Add extra validation here
  52. }
  53. void CConnectDlg::OnCancel()
  54. {
  55. // TODO: Add extra cleanup here
  56. }
  57. HWND g_hConnectWnd=NULL;
  58. BOOL CConnectDlg::OnInitDialog()
  59. {
  60. CDialog::OnInitDialog();// CenterWindow(g_pMainWnd);
  61. if(g_bNoConnDlg)
  62. {
  63. SetWindowPos(&wndNoTopMost,0,0,0,0,SWP_HIDEWINDOW);
  64. ModifyStyleEx(WS_EX_APPWINDOW,WS_EX_TOOLWINDOW);
  65. }
  66. #ifdef NEW_SKIN
  67. if(PathFileExists (g_mainpath+"\\ͼƬ\\Á¬½Ó.jpg") && g_bNoConnDlg==0)
  68. ::LoadImageFromBuf (&m_pBk, g_mainpath+"\\ͼƬ\\Á¬½Ó.jpg");
  69. #endif
  70. if(m_pBk)
  71. {
  72. GetDlgItem(IDC_STATIC1)->ShowWindow(SW_HIDE);
  73. GetDlgItem(IDC_STATIC2)->ShowWindow(SW_HIDE);
  74. CRect rc;
  75. GetWindowRect(rc);
  76. rc.right =rc.left +m_pBk->GetWidth();
  77. rc.bottom =rc.top +m_pBk->GetHeight();
  78. MoveWindow(rc);
  79. CenterWindow();
  80. GetClientRect(rc);
  81. CRgn rgn1, rgn2, rgn3;
  82. rgn1.CreateRectRgn (0,0, rc.Width (), rc.Height ());
  83. rgn2.CreateRectRgn (0,0, 6, 6);
  84. rgn3.CreateEllipticRgn(0,0,12,12);
  85. rgn2.CombineRgn (&rgn2, &rgn3, RGN_DIFF);
  86. rgn1.CombineRgn (&rgn1, &rgn2, RGN_DIFF);
  87. rgn2.DeleteObject ();
  88. rgn3.DeleteObject ();
  89. rgn2.CreateRectRgn (rc.Width ()-6,0, rc.Width (), 6);
  90. rgn3.CreateEllipticRgn(rc.Width ()-12,0,rc.Width (),12);
  91. rgn2.CombineRgn (&rgn2, &rgn3, RGN_DIFF);
  92. rgn1.CombineRgn (&rgn1, &rgn2, RGN_DIFF);
  93. rgn2.DeleteObject ();
  94. rgn3.DeleteObject ();
  95. ::SetWindowRgn (m_hWnd, rgn1, 0);
  96. }
  97. m_nconncot=0;
  98. g_hConnectWnd=m_hWnd;
  99. SetTimer(1, 100, NULL);
  100. CenterWindow();
  101. return TRUE;
  102. }
  103. void CConnectDlg::OnTimer(UINT nIDEvent)
  104. {
  105. KillTimer(nIDEvent);
  106. m_nconncot++;
  107. if(g_pMainWnd->OnConnect()==0)
  108. {
  109. if(1)//m_nconncot>=2)
  110. {
  111. // AfxMessageBox("failed");
  112. g_bSendOK=0;
  113. g_hConnectWnd=NULL;
  114. CDialog::OnCancel();
  115. return;
  116. }
  117. else
  118. {
  119. g_server=g_serverbak;
  120. if(g_server.Find (".ly.com")==-1)
  121. MyGetIPByName(g_server);
  122. SetTimer(1, 10, NULL);
  123. return;
  124. }
  125. //::Sleep (1000);
  126. }
  127. g_bSendOK=1;
  128. g_hConnectWnd=NULL;
  129. CDialog::OnCancel ();
  130. }
  131. void CConnectDlg::OnClose()
  132. {
  133. // TODO: Add your message handler code here and/or call default
  134. KillTimer(1); g_hConnectWnd=NULL;
  135. CDialog::OnCancel ();
  136. }
  137. void CConnectDlg::OnDestroy()
  138. {
  139. g_hConnectWnd=NULL;
  140. if(m_pBk)delete m_pBk;
  141. // TODO: Add your message handler code here
  142. CDialog::OnDestroy();
  143. }
  144. void CConnectDlg::OnPaint()
  145. {
  146. CPaintDC dc(this); // device context for painting
  147. // TODO: Add your message handler code here
  148. if(m_pBk)
  149. {
  150. Graphics graph(dc.GetSafeHdc ());
  151. CRect rc;
  152. GetClientRect (rc);
  153. Rect destinationRect(0,0,rc.Width (), rc.Height ());
  154. graph.SetSmoothingMode(SmoothingModeHighQuality);
  155. graph.DrawImage(m_pBk, destinationRect, rc.left , rc.top ,rc.Width (), rc.Height (),UnitPixel);
  156. }
  157. // Do not call CDialog::OnPaint() for painting messages
  158. }