// 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 }