ListDynDialogEx.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // ListDynDialogEx.cpp: implementation of the CListDynDialogEx class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "ListDynDialogEx.h"
  6. #ifdef _DEBUG
  7. #undef THIS_FILE
  8. static char THIS_FILE[]=__FILE__;
  9. #define new DEBUG_NEW
  10. #endif
  11. #define IDC_LIST1 1600
  12. //////////////////////////////////////////////////////////////////////
  13. // Construction/Destruction
  14. //////////////////////////////////////////////////////////////////////
  15. CListDynDialogEx::CListDynDialogEx(CWnd* pParent /*= NULL*/)
  16. : CDynDialogEx(pParent)
  17. {
  18. m_bAddSystemButtons = FALSE;
  19. }
  20. CListDynDialogEx::~CListDynDialogEx()
  21. {
  22. }
  23. BEGIN_MESSAGE_MAP(CListDynDialogEx, CDynDialogEx)
  24. //{{AFX_MSG_MAP(CListDynDialogEx)
  25. ON_LBN_DBLCLK(IDC_LIST1, OnDblclkList)
  26. //}}AFX_MSG_MAP
  27. END_MESSAGE_MAP()
  28. BOOL CListDynDialogEx::OnInitDialog()
  29. {
  30. BOOL bRet = CDynDialogEx::OnInitDialog();
  31. m_lstBox.AddString(_T("First String"));
  32. m_lstBox.AddString(_T("Second String"));
  33. return bRet;
  34. }
  35. int CListDynDialogEx::DoModal()
  36. {
  37. CRect rect(7,7,150,150);
  38. AddDlgControl(_T("LISTBOX"), _T("ListboxText"), STYLE_LISTBOX, EXSTYLE_LISTBOX, &rect, &m_lstBox, IDC_LIST1);
  39. return CDynDialogEx::DoModal();
  40. }
  41. void CListDynDialogEx::OnDblclkList()
  42. {
  43. CString strBuf;
  44. int nIndex = m_lstBox.GetCurSel();
  45. m_lstBox.GetText(nIndex, strBuf);
  46. AfxMessageBox(strBuf);
  47. OnOK();
  48. }