⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 threemotivesurveydlg.cpp

📁 一个按照麦克莱兰德的需要理论编写的员工需要调查软件
💻 CPP
字号:
// ThreeMotiveSurveyDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ThreeMotiveSurvey.h"
#include "ThreeMotiveSurveyDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CThreeMotiveSurveyDlg dialog

CThreeMotiveSurveyDlg::CThreeMotiveSurveyDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CThreeMotiveSurveyDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CThreeMotiveSurveyDlg)
	m_nCurSelect = -1;
	m_strTitle = _T("");
	m_strJudge = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CThreeMotiveSurveyDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CThreeMotiveSurveyDlg)
	DDX_Radio(pDX, IDC_RADIO1, m_nCurSelect);
	DDX_Text(pDX, IDC_STATIC_TITLE, m_strTitle);
	DDX_Text(pDX, IDC_STATIC_JUDGE, m_strJudge);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CThreeMotiveSurveyDlg, CDialog)
	//{{AFX_MSG_MAP(CThreeMotiveSurveyDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON_RESTART, OnRestart)
	ON_BN_CLICKED(IDC_BUTTON_PREP, OnButtonPrep)
	ON_BN_CLICKED(IDC_BUTTON_NEXT, OnButtonNext)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CThreeMotiveSurveyDlg message handlers

BOOL CThreeMotiveSurveyDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	m_strTitle = _T("    本次调查中,你将回答15个问题,每个问题都是你在工作中可能遇到的。\
请你在最能说明自己行为的词组旁边的方框里作上标记。切记:这里没有正确或错误的答案。\
请你坦率地回答所有的问题。");
	HideItem();
	for (int i=0; i<TITLE_MAX; i++)
	{
		m_wScore[i] = 0;
	}

	m_strTitleList[0] = "1、当派给我的工作相当困难时,我尽力而为";
	m_strTitleList[1] = "2、如果让我选择,我愿意在一个集体中工作而不是独自工作";
	m_strTitleList[2] = "3、我追求在一个集体中起到领导的作用";
	m_strTitleList[3] = "4、我努力改进我的工作表现";
	m_strTitleList[4] = "5、我在工作中很注意他人的感情";
	m_strTitleList[5] = "6、我避免左右我周围的人以我的方法看待问题";
	m_strTitleList[6] = "7、我在工作中承担一定风险,努力争取成功";
	m_strTitleList[7] = "8、我喜欢自己干自己的工作而其他人干他们的工作";
	m_strTitleList[8] = "9、我认为自己在组织和指导其他人的工作";
	m_strTitleList[9] = "10、我尽量回避本职以外的责任";
	m_strTitleList[10] = "11、我敢于发表与别人不同的意见";
	m_strTitleList[11] = "12、我在工作中力求更多地控制周围的事情";
	m_strTitleList[12] = "13、我尽力比我的同事工作得更好";
	m_strTitleList[13] = "14、我发现自己与周围的人谈论与业务无关的事情";
	m_strTitleList[14] = "15、当我在一集体中工作时我极力想成为'指挥者'";

	UpdateData(FALSE);
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CThreeMotiveSurveyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CThreeMotiveSurveyDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CThreeMotiveSurveyDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CThreeMotiveSurveyDlg::OnOK() 
{
	// TODO: Add extra validation here
	
// 	CDialog::OnOK();
}

void CThreeMotiveSurveyDlg::OnRestart() 
{
	// TODO: Add your control notification handler code here
	m_strTitle = m_strTitleList[0];
	
	CButton *pButton = (CButton *)GetDlgItem(IDC_RADIO1);
	pButton->ShowWindow(TRUE);
	pButton = (CButton *)GetDlgItem(IDC_RADIO2);
	pButton->ShowWindow(TRUE);
	pButton = (CButton *)GetDlgItem(IDC_RADIO3);
	pButton->ShowWindow(TRUE);
	pButton = (CButton *)GetDlgItem(IDC_RADIO4);
	pButton->ShowWindow(TRUE);
	pButton = (CButton *)GetDlgItem(IDC_RADIO5);
	pButton->ShowWindow(TRUE);
	pButton = (CButton *)GetDlgItem(IDC_RADIO6);
	pButton->ShowWindow(TRUE);
	pButton = (CButton *)GetDlgItem(IDC_RADIO7);
	pButton->ShowWindow(TRUE);
	pButton = (CButton *)GetDlgItem(IDC_BUTTON_PREP);
	pButton->ShowWindow(TRUE);
	pButton = (CButton *)GetDlgItem(IDC_BUTTON_NEXT);
	pButton->ShowWindow(TRUE);
	
	pButton = (CButton *)GetDlgItem(IDC_BUTTON_RESTART);
	SetDlgItemText(IDC_BUTTON_RESTART, "重新开始");

	m_wProblemCount = 1;
	m_nCurSelect = 0; 		

	UpdateData(FALSE);
}

void CThreeMotiveSurveyDlg::OnButtonPrep() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if (!g_bDicOrder[m_wProblemCount-1])
	{
		m_wScore[m_wProblemCount-1] = 7-m_nCurSelect;
	}
	else
	{
		m_wScore[m_wProblemCount-1] = 1+m_nCurSelect;
	}

	if (m_wProblemCount > 1)
	{
		m_wProblemCount --;
	}
	m_strTitle = m_strTitleList[m_wProblemCount-1];
	if (!g_bDicOrder[m_wProblemCount-1])
	{
		m_nCurSelect = 7-m_wScore[m_wProblemCount-1];
	}
	else
	{
		m_nCurSelect = m_wScore[m_wProblemCount-1]-1;
	}

	UpdateData(FALSE);
}

