?? gaokaodlg.cpp
字號(hào):
// gaokaoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "gaokao.h"
#include "gaokaoDlg.h"
#include "jiegou.h" //自己定義的基本數(shù)據(jù)結(jié)構(gòu)
#include "HelpDlg.h" //自定義的幫助對(duì)話框
#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)
virtual void OnOK();
//}}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)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGaokaoDlg dialog
CGaokaoDlg::CGaokaoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CGaokaoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CGaokaoDlg)
m_lsd = _T("");
m_msd = _T("");
m_select = _T("");
m_strEdit = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CGaokaoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGaokaoDlg)
DDX_Control(pDX, IDC_SLIDER1, m_Slider1);
DDX_Control(pDX, IDC_LIST1, m_ListCtrl);
DDX_Text(pDX, IDC_STATICLSD, m_lsd);
DDX_Text(pDX, IDC_STATICselect, m_select);
DDX_Text(pDX, IDC_strEdit, m_strEdit);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CGaokaoDlg, CDialog)
//{{AFX_MSG_MAP(CGaokaoDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_COMMAND(ID_MENUITEM32776, Onshow)
ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
ON_COMMAND(ID_MENUITEM32772, OnLSD)
ON_COMMAND(ID_MENUITEM32773, OnSelect)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
ON_COMMAND(ID_MENUITEM32777, OnMenuitem32777)
ON_COMMAND(ID_MENUITEM32780, OnMenuitem32780)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
ON_WM_HSCROLL()
ON_NOTIFY(NM_OUTOFMEMORY, IDC_SLIDER1, OnOutofmemorySlider1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGaokaoDlg message handlers
BOOL CGaokaoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
LV_COLUMN lvColumn;
lvColumn.mask=LVCF_FMT|LVCF_SUBITEM|LVCF_TEXT|LVCF_WIDTH;
lvColumn.fmt=LVCFMT_LEFT;
lvColumn.cx=60; //設(shè)置列的寬度
lvColumn.iSubItem=0;
lvColumn.pszText="姓名";
m_ListCtrl.InsertColumn(0,&lvColumn);
lvColumn.iSubItem=1;
lvColumn.pszText="語(yǔ)文";
m_ListCtrl.InsertColumn(1,&lvColumn);
lvColumn.pszText="數(shù)學(xué)";
m_ListCtrl.InsertColumn(2,&lvColumn);
lvColumn.pszText="英語(yǔ)";
m_ListCtrl.InsertColumn(3,&lvColumn);
lvColumn.pszText="X科";
m_ListCtrl.InsertColumn(4,&lvColumn);
lvColumn.pszText="綜合";
m_ListCtrl.InsertColumn(5,&lvColumn);
CString str;
int i,j,score,n;
srand(time(NULL));
// n=10+rand()%3;
n=1000;
InitSLList(L,n);
for(i=1;i<=n;i++)
{
for(j=0;j<4;j++)
{
L.r[i].name[j]=65+rand()%26;
}
str.Format("%s",L.r[i].name);
m_ListCtrl.InsertItem(i-1,str);
{
score=rand()%101;
if(score<60) //if在這里是為了提高整體成績(jī),不讓太多成績(jī)低于60分
{
score=rand()%101;
}
L.r[i].keys[j]=score;
str.Format("%d",L.r[i].keys[j]);
m_ListCtrl.SetItemText(i-1,j,str);
}
L.r[i].keys[5]=L.r[i].keys[1]+L.r[i].keys[2]+L.r[i].keys[3]+L.r[i].keys[4];
str.Format("%d",L.r[i].keys[5]);
m_ListCtrl.SetItemText(i-1,j,str);
}
copy=L;
// 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
////////////////////////////////滑塊設(shè)置?。?!初始化
m_Slider1.SetRange(0,10000);
m_Slider1.SetTicFreq(4);
m_Slider1.SetLineSize(1);
m_Slider1.SetPageSize(4);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CGaokaoDlg::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 CGaokaoDlg::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 CGaokaoDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CGaokaoDlg::Onshow()
{
// TODO: Add your command handler code here
CAboutDlg dlg;
dlg.DoModal();
}
void CGaokaoDlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
*pResult = 0;
}
int radio,a=0,b=0,c=0,d=0;
int chosecourse()
{
if( (a+b+c+d) ==0 ) radio = 0; //還沒(méi)有選擇要進(jìn)行排序的關(guān)鍵字
if( a ) radio = 1; //選擇了chinese
if( b ) radio = 2; //選擇了math
if( c ) radio = 3; //選擇了english
if( d ) radio = 4; //選擇了X科
return radio;
}
void CGaokaoDlg::OnLSD()
{
start=clock();
int i,j;
for( i=0 ; i<L.recnum ; i++ ) L.r[i].next=i+1;
L.r[L.recnum].next=0;
i=chosecourse();
if(i==0) MessageBox("請(qǐng)先選擇關(guān)鍵字!!!");
else
{
RadixSort(L,i);
RadixSort(L,5);
m_ListCtrl.DeleteAllItems(); //先清除所有的表現(xiàn)
for(int k=6;k>=0;k--) m_ListCtrl.DeleteColumn(k); //再清除所有的列
LV_COLUMN lvColumn; //設(shè)置列表基本信息 列
lvColumn.mask=LVCF_FMT|LVCF_SUBITEM|LVCF_TEXT|LVCF_WIDTH;
lvColumn.fmt=LVCFMT_LEFT;
lvColumn.cx=60; //設(shè)置列的寬度
lvColumn.iSubItem=0;
lvColumn.pszText="姓名";
m_ListCtrl.InsertColumn(0,&lvColumn);
lvColumn.iSubItem=1;
lvColumn.pszText="語(yǔ)文";
m_ListCtrl.InsertColumn(1,&lvColumn);
lvColumn.pszText="數(shù)學(xué)";
m_ListCtrl.InsertColumn(2,&lvColumn);
lvColumn.pszText="英語(yǔ)";
m_ListCtrl.InsertColumn(3,&lvColumn);
lvColumn.pszText="X科";
m_ListCtrl.InsertColumn(4,&lvColumn);
lvColumn.pszText="綜合";
m_ListCtrl.InsertColumn(5,&lvColumn);
lvColumn.pszText="排名";
m_ListCtrl.InsertColumn(6,&lvColumn);
CString str;
for(k=0,i=L.r[0].next; i; i=L.r[i].next,k++ )
{
str.Format("%s",L.r[i].name);
m_ListCtrl.InsertItem(k,str);
for(j=1;j<=4;j++)
{
str.Format("%d",L.r[i].keys[j]);
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -