ConnectDlg - 副本.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. g_hConnectWnd=m_hWnd;
  98. // TODO: Add extra initialization here
  99. SetTimer(1, 100, NULL);
  100. CenterWindow();
  101. return TRUE; // return TRUE unless you set the focus to a control
  102. // EXCEPTION: OCX Property Pages should return FALSE
  103. }
  104. extern void MyGetIPByName(CString &name);
  105. void CConnectDlg::OnTimer(UINT nIDEvent)
  106. {
  107. // TODO: Add your message handler code here and/or call default g_bSendOK
  108. KillTimer(nIDEvent);
  109. if(g_pMainWnd->OnConnect()==0)
  110. {
  111. g_server=g_serverbak;
  112. if(g_server.Find (".ly.com")==-1)MyGetIPByName(g_server);
  113. SetTimer(1, 1000, NULL);
  114. return;
  115. //::Sleep (1000);
  116. }
  117. g_bSendOK=1; g_hConnectWnd=NULL;
  118. CDialog::OnCancel ();
  119. }
  120. void CConnectDlg::OnClose()
  121. {
  122. // TODO: Add your message handler code here and/or call default
  123. KillTimer(1); g_hConnectWnd=NULL;
  124. CDialog::OnCancel ();
  125. }
  126. void CConnectDlg::OnDestroy()
  127. {
  128. g_hConnectWnd=NULL;
  129. if(m_pBk)delete m_pBk;
  130. // TODO: Add your message handler code here
  131. CDialog::OnDestroy();
  132. }
  133. void CConnectDlg::OnPaint()
  134. {
  135. CPaintDC dc(this); // device context for painting
  136. // TODO: Add your message handler code here
  137. if(m_pBk)
  138. {
  139. Graphics graph(dc.GetSafeHdc ());
  140. CRect rc;
  141. GetClientRect (rc);
  142. Rect destinationRect(0,0,rc.Width (), rc.Height ());
  143. graph.SetSmoothingMode(SmoothingModeHighQuality);
  144. graph.DrawImage(m_pBk, destinationRect, rc.left , rc.top ,rc.Width (), rc.Height (),UnitPixel);
  145. }
  146. // Do not call CDialog::OnPaint() for painting messages
  147. }