GdiplusDemoDlg.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //Download by http://www.NewXing.com
  2. // GdiplusDemoDlg.cpp : implementation file
  3. //
  4. #include "stdafx.h"
  5. #include "WalkLtDemo.h"
  6. #include "GdiplusDemoDlg.h"
  7. #include "MyCodeDlg.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CGdiplusDemoDlg dialog
  15. CGdiplusDemoDlg::CGdiplusDemoDlg(CWnd* pParent /*=NULL*/)
  16. : CDialog(CGdiplusDemoDlg::IDD, pParent)
  17. {
  18. //{{AFX_DATA_INIT(CGdiplusDemoDlg)
  19. // NOTE: the ClassWizard will add member initialization here
  20. //}}AFX_DATA_INIT
  21. }
  22. void CGdiplusDemoDlg::DoDataExchange(CDataExchange* pDX)
  23. {
  24. CDialog::DoDataExchange(pDX);
  25. //{{AFX_DATA_MAP(CGdiplusDemoDlg)
  26. DDX_Control(pDX, IDC_TREE1, m_ctrlTree);
  27. //}}AFX_DATA_MAP
  28. }
  29. BEGIN_MESSAGE_MAP(CGdiplusDemoDlg, CDialog)
  30. //{{AFX_MSG_MAP(CGdiplusDemoDlg)
  31. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  32. //}}AFX_MSG_MAP
  33. END_MESSAGE_MAP()
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CGdiplusDemoDlg message handlers
  36. extern void FillGdiplusFuns(CTreeCtrl &tree);
  37. BOOL CGdiplusDemoDlg::OnInitDialog()
  38. {
  39. CDialog::OnInitDialog();
  40. FillGdiplusFuns(m_ctrlTree);
  41. return TRUE;
  42. }
  43. void CGdiplusDemoDlg::OnButton1()
  44. {
  45. HTREEITEM h=m_ctrlTree.GetSelectedItem();
  46. if (!h)
  47. {
  48. AfxMessageBox("请选择一演示项");
  49. return;
  50. }
  51. int res = m_ctrlTree.GetItemData(h);
  52. m_index1 = res/0x100;
  53. m_index2 = res&0x00FF;
  54. if (m_index1<1 || m_index2<1)
  55. {
  56. AfxMessageBox("请选择一可演示项");
  57. return;
  58. }
  59. //获取函数的源代码
  60. CString GetGdiplusFunsCode(int index1, int index2);
  61. CMyCodeDlg dlg;
  62. dlg.m_str = GetGdiplusFunsCode(m_index1, m_index2);
  63. dlg.m_title=m_ctrlTree.GetItemText(h);
  64. dlg.DoModal();
  65. }
  66. void CGdiplusDemoDlg::OnOK()
  67. {
  68. UpdateData();
  69. HTREEITEM h=m_ctrlTree.GetSelectedItem();
  70. if (!h)
  71. {
  72. AfxMessageBox("请选择一演示项");
  73. return;
  74. }
  75. int res = m_ctrlTree.GetItemData(h);
  76. m_index1 = res/0x100;
  77. m_index2 = res&0x00FF;
  78. if (m_index1<1 || m_index2<1)
  79. {
  80. AfxMessageBox("请选择一可演示项");
  81. return;
  82. }
  83. CDialog::OnOK();
  84. }