// SendDataDlg2.cpp : implementation file // #include "stdafx.h" #include "ylgl.h" #include "SendDataDlg2.h" #include "ConnectDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern HWND g_hSendWnd; ///////////////////////////////////////////////////////////////////////////// // SendDataDlg2 dialog SendDataDlg2::SendDataDlg2(CWnd* pParent /*=NULL*/) : CDialog(SendDataDlg2::IDD, pParent) { //{{AFX_DATA_INIT(SendDataDlg2) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT pData=NULL; m_trytimes=0; m_pBk=NULL; } void SendDataDlg2::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(SendDataDlg2) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(SendDataDlg2, CDialog) //{{AFX_MSG_MAP(SendDataDlg2) ON_WM_TIMER() ON_WM_DESTROY() ON_WM_CLOSE() ON_WM_PAINT() ON_WM_ERASEBKGND() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // SendDataDlg2 message handlers BOOL SendDataDlg2::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 SendDataDlg2::OnOK() { // TODO: Add extra validation here } void SendDataDlg2::OnCancel() { // TODO: Add extra cleanup here } BOOL SendDataDlg2::OnInitDialog() { CDialog::OnInitDialog();// CenterWindow(g_pMainWnd); m_nconncot=0; 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); 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); } // TODO: Add extra initialization here g_bSendOK=0; g_hSendWnd=m_hWnd; SetTimer(1, 100, NULL); CenterWindow(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } extern HWND g_hConnectWnd; extern BOOL g_bNeedCoon; extern int g_conntype; extern BOOL EncryptFile2(BYTE *buffer, DWORD leng, PCHAR szPassword); void SendDataDlg2::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default if(nIDEvent==1) { KillTimer(nIDEvent); int g_nSendCodetemp=g_nSendCode; ll: if(g_bNeedCoon) { if(g_pMainWnd->OnConnect()==0) { g_bSendOK=0; CDialog::OnCancel(); AfxMessageBox("连接服务器失败!!!", MB_ICONINFORMATION); return; } ::Sleep(1000); } //AfxMessageBox("连接服务器ok", MB_ICONINFORMATION); g_nSendCode=g_nSendCodetemp; if(pData) { if(g_pMainWnd->ProcessChatMessageRequest((void*)pData, length)==0) { g_bNeedCoon=1; goto ll; } } else if(sql.IsEmpty ()) { if(g_pMainWnd->ProcessChatMessageRequest(&code, sizeof(BYTE))==0) { g_bNeedCoon=1; goto ll; } } else { const char *szDataBuf = sql.GetBuffer(0); sql.ReleaseBuffer(); if(g_pMainWnd->ProcessChatMessageRequest((void*)szDataBuf, strlen(szDataBuf) + 1)==0) { g_bNeedCoon=1; goto ll; } } g_bSendOK=1; } } void SendDataDlg2::OnDestroy() { // TODO: Add your message handler code here g_hSendWnd=NULL; if(m_pBk)delete m_pBk; CDialog::OnDestroy(); } void SendDataDlg2::OnClose() { // TODO: Add your message handler code here and/or call default // MessageBox("close message"); CDialog::OnCancel ();g_hSendWnd=NULL; } void SendDataDlg2::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.DrawImage(m_pBk, destinationRect, rc.left , rc.top ,rc.Width (), rc.Height (),UnitPixel); } // Do not call CDialog::OnPaint() for painting messages }