123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- // ConnectDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "ConnectDlg.h"
- #include "ClientTunnel.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CConnectDlg dialog
- CConnectDlg::CConnectDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CConnectDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CConnectDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- m_pBk=NULL;
- }
- void CConnectDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CConnectDlg)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CConnectDlg, CDialog)
- //{{AFX_MSG_MAP(CConnectDlg)
- ON_WM_TIMER()
- ON_WM_CLOSE()
- ON_WM_DESTROY()
- ON_WM_PAINT()
- ON_WM_ERASEBKGND()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CConnectDlg message handlers
- BOOL CConnectDlg::OnEraseBkgnd(CDC* pDC)
- {
- // TODO: Add your message handler code here and/or call default
- #ifdef NEW_SKIN
- return 1;
- #else
- return CDialog::OnEraseBkgnd (pDC);
- #endif
- }
- void CConnectDlg::OnOK()
- {
- // TODO: Add extra validation here
- }
- void CConnectDlg::OnCancel()
- {
- // TODO: Add extra cleanup here
- }
- HWND g_hConnectWnd=NULL;
- BOOL CConnectDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();// CenterWindow(g_pMainWnd);
- if(g_bNoConnDlg)
- {
- SetWindowPos(&wndNoTopMost,0,0,0,0,SWP_HIDEWINDOW);
- ModifyStyleEx(WS_EX_APPWINDOW,WS_EX_TOOLWINDOW);
- }
- #ifdef NEW_SKIN
- if(PathFileExists (g_mainpath+"\\ͼƬ\\Á¬½Ó.jpg") && g_bNoConnDlg==0)
- ::LoadImageFromBuf (&m_pBk, g_mainpath+"\\ͼƬ\\Á¬½Ó.jpg");
- #endif
- if(m_pBk)
- {
- GetDlgItem(IDC_STATIC1)->ShowWindow(SW_HIDE);
- GetDlgItem(IDC_STATIC2)->ShowWindow(SW_HIDE);
- CRect rc;
- GetWindowRect(rc);
- rc.right =rc.left +m_pBk->GetWidth();
- rc.bottom =rc.top +m_pBk->GetHeight();
- MoveWindow(rc);
- CenterWindow();
-
- GetClientRect(rc);
- CRgn rgn1, rgn2, rgn3;
- rgn1.CreateRectRgn (0,0, rc.Width (), rc.Height ());
-
- rgn2.CreateRectRgn (0,0, 6, 6);
- rgn3.CreateEllipticRgn(0,0,12,12);
- rgn2.CombineRgn (&rgn2, &rgn3, RGN_DIFF);
- rgn1.CombineRgn (&rgn1, &rgn2, RGN_DIFF);
- rgn2.DeleteObject ();
- rgn3.DeleteObject ();
-
- rgn2.CreateRectRgn (rc.Width ()-6,0, rc.Width (), 6);
- rgn3.CreateEllipticRgn(rc.Width ()-12,0,rc.Width (),12);
- rgn2.CombineRgn (&rgn2, &rgn3, RGN_DIFF);
- rgn1.CombineRgn (&rgn1, &rgn2, RGN_DIFF);
- rgn2.DeleteObject ();
- rgn3.DeleteObject ();
- ::SetWindowRgn (m_hWnd, rgn1, 0);
- }
- m_nconncot=0;
- g_hConnectWnd=m_hWnd;
- SetTimer(1, 100, NULL);
- CenterWindow();
- return TRUE;
- }
- void CConnectDlg::OnTimer(UINT nIDEvent)
- {
- KillTimer(nIDEvent);
-
- m_nconncot++;
- if(g_pMainWnd->OnConnect()==0)
- {
- if(1)//m_nconncot>=2)
- {
- // AfxMessageBox("failed");
- g_bSendOK=0;
- g_hConnectWnd=NULL;
- CDialog::OnCancel();
- return;
- }
- else
- {
- g_server=g_serverbak;
- if(g_server.Find (".ly.com")==-1)
- MyGetIPByName(g_server);
- SetTimer(1, 10, NULL);
- return;
- }
- //::Sleep (1000);
- }
-
- g_bSendOK=1;
- g_hConnectWnd=NULL;
- CDialog::OnCancel ();
- }
- void CConnectDlg::OnClose()
- {
- // TODO: Add your message handler code here and/or call default
- KillTimer(1); g_hConnectWnd=NULL;
- CDialog::OnCancel ();
- }
- void CConnectDlg::OnDestroy()
- {
- g_hConnectWnd=NULL;
- if(m_pBk)delete m_pBk;
- // TODO: Add your message handler code here
- CDialog::OnDestroy();
- }
- void CConnectDlg::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
-
- // TODO: Add your message handler code here
- if(m_pBk)
- {
- Graphics graph(dc.GetSafeHdc ());
- CRect rc;
- GetClientRect (rc);
- Rect destinationRect(0,0,rc.Width (), rc.Height ());
- graph.SetSmoothingMode(SmoothingModeHighQuality);
- graph.DrawImage(m_pBk, destinationRect, rc.left , rc.top ,rc.Width (), rc.Height (),UnitPixel);
- }
- // Do not call CDialog::OnPaint() for painting messages
- }
|