课件管理Dlg.cpp
资源名称:Sequence.rar [点击查看]
上传用户:xaucma
上传日期:2022-07-29
资源大小:2020k
文件大小:8k
源码类别:
数据结构
开发平台:
Visual C++
- // 课件管理Dlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "课件管理.h"
- #include "课件管理Dlg.h"
- #include <iostream.h>
- #include <fstream.h>
- #include "sstream"
- #include<stdlib.h>
- #include<string.h>
- #include "windows.h"
- #include <stdlib.h>
- #include <stdio.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();
- //int a[100];
- int a[7];
- // 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()
- /////////////////////////////////////////////////////////////////////////////
- // CMyDlg dialog
- CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CMyDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CMyDlg)
- m_edit2 = _T("");
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- }
- void CMyDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CMyDlg)
- DDX_Control(pDX, IDC_EDIT3, m_edit3);
- DDX_Control(pDX, IDC_EDIT1, m_edit1);
- DDX_Control(pDX, IDC_COMBO1, m_combo);
- DDX_Text(pDX, IDC_EDIT2, m_edit2);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
- //{{AFX_MSG_MAP(CMyDlg)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMyDlg message handlers
- BOOL CMyDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- m_combo.SetCurSel(0);
- // 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
- return TRUE; // return TRUE unless you set the focus to a control
- }
- void CMyDlg::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 CMyDlg::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 CMyDlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
- void CMyDlg::OnOK()
- {
- // TODO: Add extra validation here
- CString str;
- GetDlgItem(IDC_EDIT2)->GetWindowText(str);
- int s[10];
- //CString str="aa,bb,cc,dd,ee";
- CString strTemp;
- int nIndex=0, nLast=0,i=0;
- int t=0;
- char str1[100]="排序结果为: ";
- while (nIndex != -1)
- {
- nIndex = str.Find(",", nLast);
- if(nIndex != -1)
- {
- strTemp = str.Mid(nLast, nIndex - nLast);
- nLast = nIndex + 1;
- }
- else
- {
- strTemp = str.Mid(nLast, str.GetLength() - nLast);
- }
- //TRACE0(strTemp);
- s[i++]=atoi(strTemp);
- }
- //GetDlgItem(IDC_EDIT3)->SetWindowText((char *)s[0]);
- //static int i=0;
- for(int ia=0;ia<i-1;ia++)
- //Sleep(1000);
- for(int j=0;j<i-ia-1;j++)
- if(s[j]>s[j+1]){
- t=s[j];
- s[j]=s[j+1];
- s[j+1]=t;
- }
- // CDialog::OnOK();
- // GetDlgItem(IDC_EDIT1)->SetWindowText((CString)a[0]);
- //GetDlgItem(IDC_EDIT3)->SetWindowText(str1);
- //for(int s=0;s<=1000;s++);
- for(int z=0;z<i;z++){
- CString myString ;
- myString.Format("%d ",s[z]);
- strcat(str1,myString);
- }
- GetDlgItem(IDC_EDIT3)->SetWindowText(str1);
- }
- void CMyDlg::OnSelchangeCombo1()
- {
- // TODO: Add your control notification handler code here
- int i=m_combo.GetCurSel();
- // TODO: Add extra validation here
- if(i==0){
- CFile file("插入排序.txt",CFile::modeRead);
- char szchar[1000];
- memset(szchar,0,1000);
- file.Read(szchar,1000);
- GetDlgItem(IDC_STATIC1)->SetWindowText(szchar);
- //MessageBox(szchar);
- file.Close();
- GetDlgItem(IDC_EDIT3)->SetWindowText("插入排序举例:");
- }
- if(i==1){
- CFile file("堆排序.txt",CFile::modeRead);
- char szchar[1000];
- memset(szchar,0,1000);
- file.Read(szchar,1000);
- GetDlgItem(IDC_STATIC1)->SetWindowText(szchar);
- //MessageBox(szchar);
- file.Close();
- GetDlgItem(IDC_EDIT3)->SetWindowText("堆排序举例:");
- }
- if(i==2){
- CFile file("归并排序.txt",CFile::modeRead);
- char szchar[1000];
- memset(szchar,0,1000);
- file.Read(szchar,1000);
- GetDlgItem(IDC_STATIC1)->SetWindowText(szchar);
- //MessageBox(szchar);
- file.Close();
- GetDlgItem(IDC_EDIT3)->SetWindowText("归并排序举例:");
- }
- if(i==3){
- CFile file("冒泡排序.txt",CFile::modeRead);
- char szchar[1000];
- memset(szchar,0,1000);
- file.Read(szchar,1000);
- GetDlgItem(IDC_STATIC1)->SetWindowText(szchar);
- //MessageBox(szchar);
- file.Close();
- GetDlgItem(IDC_EDIT3)->SetWindowText("冒泡排序举例:");
- }
- }
- void CMyDlg::OnButton1()
- {//char a[100];
- // TODO: Add your control notification handler code here
- //m_edit3.Clear();
- static int num=0;
- //a[i++]=IDC_EDIT2;
- GetDlgItem(IDC_EDIT2)->GetWindowText(a[num]);
- GetDlgItem(IDC_EDIT3)->SetWindowText("");
- GetDlgItem(IDC_EDIT2)->SetWindowText("");
- //GetDlgItem(IDC_EDIT1)->SetWindowText(a[i-1]);
- for(int j=0;j<=num;j++){
- //GetDlgItem(IDC_EDIT1)->SetWindowText(a[j]);
- //IDC_EDIT1.SetWindowText(num);
- }
- num++;
- }
- void CMyDlg::OnButton2()
- {
- int a[]={2,64,200,100,59,3,1};
- int t=0;
- char str[]=" ";
- //static int i=0;
- for(int i=0;i<7;i++){
- //Sleep(1000);
- for(int j=0;j<7-i;j++)
- if(a[j]>a[j+1]){
- t=a[j];
- a[j]=a[j+1];
- a[j+1]=t;
- }
- // CDialog::OnOK();
- // GetDlgItem(IDC_EDIT1)->SetWindowText((CString)a[0]);
- //GetDlgItem(IDC_EDIT3)->SetWindowText(str);
- //for(int s=0;s<=1000;s++);
- }
- for(int z=0;z<7;z++){
- CString myString ;
- myString.Format("%d ",a[z]);
- strcat(str,myString);
- }
- GetDlgItem(IDC_EDIT3)->SetWindowText(str);
- }
- void CMyDlg::OnCancel()
- {
- // TODO: Add extra cleanup here
- // i=0;
- CDialog::OnCancel();
- }