NewNotedlg.cpp
上传用户:hahaxixi
上传日期:2022-04-15
资源大小:1939k
文件大小:3k
源码类别:

手机短信编程

开发平台:

Visual C++

  1. // NewNotedlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "NoteManage.h"
  5. #include "NewNotedlg.h"
  6. #include "Restoredlg.h"
  7. #include "ADOConn.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. #define AW_BLEND                    0x00080000 //淡入淡出
  14. #define AW_HIDE                     0x00010000 //隐藏
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CNewNotedlg dialog
  17. CNewNotedlg::CNewNotedlg(CWnd* pParent /*=NULL*/)
  18. : CDialog(CNewNotedlg::IDD, pParent)
  19. {
  20. //{{AFX_DATA_INIT(CNewNotedlg)
  21. // NOTE: the ClassWizard will add member initialization here
  22. //}}AFX_DATA_INIT
  23. }
  24. void CNewNotedlg::DoDataExchange(CDataExchange* pDX)
  25. {
  26. CDialog::DoDataExchange(pDX);
  27. //{{AFX_DATA_MAP(CNewNotedlg)
  28. // NOTE: the ClassWizard will add DDX and DDV calls here
  29. //}}AFX_DATA_MAP
  30. }
  31. BEGIN_MESSAGE_MAP(CNewNotedlg, CDialog)
  32. //{{AFX_MSG_MAP(CNewNotedlg)
  33. ON_WM_TIMER()
  34. ON_WM_LBUTTONDOWN()
  35. //}}AFX_MSG_MAP
  36. END_MESSAGE_MAP()
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CNewNotedlg message handlers
  39. BOOL CNewNotedlg::OnInitDialog() 
  40. {
  41. CDialog::OnInitDialog();
  42. // TODO: Add extra initialization here
  43. CenterWindow();
  44. DWORD dwStyle = AW_BLEND;
  45. HINSTANCE hInst = LoadLibrary("User32.DLL"); 
  46. typedef BOOL(WINAPI MYFUNC(HWND,DWORD,DWORD));
  47. MYFUNC* AnimateWindow;
  48. AnimateWindow = (MYFUNC *)::GetProcAddress(hInst,"AnimateWindow");
  49. AnimateWindow(this->m_hWnd,1000,dwStyle);
  50. FreeLibrary(hInst);
  51. AddToTable();
  52. SetTimer(1,1000,NULL);
  53. return TRUE;  // return TRUE unless you set the focus to a control
  54.               // EXCEPTION: OCX Property Pages should return FALSE
  55. }
  56. void CNewNotedlg::OnTimer(UINT nIDEvent) 
  57. {
  58. // TODO: Add your message handler code here and/or call default
  59. DWORD dwStyle = AW_BLEND;
  60. HINSTANCE hInst=LoadLibrary("User32.DLL"); 
  61. typedef BOOL(WINAPI MYFUNC(HWND,DWORD,DWORD));
  62. MYFUNC* AnimateWindow;
  63. AnimateWindow=(MYFUNC *)::GetProcAddress(hInst,"AnimateWindow");
  64. AnimateWindow(this->GetSafeHwnd(),1000,AW_HIDE | dwStyle);
  65. FreeLibrary(hInst);
  66. CDialog::OnCancel();
  67. CDialog::OnTimer(nIDEvent);
  68. }
  69. void CNewNotedlg::OnLButtonDown(UINT nFlags, CPoint point) 
  70. {
  71. // TODO: Add your message handler code here and/or call default
  72. KillTimer(1);
  73. CRestoredlg dlg;
  74. dlg.m_Name  = m_Name;
  75. dlg.m_Phone = m_Phone;
  76. dlg.m_Note  = m_Note;
  77. dlg.DoModal();
  78. CDialog::OnCancel();
  79. CDialog::OnLButtonDown(nFlags, point);
  80. }
  81. void CNewNotedlg::AddToTable()
  82. {
  83. CString sql;
  84. sql.Format("select * from tb_phonebook where 电话号码='%s'",m_Phone);
  85. ADOConn m_AdoConn;
  86. m_AdoConn.OnInitADOConn();
  87. m_AdoConn.m_pRecordset = m_AdoConn.GetRecordSet((_bstr_t)sql);
  88. if(!m_AdoConn.m_pRecordset->adoEOF)
  89. {
  90. m_Name = (char*)(_bstr_t)m_AdoConn.m_pRecordset->GetCollect("姓名");
  91. }
  92. else
  93. m_Name = "新号码";
  94. CTime time = CTime::GetCurrentTime();
  95. sql.Format("insert into tb_recvnote(发送人姓名,发送人电话,信息内容,接收时间)values
  96. ('%s','%s','%s','%s')",m_Name,m_Phone,m_Note,time.Format("%y-%m-%d %H:%M:%S"));
  97. m_AdoConn.ExecuteSQL((_bstr_t)sql);
  98. m_AdoConn.ExitConnect();
  99. }