DemoDlg.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // DemoDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "Demo.h"
  5. #include "DemoDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CDemoDlg dialog
  13. CDemoDlg::CDemoDlg(CWnd* pParent /*=NULL*/)
  14. : CResizableDialog(CDemoDlg::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CDemoDlg)
  17. // NOTE: the ClassWizard will add member initialization here
  18. //}}AFX_DATA_INIT
  19. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  20. }
  21. void CDemoDlg::DoDataExchange(CDataExchange* pDX)
  22. {
  23. CResizableDialog::DoDataExchange(pDX);
  24. //{{AFX_DATA_MAP(CDemoDlg)
  25. DDX_Control(pDX, IDC_LIST1, m_ctrlList1);
  26. DDX_Control(pDX, IDC_COMBO1, m_ctrlCombo1);
  27. //}}AFX_DATA_MAP
  28. }
  29. BEGIN_MESSAGE_MAP(CDemoDlg, CResizableDialog)
  30. //{{AFX_MSG_MAP(CDemoDlg)
  31. ON_WM_CREATE()
  32. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  33. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  34. ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
  35. //}}AFX_MSG_MAP
  36. END_MESSAGE_MAP()
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CDemoDlg message handlers
  39. BOOL CDemoDlg::OnInitDialog()
  40. {
  41. CResizableDialog::OnInitDialog();
  42. SetIcon(m_hIcon, TRUE); // Set big icon
  43. SetIcon(m_hIcon, FALSE); // Set small icon
  44. // TODO: Add extra initialization here
  45. AddAnchor(IDOK, TOP_RIGHT);
  46. AddAnchor(IDC_COMBO1, TOP_LEFT, TOP_RIGHT);
  47. AddAnchor(IDC_EDIT1, TOP_LEFT, TOP_RIGHT);
  48. AddAnchor(IDC_LIST1, TOP_RIGHT, BOTTOM_RIGHT);
  49. m_ctrlList1.AddString("a very very very loooong item text");
  50. m_ctrlList1.SetHorizontalExtent(400);
  51. return TRUE; // return TRUE unless you set the focus to a control
  52. }
  53. #ifndef WS_EX_LAYOUTRTL
  54. #pragma message("Please update your Windows header files, get the latest SDK")
  55. #define WS_EX_LAYOUTRTL 0x00400000
  56. #endif
  57. int CDemoDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
  58. {
  59. // ModifyStyleEx(0, WS_EX_LAYOUTRTL);
  60. if (CResizableDialog::OnCreate(lpCreateStruct) == -1)
  61. return -1;
  62. return 0;
  63. }
  64. void CDemoDlg::OnButton1()
  65. {
  66. CString str;
  67. GetDlgItemText(IDC_EDIT1, str);
  68. m_ctrlCombo1.AddString(str);
  69. }
  70. void CDemoDlg::OnButton2()
  71. {
  72. m_ctrlCombo1.ResetContent();
  73. }
  74. void CDemoDlg::OnButton3()
  75. {
  76. CString str;
  77. GetDlgItemText(IDC_EDIT1, str);
  78. m_ctrlCombo1.Dir(0, str);
  79. }