// RandXDlg.cpp : implementation file
//
#include "stdafx.h"
#include "RandX.h"
#include "RandXDlg.h"
#include "CSpreadSheet.h"
#include "Menber.h"
#include "TxtDlg.h"
#include "IntroDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
int m,n; //按组,按人
/////////////////////////////////////////////////////////////////////////////
// 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()
/////////////////////////////////////////////////////////////////////////////
// CRandXDlg dialog
CRandXDlg::CRandXDlg(CWnd* pParent /*=NULL*/)
: CDialog(CRandXDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CRandXDlg)
m_iz = 0;
m_im = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CRandXDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRandXDlg)
DDX_Control(pDX, IDC_STATIC_S, m_static);
DDX_Control(pDX, IDC_LIST, m_AccessList);
DDX_Text(pDX, IDC_EDIT_ZU, m_iz);
DDX_Text(pDX, IDC_EDIT_M, m_im);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRandXDlg, CDialog)
//{{AFX_MSG_MAP(CRandXDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(ID_ABOUT, OnAbout)
ON_BN_CLICKED(IDD_OPEN, OnOpen)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
ON_BN_CLICKED(IDD_SAVE, OnSave)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRandXDlg message handlers
BOOL CRandXDlg::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
((CButton *)GetDlgItem(IDC_RADIO1))->SetCheck(TRUE); //默认方式H1
i_choice=1;
pMenber=NULL;
bQuit=false;
bFirst=true;
bShow=true;
CWnd * pWnd=GetDlgItem(IDC_EDIT_M);
pWnd->EnableWindow(FALSE);
pWnd=GetDlgItem(IDD_SAVE);
pWnd->EnableWindow(FALSE);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CRandXDlg::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 CRandXDlg::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 CRandXDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CRandXDlg::OnAbout()
{
// TODO: Add your control notification handler code here
CAboutDlg * dlg=new CAboutDlg;
dlg->Create(IDD_ABOUTBOX);
CWnd *pWnd=GetDlgItem(IDCANCEL);
CRect rect;
pWnd->GetWindowRect(&rect); //获得父窗口位置
int w,h;
w=rect.left;
h=rect.top;
dlg->ShowWindow(SW_SHOW);
dlg->SetWindowPos(this,w+140,h-20,0,0,SWP_NOSIZE); //SWP_NOSIZE忽略大小cx,cy
MSG msg;
DWORD dwTimeStarted;
dwTimeStarted = ::GetTickCount();
UINT LFactor=2500; //延时时间
while (::GetTickCount() - dwTimeStarted < LFactor)
{
if (PeekMessage(&msg,0,0,0,PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
delete dlg;
}
//////////////////////////////////
//
// 打开Excel文件
//
/////////////////////////////////
void CRandXDlg::OnOpen()
{
CString sname;
sname="Sheet1";
if (bFirst)
{
CIntroDlg idlg;
if (idlg.DoModal()==IDOK)
{
sname=idlg.m_stable;
}
bFirst=false;
}
m_static.StopRoll();
// TODO: Add your control notification handler code here
char szFilter[] = "Excel 文件(*.xls)|*.XLS|All Files(*.*)|*.*||";
CFileDialog Dlg(TRUE,"XLS",NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter,NULL);
if(Dlg.DoModal() == IDOK)
{
CString PathName = Dlg.GetPathName();
CSpreadSheet SS(PathName,sname);
CStringArray Rows, Column;
//清空列表框
m_AccessList.ResetContent();
m_iTotal=SS.GetTotalRows();
if (pMenber!=NULL)
{
pMenber=NULL; //清空
}
pMenber=new CMenber[m_iTotal];
for (int i =1; i <= m_iTotal; i++)
{
// 读取一行
SS.ReadRow(Rows, i);
CString strContents ="";
/* for (int j = 1; j <= Rows.GetSize(); j++)
{
if(j == 1)
strContents = Rows.GetAt(j-1);
else
strContents = strContents + " " + Rows.GetAt(j-1);
}
*/
pMenber[i-1].pName=Rows.GetAt(0);
pMenber[i-1].pNo=Rows.GetAt(1);
pMenber[i-1].pNo.Format("%-13s",pMenber[i-1].pNo);
pMenber[i-1].pName.Format("%-13s",pMenber[i-1].pName);
strContents=pMenber[i-1].pName+" "+pMenber[i-1].pNo;
m_AccessList.AddString(strContents);
}
CWnd * pWnd=GetDlgItem(IDC_STATIC_S);
CString s1;
s1.Format("%s%d%s","共有",m_iTotal,"人");
pWnd->SetWindowText(s1);
m_static.SetText(s1);
}
else //取消
{
CWnd * pWnd=GetDlgItem(IDC_STATIC_S);
pWnd->SetWindowText("请导入Excel表格!");
m_static.SetText("请导入Excel表格!");
}
}
///////////////////////////////////
//
// 执行分组
//
///////////////////////////////////////
void CRandXDlg::OnButton2()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE); //接收数据
m_static.StopRoll();
if (pMenber==NULL)
{
AfxMessageBox(" 请导入Excel数据! ",MB_OK);
return;
}
if ((m_im==0&&m_iz==0)||m_im>m_iTotal||m_iz>m_iTotal||m_im<0||m_iz<0)
{
AfxMessageBox(" 输入有误! \r\n 请重新输入数字! ",MB_OK);
return;
}
else
{
CWnd *pWnd=GetDlgItem(IDD_SAVE);
pWnd->EnableWindow(TRUE);
int i,j; //中间变量
CString s2;
randx=m_iTotal; //随机选取总数
m_s=m_iTotal; //人数标记
int irand; //选取
没有合适的资源?快使用搜索试试~ 我知道了~
MFC对人员随机分组程序代码
共32个文件
h:9个
cpp:7个
bmp:6个
5星 · 超过95%的资源 需积分: 32 85 下载量 149 浏览量
2010-12-12
19:52:10
上传
评论 3
收藏 250KB RAR 举报
温馨提示
可以读取excel数据,导出excel数据 导入Excel人员数据后,对人员进行随机分组
资源推荐
资源详情
资源评论
收起资源包目录
RandX.rar (32个子文件)
RandX
RandX.clw 2KB
StdAfx.cpp 207B
RandX.opt 91KB
RandXDlg.h 2KB
resource.h 1KB
RandX.cpp 2KB
RandX.plg 2KB
IntroDlg.h 1KB
IntroDlg.cpp 2KB
RandX.h 1KB
ColorStatic.h 4KB
ColorStatic.cpp 11KB
CSpreadSheet.h 33KB
Menber.cpp 530B
Menber.h 546B
StdAfx.h 1KB
RandXDlg.cpp 14KB
RandX.dsw 533B
TxtDlg.h 1KB
res
RandX.rc2 397B
RandX.ico 108KB
name_3.bmp 40KB
name_1.bmp 49KB
name2.bmp 144KB
name_2.bmp 49KB
name1.bmp 144KB
name3.bmp 115KB
RandX.dsp 5KB
RandX.rc 8KB
TxtDlg.cpp 984B
RandX.aps 268KB
RandX.ncb 137KB
共 32 条
- 1
gudufuyun
- 粉丝: 80
- 资源: 30
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页