void CThreeMotiveSurveyDlg::OnButtonNext() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if (!g_bDicOrder[m_wProblemCount-1])
	{
		m_wScore[m_wProblemCount-1] = 7-m_nCurSelect;
	}
	else
	{
		m_wScore[m_wProblemCount-1] = 1+m_nCurSelect;
	}
	
	if (m_wProblemCount < 15)
	{
		m_wProblemCount ++;
		m_strTitle = m_strTitleList[m_wProblemCount-1];
		if (!g_bDicOrder[m_wProblemCount-1])
		{
			m_nCurSelect = 7-m_wScore[m_wProblemCount-1];
		}
		else
		{
			m_nCurSelect = m_wScore[m_wProblemCount-1]-1;
		}
	}
	else		//The last step
	{
		HideItem();
		m_strTitle.Empty();
		
		CButton *pButton = (CButton *)GetDlgItem(IDC_BUTTON_RESTART);
		pButton->ShowWindow(FALSE);
		
		m_strResult = "通过对以上问题的分析,你倾向于:\r\n";
		WORD wTotalScore;	
		WORD wType = 0;
		CString sTmp;
		//成就欲
		wTotalScore = 0;
		for (int i=0; i<TITLE_MAX; i+=3)
		{
			wTotalScore += m_wScore[i];
		}

		if (wTotalScore <= LOW_SUCCESS)
		{
			m_strResult += "低成就欲";
			wType |= 0x01<<8;
		}
		else if (wTotalScore >= HIGH_SUCCESS)
		{
			m_strResult += "高成就欲";
			wType |= 0x03<<8;
		}
		else
		{
			m_strResult += "中成就欲";
			wType |= 0x02<<8;
		}
		sTmp.Format("(%d)", wTotalScore);
		m_strResult += sTmp;
		m_strResult += "、";

		//依附欲
		wTotalScore = 0;
		for (i=1; i<TITLE_MAX; i+=3)
		{
			wTotalScore += m_wScore[i];
		}

		if (wTotalScore <= LOW_FOLLOW)
		{
			m_strResult += "低依附欲";
			wType |= 0x01<<4;
		}
		else if (wTotalScore >= HIGH_FOLLOW)
		{
			m_strResult += "高依附欲";
			wType |= 0x03<<4;
		}
		else
		{
			m_strResult += "中依附欲";
			wType |= 0x02<<4;
		}
		sTmp.Format("(%d)", wTotalScore);
		m_strResult += sTmp;
		m_strResult += "、";

		//权力欲
		wTotalScore = 0;
		for (i=2; i<TITLE_MAX; i+=3)
		{
			wTotalScore += m_wScore[i];
		}

		if (wTotalScore <= LOW_POWER)
		{
			m_strResult += "低权力欲";
			wType |= 0x01;
		}
		else if (wTotalScore >= HIGH_POWER)
		{
			m_strResult += "高权力欲";
			wType |= 0x03;
		}
		else
		{
			m_strResult += "中权力欲";
			wType |= 0x02;
		}
		sTmp.Format("(%d)", wTotalScore);
		m_strResult += sTmp;

		m_strResult += "\r\n\r\n你或许是一名优秀的:\r\n";
		for (i=0; i<sizeof(g_wType)/2; i++)
		{
			if (wType == g_wType[i])
			{
				i++;
				break;
			}
		}
		
		m_strResult += g_strType[--i];

		//名词解释
		sTmp.Empty();
		sTmp += "\r\n\r\n\r\n";
		sTmp += "麦克莱兰德的需要理论:\r\n";
		sTmp +=	"成就需要:针对某种高标准,追求卓越,实现有价值的目标的一种需求\r\n";
		sTmp +=	"合群(依附、从属)需要:对亲密的人际关系和友谊(包括社会的接受)的一种需求\r\n";
		sTmp +=	"权力需要:影响和感化其他人的一种欲望";

		CStatic *pText = (CStatic *)GetDlgItem(IDC_STATIC_JUDGE);
		pText->ShowWindow(TRUE);
		m_strJudge = m_strResult+sTmp;
	}	

	UpdateData(FALSE);
}

void CThreeMotiveSurveyDlg::HideItem()
{
	CButton *pButton = (CButton *)GetDlgItem(IDC_RADIO1);
	pButton->ShowWindow(FALSE);
	pButton = (CButton *)GetDlgItem(IDC_RADIO2);
	pButton->ShowWindow(FALSE);
	pButton = (CButton *)GetDlgItem(IDC_RADIO3);
	pButton->ShowWindow(FALSE);
	pButton = (CButton *)GetDlgItem(IDC_RADIO4);
	pButton->ShowWindow(FALSE);
	pButton = (CButton *)GetDlgItem(IDC_RADIO5);
	pButton->ShowWindow(FALSE);
	pButton = (CButton *)GetDlgItem(IDC_RADIO6);
	pButton->ShowWindow(FALSE);
	pButton = (CButton *)GetDlgItem(IDC_RADIO7);
	pButton->ShowWindow(FALSE);
	pButton = (CButton *)GetDlgItem(IDC_BUTTON_PREP);
	pButton->ShowWindow(FALSE);
	pButton = (CButton *)GetDlgItem(IDC_BUTTON_NEXT);
	pButton->ShowWindow(FALSE);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -