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

📄 sdzjedlg.cpp

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

#include "stdafx.h"
#include "xxgl.h"
#include "sdzjedlg.h"
#include "math.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

Csdzjedlg::Csdzjedlg(CWnd* pParent /*=NULL*/)
	: CDialog(Csdzjedlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(Csdzjedlg)
	m_qszje = _T("");
	m_jszje = _T("");
	//}}AFX_DATA_INIT
}


void Csdzjedlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Csdzjedlg)
	DDX_Text(pDX, IDC_qszje, m_qszje);
	DDX_Text(pDX, IDC_jszje, m_jszje);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(Csdzjedlg, CDialog)
	//{{AFX_MSG_MAP(Csdzjedlg)
	ON_EN_CHANGE(IDC_jszje, OnChangejszje)
	ON_EN_CHANGE(IDC_qszje, OnChangeqszje)
	ON_EN_SETFOCUS(IDC_jszje, OnSetfocusjszje)
	ON_EN_SETFOCUS(IDC_qszje, OnSetfocusqszje)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Csdzjedlg message handlers

void Csdzjedlg::OnChangejszje() 
{
	// 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
    char buf[20];
	int l,i,flag,j;
	
	GetDlgItemText(IDC_jszje,buf,12);
    l = strlen(buf);
	if (l > 8){
	  buf[8] = 0;
	  SetDlgItemText(IDC_jszje,buf);
	  Set_to_item_end(this,IDC_jszje);
	  return ;
    }
	if (l > 0){
		for (i=0;i<l;i++){
	      if (((buf[i] < '0')||(buf[i] > '9'))&&(buf[i] != '.')){
		    buf[i] = 0;
	        SetDlgItemText(IDC_jszje,buf);
 			Set_to_item_end(this,IDC_jszje);
		  }
		}
        l = strlen(buf);
		flag = 0;
		for (i=0;i<l;i++){
			if (buf[i] == '.'){
				j = i;
				flag = 1;
				break;
            }
        }
		if (flag == 1){
			if (j < l-3){
				buf[j+3] = 0;
	            SetDlgItemText(IDC_jszje,buf);
 			    Set_to_item_end(this,IDC_jszje);
            } 
        }
	}
	
}

void Csdzjedlg::OnChangeqszje() 
{
	// 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
    char buf[20];
	int l,i,flag,j;
	
	GetDlgItemText(IDC_qszje,buf,12);
    l = strlen(buf);
	if (l > 8){
	  buf[8] = 0;
	  SetDlgItemText(IDC_qszje,buf);
	  Set_to_item_end(this,IDC_qszje);
	  return ;
    }
	if (l > 0){
		for (i=0;i<l;i++){
	      if (((buf[i] < '0')||(buf[i] > '9'))&&(buf[i] != '.')){
		    buf[i] = 0;
	        SetDlgItemText(IDC_qszje,buf);
 			Set_to_item_end(this,IDC_qszje);
		  }
		}
        l = strlen(buf);
		flag = 0;
		for (i=0;i<l;i++){
			if (buf[i] == '.'){
				j = i;
				flag = 1;
				break;
            }
        }
		if (flag == 1){
			if (j < l-3){
				buf[j+3] = 0;
	            SetDlgItemText(IDC_qszje,buf);
 			    Set_to_item_end(this,IDC_qszje);
            } 
        }
	}
	
}

void Csdzjedlg::OnOK() 
{
	// TODO: Add extra validation here
	float bf,ef;
	char buf[20];
	CWnd *wn_qszje;
	CWnd *wn_jszje;
	CWnd *wn_ok;
	CWnd *wn_cur;

	wn_qszje = GetDlgItem(IDC_qszje);
	wn_jszje = GetDlgItem(IDC_jszje);
    wn_ok =  GetDlgItem(IDOK);
	wn_cur = GetFocus();
	if (wn_cur->m_hWnd != wn_ok->m_hWnd){
	  if (cur_focus == 1){
		wn_jszje->SetFocus();
		return;
	  }
    }
	GetDlgItemText(IDC_qszje,buf,20);
	bf = atof(buf);
	GetDlgItemText(IDC_jszje,buf,20);
	ef = atof(buf);
	if ((bf > ef)&&(fabs(bf) > 0.001)&&(fabs(ef) > 0.001)){
		MessageBox("输入的起始数大于结束数,请重新输入.","",MB_OK);
		wn_qszje->SetFocus();
		return;
    }
	CDialog::OnOK();
}

void Csdzjedlg::OnSetfocusjszje() 
{
	// TODO: Add your control notification handler code here
	// TODO: Add your control notification handler code here
	CWnd *wnd;

	wnd = GetDlgItem(IDC_jszje);
    switch_to_english_mode(wnd);
	cur_focus = 2;		
}

void Csdzjedlg::OnSetfocusqszje() 
{
	// TODO: Add your control notification handler code here
	// TODO: Add your control notification handler code here
	CWnd *wnd;

	wnd = GetDlgItem(IDC_qszje);
    switch_to_english_mode(wnd);
	cur_focus = 1;		
}

⌨️ 快捷键说明

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