OptionDlg.cpp
上传用户:szfskj
上传日期:2022-03-28
资源大小:3962k
文件大小:3k
源码类别:

其他游戏

开发平台:

Visual C++

  1. // OptionDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "skyblue_Rect.h"
  5. #include "OptionDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // COptionDlg dialog
  13. COptionDlg::COptionDlg(int m_iArea, int m_iLevel, int m_iBlockStyle,BOOL m_bMusic, BOOL m_bDrawGrid, CWnd* pParent /*=NULL*/)
  14. : CDialog(COptionDlg::IDD, pParent)
  15. {
  16. m_oldArea = m_iArea;
  17. m_oldLevel = m_iLevel;
  18. m_oldBlockSytle = m_iBlockStyle;
  19. m_oldMusic = m_bMusic;
  20. m_oldDrawGrid = m_bDrawGrid;
  21. //{{AFX_DATA_INIT(COptionDlg)
  22. m_bMusic = FALSE;
  23. m_bDrawGrid = FALSE;
  24. //}}AFX_DATA_INIT
  25. }
  26. void COptionDlg::DoDataExchange(CDataExchange* pDX)
  27. {
  28. CDialog::DoDataExchange(pDX);
  29. //{{AFX_DATA_MAP(COptionDlg)
  30. DDX_Check(pDX, IDC_CHECK_GRID, m_bDrawGrid);
  31. DDX_Check(pDX, IDC_CHECK_MUSIC, m_bMusic);
  32. //}}AFX_DATA_MAP
  33. }
  34. BEGIN_MESSAGE_MAP(COptionDlg, CDialog)
  35. //{{AFX_MSG_MAP(COptionDlg)
  36. ON_WM_CREATE()
  37. // NOTE: the ClassWizard will add message map macros here
  38. //}}AFX_MSG_MAP
  39. END_MESSAGE_MAP()
  40. /////////////////////////////////////////////////////////////////////////////
  41. // COptionDlg message handlers
  42. int COptionDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  43. {
  44. if (CDialog::OnCreate(lpCreateStruct) == -1)
  45. return -1;
  46. return 0;
  47. }
  48. BOOL COptionDlg::OnInitDialog() 
  49. {
  50. CDialog::OnInitDialog();
  51. //参传来的参数赋初值 
  52. CComboBox *m_comboArea;
  53. CComboBox *m_comboLevel;
  54. CComboBox *m_comboBlockStyle;
  55. CButton   *m_btnDrawGrid;
  56. CButton   *m_btnMusic;
  57. m_comboArea = (CComboBox *)GetDlgItem(IDC_COMBO_AREA);
  58. m_comboArea -> SetCurSel( m_oldArea );
  59. m_comboLevel = (CComboBox *)GetDlgItem(IDC_COMBO_LEVEL);
  60. m_comboLevel -> SetCurSel( m_oldLevel );
  61. m_comboBlockStyle = (CComboBox *)GetDlgItem(IDC_COMBO_BLOCK_SYTLE);
  62. m_comboBlockStyle -> SetCurSel( m_oldBlockSytle );
  63. m_btnDrawGrid = (CButton *)GetDlgItem(IDC_CHECK_GRID);
  64. m_btnDrawGrid -> SetCheck(m_oldDrawGrid);
  65. m_btnMusic = (CButton *)GetDlgItem(IDC_CHECK_MUSIC);
  66. m_btnMusic -> SetCheck(m_oldMusic);
  67. return TRUE;  // return TRUE unless you set the focus to a control
  68.               // EXCEPTION: OCX Property Pages should return FALSE
  69. }
  70. void COptionDlg::OnOK() 
  71. {
  72. CComboBox *m_comboArea;
  73. CComboBox *m_comboLevel;
  74. CComboBox *m_comboBlockStyle;
  75. m_comboArea = (CComboBox *)GetDlgItem(IDC_COMBO_AREA);
  76. m_comboLevel = (CComboBox *)GetDlgItem(IDC_COMBO_LEVEL);
  77. m_comboBlockStyle = (CComboBox *)GetDlgItem(IDC_COMBO_BLOCK_SYTLE);
  78. m_iArea = m_comboArea -> GetCurSel();
  79. if (m_iArea<0 || m_iArea>3)
  80. m_iArea = 0;
  81. m_iLevel = m_comboLevel -> GetCurSel();
  82. if (m_iLevel<0 || m_iLevel>5)
  83. m_iLevel = 2;
  84. m_iBlockStyle = m_comboBlockStyle -> GetCurSel();
  85. if (m_iBlockStyle<0 || m_iBlockStyle>5)
  86. m_iBlockStyle = 0;
  87. CDialog::OnOK();
  88. }