PropListBoxDlg.cpp
上传用户:liming
上传日期:2022-02-22
资源大小:23k
文件大小:5k
源码类别:

ListView/ListBox

开发平台:

Visual C++

  1. // PropListBoxDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "PropListBox.h"
  5. #include "PropListBoxDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CPropListBoxDlg dialog
  13. CPropListBoxDlg::CPropListBoxDlg(CWnd* pParent /*=NULL*/)
  14. : CDialog(CPropListBoxDlg::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CPropListBoxDlg)
  17. // NOTE: the ClassWizard will add member initialization here
  18. //}}AFX_DATA_INIT
  19. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  20. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  21. }
  22. void CPropListBoxDlg::DoDataExchange(CDataExchange* pDX)
  23. {
  24. CDialog::DoDataExchange(pDX);
  25. //{{AFX_DATA_MAP(CPropListBoxDlg)
  26. DDX_Control(pDX, IDC_PROPLIST, m_propList);
  27. //}}AFX_DATA_MAP
  28. }
  29. BEGIN_MESSAGE_MAP(CPropListBoxDlg, CDialog)
  30. //{{AFX_MSG_MAP(CPropListBoxDlg)
  31. ON_WM_PAINT()
  32. ON_WM_QUERYDRAGICON()
  33. //}}AFX_MSG_MAP
  34. END_MESSAGE_MAP()
  35. /////////////////////////////////////////////////////////////////////////////
  36. // CPropListBoxDlg message handlers
  37. BOOL CPropListBoxDlg::OnInitDialog()
  38. {
  39. CDialog::OnInitDialog();
  40. // Set the icon for this dialog.  The framework does this automatically
  41. //  when the application's main window is not a dialog
  42. SetIcon(m_hIcon, TRUE); // Set big icon
  43. SetIcon(m_hIcon, FALSE); // Set small icon
  44. //Add properties to the property list box
  45. propItem1 = new CPropertyItem("ToolTip Text","",PIT_EDIT,"");
  46. m_propList.AddPropItem(propItem1);
  47. propItem2 = new CPropertyItem("Enabled","true",PIT_COMBO,"true|false|");
  48. m_propList.AddPropItem(propItem2);
  49. propItem3 = new CPropertyItem("Visible","true",PIT_COMBO,"true|false|");
  50. m_propList.AddPropItem(propItem3);
  51. propItem4 = new CPropertyItem("Fore. Color","",PIT_COLOR,"");
  52. m_propList.AddPropItem(propItem4);
  53. propItem5 = new CPropertyItem("Back. Color","",PIT_COLOR,"");
  54. m_propList.AddPropItem(propItem5);
  55. propItem6 = new CPropertyItem("Opaque","false",PIT_COMBO,"true|false|");
  56. m_propList.AddPropItem(propItem6);
  57. propItem7 = new CPropertyItem("Auto. Scroll","true",PIT_COMBO,"true|false|");
  58. m_propList.AddPropItem(propItem7);
  59. propItem8 = new CPropertyItem("Double Buffered","true",PIT_COMBO,"true|false|");
  60. m_propList.AddPropItem(propItem8);
  61. propItem9 = new CPropertyItem("Font","",PIT_FONT,"");
  62. m_propList.AddPropItem(propItem9);
  63. propItem10 = new CPropertyItem("Text","",PIT_EDIT,"");
  64. m_propList.AddPropItem(propItem10);
  65. propItem11 = new CPropertyItem("Horiz. Align","CENTER",PIT_COMBO,"CENTER|LEFT|RIGHT|");
  66. m_propList.AddPropItem(propItem11);
  67. propItem12 = new CPropertyItem("Vert. Align","CENTER",PIT_COMBO,"CENTER|TOP|BOTTOM|");
  68. m_propList.AddPropItem(propItem12);
  69. propItem13 = new CPropertyItem("Icon","",PIT_FILE,"");
  70. m_propList.AddPropItem(propItem13);
  71. propItem14 = new CPropertyItem("Border Painted","",PIT_COMBO,"true|false|");
  72. m_propList.AddPropItem(propItem14);
  73. propItem15 = new CPropertyItem("Fill Content Area","",PIT_COMBO,"true|false|");
  74. m_propList.AddPropItem(propItem15);
  75. propItem16 = new CPropertyItem("Focus Painted","",PIT_COMBO,"true|false|");
  76. m_propList.AddPropItem(propItem16);
  77. propItem17 = new CPropertyItem("Horiz. Text Pos.","RIGHT",PIT_COMBO,"RIGHT|LEFT|CENTER|LEADING|TRAILING|");
  78. m_propList.AddPropItem(propItem17);
  79. return TRUE;  // return TRUE  unless you set the focus to a control
  80. }
  81. // If you add a minimize button to your dialog, you will need the code below
  82. //  to draw the icon.  For MFC applications using the document/view model,
  83. //  this is automatically done for you by the framework.
  84. void CPropListBoxDlg::OnPaint() 
  85. {
  86. if (IsIconic())
  87. {
  88. CPaintDC dc(this); // device context for painting
  89. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  90. // Center icon in client rectangle
  91. int cxIcon = GetSystemMetrics(SM_CXICON);
  92. int cyIcon = GetSystemMetrics(SM_CYICON);
  93. CRect rect;
  94. GetClientRect(&rect);
  95. int x = (rect.Width() - cxIcon + 1) / 2;
  96. int y = (rect.Height() - cyIcon + 1) / 2;
  97. // Draw the icon
  98. dc.DrawIcon(x, y, m_hIcon);
  99. }
  100. else
  101. {
  102. CDialog::OnPaint();
  103. }
  104. }
  105. // The system calls this to obtain the cursor to display while the user drags
  106. //  the minimized window.
  107. HCURSOR CPropListBoxDlg::OnQueryDragIcon()
  108. {
  109. return (HCURSOR) m_hIcon;
  110. }
  111. CPropListBoxDlg::~CPropListBoxDlg()
  112. {
  113. delete propItem1;
  114. delete propItem2;
  115. delete propItem3;
  116. delete propItem4;
  117. delete propItem5;
  118. delete propItem6;
  119. delete propItem7;
  120. delete propItem8;
  121. delete propItem9;
  122. delete propItem10;
  123. delete propItem11;
  124. delete propItem12;
  125. delete propItem13;
  126. delete propItem14;
  127. delete propItem15;
  128. delete propItem16;
  129. delete propItem17;
  130. }