Dlg6.cpp
上传用户:tree100901
上传日期:2016-07-12
资源大小:182k
文件大小:3k
源码类别:

外挂编程

开发平台:

Visual C++

  1. // Dlg6.cpp : 实现文件
  2. //
  3. #include "stdafx.h"
  4. #include "WarH.h"
  5. #include "Dlg6.h"
  6. #include "MH.h"
  7. #define ALPHA(n) (n * 255 / 100)
  8. // CDlg6 对话框
  9. IMPLEMENT_DYNAMIC(CDlg6, CDialog)
  10. CDlg6::CDlg6(CWnd* pParent /*=NULL*/)
  11. : CDialog(CDlg6::IDD, pParent)
  12. {
  13. }
  14. CDlg6::~CDlg6()
  15. {
  16. }
  17. void CDlg6::DoDataExchange(CDataExchange* pDX)
  18. {
  19. CDialog::DoDataExchange(pDX);
  20. DDX_Control(pDX, IDC_SLIDER1, m_Alpha);
  21. DDX_Control(pDX, IDC_MEGGAGE, m_Msg);
  22. }
  23. BOOL CDlg6::OnInitDialog()
  24. {
  25. CDialog::OnInitDialog();
  26. m_Alpha.SetRange(0, 100);
  27. m_Alpha.SetPos(80);
  28. m_tooltips.Create(GetDlgItem(IDC_SLIDER1));
  29. m_tooltips.Activate(TRUE);
  30. HWND hWnd = ::AfxGetApp()->m_pMainWnd->m_hWnd;
  31. ::SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(m_hWnd, GWL_EXSTYLE) ^ WS_EX_LAYERED);
  32. ::SetLayeredWindowAttributes(hWnd, 0, ALPHA(m_Alpha.GetPos()), LWA_ALPHA);
  33. return FALSE;
  34. }
  35. BEGIN_MESSAGE_MAP(CDlg6, CDialog)
  36. ON_NOTIFY_EX(TTN_NEEDTEXT, 0, OnToolTipNotify)
  37. ON_WM_HSCROLL()
  38. ON_BN_CLICKED(IDC_MH, &CDlg6::OnBnClickedMh)
  39. ON_WM_CTLCOLOR()
  40. END_MESSAGE_MAP()
  41. // CDlg6 消息处理程序
  42. HBRUSH CDlg6::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  43. {
  44. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  45. // TODO:  在此更改 DC 的任何属性
  46. int nID = pWnd->GetDlgCtrlID();
  47. switch (nID)
  48. {
  49. case IDC_STATIC:
  50. pDC->SetTextColor(RGB(0, 0, 255));
  51. break;
  52. case IDC_STATIC_LOW:
  53. case IDC_STATIC_HIG:
  54. case IDC_STATIC_VER:
  55. pDC->SetTextColor(RGB(255, 0, 0));
  56. break;
  57. }
  58. // TODO:  如果默认的不是所需画笔,则返回另一个画笔
  59. return hbr;
  60. }
  61. void CDlg6::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
  62. {
  63. // TODO: Add your message handler code here and/or call default
  64. CDialog::OnHScroll(nSBCode,nPos,pScrollBar);
  65. CSliderCtrl *pSlidCtrl=(CSliderCtrl*)GetDlgItem(IDC_SLIDER1);
  66. int m_nCur=pSlidCtrl->GetPos();
  67. CString str;
  68. str.Format(_T("%dn"),m_nCur);
  69. TRACE(str);
  70. HWND hWnd = ::AfxGetApp()->m_pMainWnd->m_hWnd;
  71. ::SetLayeredWindowAttributes(hWnd, 0, ALPHA(m_Alpha.GetPos()), LWA_ALPHA);
  72. m_tooltips.Update();  
  73. }
  74. BOOL CDlg6::OnToolTipNotify(UINT id, NMHDR * pNMHDR, LRESULT * pResult)
  75. {
  76.     TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
  77.     UINT nID = pNMHDR->idFrom;
  78.     if (pTTT->uFlags & TTF_IDISHWND)
  79.     {
  80.           // idFrom is actually the HWND of the tool
  81.           nID = ::GetDlgCtrlID((HWND)nID);
  82.           if (nID)
  83.           {
  84.                CString strToolTips;
  85.    strToolTips.Format(_T("Alpha:%d%c"), m_Alpha.GetPos(), '%');
  86.    
  87.                wcscpy(pTTT->lpszText, strToolTips);
  88.                pTTT->hinst = NULL;
  89.                return(TRUE);
  90.            }
  91.     }
  92.     return(FALSE);
  93. }
  94. CListBox* pMsg;
  95. void text(LPCTSTR s)
  96. {
  97. if (pMsg->GetCount() > 100)
  98. pMsg->ResetContent();
  99. pMsg->InsertString(pMsg->GetCount(), s);
  100. }
  101. void CDlg6::OnBnClickedMh()
  102. {
  103. // TODO: 在此添加控件通知处理程序代码
  104. pMsg = &m_Msg;
  105. startMH(text);
  106. }