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

📄 syszcdlg.cpp

📁 这是一套学校设备管理系统的源码 里面有树形结构使用的很棒的方法
💻 CPP
字号:
 // syszcdlg.cpp : implementation file
//

#include "stdafx.h"
#include "xxgl.h"
#include "syszcdlg.h"
#include "strt.h"
#include "ext.h"
#include "func.h"

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

Csyszcdlg::Csyszcdlg(CWnd* pParent /*=NULL*/)
	: CDialog(Csyszcdlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(Csyszcdlg)
	m_qczc = 0.0f;
	m_sbzc = 0.0f;
	m_xxmc = _T("");
	m_yqzc = 0.0f;
	m_dh2 = 0.0f;
	m_hx2 = 0.0f;
	m_jsj2 = 0.0f;
	m_lj2 = 0.0f;
	m_qt2 = 0.0f;
	m_sw2 = 0.0f;
	m_yy2 = 0.0f;
	m_zcze = 0.0f;
	m_wl2 = 0.0f;
	//}}AFX_DATA_INIT
  FILE *fpe;

  unsigned char buf[40];
  unsigned char pass[40];
  int l,i,c,j,k,flag;
  unsigned char mask;

  rand_base = 1000;
  fpe = fopen("c:\\xxsbgl\\mima.txt","rb");
  fscanf(fpe,"%s\n%s\n",buf,pass);
  fclose(fpe);
  l = strlen((char *)buf);
  for (i=0;i<l*8;i++){
    c = buf[i/8];
    mask = 1;
    for (j=0;j<i%8;j++)
      mask *= 2;
    code[i] = c & mask;
    if (code[i] != 0)
      code[i] = 1;
  }

  for (i=0;i<1000;i++)
    process_flag[i] = 0;
  flag = 0;
  j = 0;
  while (flag == 0){
    i = find_a_seat(l*8);
    tab[j] = i;
    process_flag[i] = 1;
    j ++;
    if (j == l*8)
      flag = 1;
  }

  for (i=0;i<l*8;i++){
    code6[i] = code[tab[i]];
  }

  for (i=0;i<l*8;i++)
    code[i] = code6[i];

  for (i=0;i<l*8;i++){
    j = i + l%7;
    if (j >= l*8)
      j -= l*8;
    code1[i] = code[j];
  }


  for (i=0;i<l*4;i++){
    code2[i] = code1[2*i+1];
  }


  for (i=0;i<l*8;i++){
    j = i + l%7;
    if (j > l*8)
      j -= l*8;
    code3[i] = code[j];
  }


  for (i=0;i<l*4;i++){
    code4[i] = code3[2*i];
  }


  for (i=0;i<l*4;i++)
    code5[i] = code2[i] ^ code4[i];
/*
  k = 0;
  for (i=0;i<l;i++){
    c = code5[i*4]*8 + code5[i*4+1]*4 + + code5[i*4+2]*2 + + code5[i*4+3];
    if (c < 10)
      c += '0';
    else
      c += 'A' - 10;
    pass[k++] = c;
  }
  pass[k] = 0;
*/
  for (i=0;i<l;i++){
    c = pass[i];
    if (c >= 'A')
      c = c - 'A' + 10;
    else
      c -= '0';
    code5[4*i] = c / 8;
    c = c % 8;
    code5[4*i+1] = c / 4;
    c = c % 4;
    code5[4*i+2] = c / 2;
    code5[4*i+3] = c % 2;
  }

  for (i=0;i<l*4;i++)
    code2[i] = code5[i] ^ code4[i];

  for (i=0;i<l*4;i++){
    code1[2*i+1] = code2[i];
  }

  for (i=0;i<l*8;i++){
    j = i - l%7;
    if (j < 0)
      j = j + l*8;
    code[i] = code1[j];
  }

  for (i=0;i<l*8;i++){
    code6[tab[i]] = code[i];
  }

  for (i=0;i<l*8;i++)
    code[i] = code6[i];

  for (i=0;i<l;i++){
    buf[i] = code[i*8] + code[i*8+1]*2 + code[i*8+2]*4 + code[i*8+3]*8
      + code[i*8+4]*16 + code[i*8+5]*32 + code[i*8+6]*64 + code[i*8+7]*128;
  }

  strcpy(xiaoming,(char *)buf);
  m_xxmc = xiaoming;

  char buf1[20],buf2[20],buf3[20],buf4[20],buf5[20],buf6[20],buf7[20];
  char buf8[20],buf9[20],buf10[20],buf11[20],buf12[20];

  fpe = fopen("c:\\xxsbgl\\syszc.txt","rb");
  if (fpe != NULL){
    fscanf(fpe,"%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",buf1,
		buf2,buf3,buf4,buf5,buf6,buf7,buf8,buf9,buf10,buf11,buf12);
    m_yqzc = atof(buf1);
    m_qczc = atof(buf2);
    m_sbzc = atof(buf3);
    m_zcze = atof(buf4);
    m_wl2 = atof(buf5);
    m_hx2 = atof(buf6);
    m_sw2 = atof(buf7);
    m_lj2 = atof(buf8);
    m_jsj2 = atof(buf9);
    m_dh2 = atof(buf10);
    m_yy2 = atof(buf11);
    m_qt2 = atof(buf12);
	fclose(fpe);
  }
}


void Csyszcdlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Csyszcdlg)
	DDX_Text(pDX, IDC_qczc, m_qczc);
	DDX_Text(pDX, IDC_sbzc, m_sbzc);
	DDX_Text(pDX, IDC_xxmc, m_xxmc);
	DDX_Text(pDX, IDC_yqzc, m_yqzc);
	DDX_Text(pDX, IDC_dh2, m_dh2);
	DDX_Text(pDX, IDC_hx2, m_hx2);
	DDX_Text(pDX, IDC_jsj2, m_jsj2);
	DDX_Text(pDX, IDC_lj2, m_lj2);
	DDX_Text(pDX, IDC_qt2, m_qt2);
	DDX_Text(pDX, IDC_sw2, m_sw2);
	DDX_Text(pDX, IDC_yy2, m_yy2);
	DDX_Text(pDX, IDC_zcze, m_zcze);
	DDX_Text(pDX, IDC_wl2, m_wl2);
	//}}AFX_DATA_MAP
  CBitmap *bitmap;
  CBitmap *bitmap1;
  
  HBITMAP hbitmap;
  HBITMAP hbitmap1;
  
  bitmap = new CBitmap();
  bitmap1 = new CBitmap();


  bitmap->LoadBitmap(IDB_qr);
  bitmap1->LoadBitmap(IDB_qx);


  hbitmap = (*bitmap).operator HBITMAP();
  hbitmap1 = (*bitmap1).operator HBITMAP();

  
  CWnd *wn;
  CWnd *wn1;


  wn = GetDlgItem(IDOK);
  wn1 = GetDlgItem(IDCANCEL);
 // wn2 = GetDlgItem(IDOK3);

  WPARAM wParam;
  LPARAM lParam;
  wParam =  (WPARAM) LOWORD(BS_LEFT | BS_BITMAP); // style 
  lParam =  MAKELPARAM(TRUE, 0);   // redraw flag 
  wn->SendMessage(BM_SETIMAGE, IMAGE_BITMAP,(long)hbitmap);
  wn1->SendMessage(BM_SETIMAGE, IMAGE_BITMAP,(long)hbitmap1);
}


BEGIN_MESSAGE_MAP(Csyszcdlg, CDialog)
	//{{AFX_MSG_MAP(Csyszcdlg)
	ON_EN_CHANGE(IDC_qczc, OnChangeqczc)
	ON_EN_CHANGE(IDC_sbzc, OnChangesbzc)
	ON_EN_CHANGE(IDC_yqzc, OnChangeyqzc)
	ON_EN_CHANGE(IDC_zcze, OnChangezcze)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Csyszcdlg message handlers

void Csyszcdlg::OnOK() 
{
	// TODO: Add extra validation here
  FILE *fpe;
  char buf1[20],buf2[20],buf3[20],buf4[20],buf5[20],buf6[20];
  char buf7[20],buf8[20],buf9[20],buf10[20],buf11[20],buf12[20];

  fpe = fopen("c:\\xxsbgl\\syszc.txt","wb");
  GetDlgItemText(IDC_yqzc,buf1,20);
  GetDlgItemText(IDC_qczc,buf2,20);
  GetDlgItemText(IDC_sbzc,buf3,20);
  GetDlgItemText(IDC_zcze,buf4,20);
  GetDlgItemText(IDC_wl2,buf5,20);
  GetDlgItemText(IDC_hx2,buf6,20);
  GetDlgItemText(IDC_sw2,buf7,20);
  GetDlgItemText(IDC_lj2,buf8,20);
  GetDlgItemText(IDC_jsj2,buf9,20);
  GetDlgItemText(IDC_dh2,buf10,20);
  GetDlgItemText(IDC_yy2,buf11,20);
  GetDlgItemText(IDC_qt2,buf12,20);
  fprintf(fpe,"%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
	  buf1,buf2,buf3,buf4,buf5,buf6,buf7,buf8,buf9,buf10,buf11,buf12);
  fclose(fpe);
	
	
  CDialog::OnOK();
}

void Csyszcdlg::OnChangeqczc() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	float t1,t2,t3,t;
	char buf[20];

	GetDlgItemText(IDC_yqzc,buf,20);
	t1 = atof(buf);
	GetDlgItemText(IDC_qczc,buf,20);
	t2 = atof(buf);
	GetDlgItemText(IDC_sbzc,buf,20);
	t3 = atof(buf);
	t = t1 + t2 + t3 ;
	sprintf(buf,"%.2f",t);
    SetDlgItemText(IDC_zcze,buf);
	
}

void Csyszcdlg::OnChangesbzc() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	float t1,t2,t3,t;
	char buf[20];

	GetDlgItemText(IDC_yqzc,buf,20);
	t1 = atof(buf);
	GetDlgItemText(IDC_qczc,buf,20);
	t2 = atof(buf);
	GetDlgItemText(IDC_sbzc,buf,20);
	t3 = atof(buf);
	t = t1 + t2 + t3 ;
	sprintf(buf,"%.2f",t);
    SetDlgItemText(IDC_zcze,buf);
	
}

void Csyszcdlg::OnChangeyqzc() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	float t1,t2,t3,t;
	char buf[20];

	GetDlgItemText(IDC_yqzc,buf,20);
	t1 = atof(buf);
	GetDlgItemText(IDC_qczc,buf,20);
	t2 = atof(buf);
	GetDlgItemText(IDC_sbzc,buf,20);
	t3 = atof(buf);
	t = t1 + t2 + t3 ;
	sprintf(buf,"%.2f",t);
    SetDlgItemText(IDC_zcze,buf);
	
}

void Csyszcdlg::OnChangezcze() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
}

⌨️ 快捷键说明

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