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

📄 sdwpdjdlg.cpp

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

#include "stdafx.h"
#include "xxgl.h"
#include "sdwpdjdlg.h"
#include "math.h"

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

static int cur_focus;
/////////////////////////////////////////////////////////////////////////////
// Csdwpdjdlg dialog
switch_to_english_mode(CWnd *wnd);
switch_to_chinese_mode(CWnd *wnd);
Set_to_item_end(CWnd *wd,int id);

Csdwpdjdlg::Csdwpdjdlg(CWnd* pParent /*=NULL*/)
	: CDialog(Csdwpdjdlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(Csdwpdjdlg)
	m_jswpdj = _T("");
	m_qswpdj = _T("");
	//}}AFX_DATA_INIT
	cur_focus = 0;
}


void Csdwpdjdlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Csdwpdjdlg)
	DDX_Text(pDX, IDC_jswpdj, m_jswpdj);
	DDX_Text(pDX, IDC_qswpdj, m_qswpdj);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(Csdwpdjdlg, CDialog)
	//{{AFX_MSG_MAP(Csdwpdjdlg)
	ON_EN_CHANGE(IDC_jswpdj, OnChangejswpdj)
	ON_EN_CHANGE(IDC_qswpdj, OnChangeqswpdj)
	ON_EN_SETFOCUS(IDC_qswpdj, OnSetfocusqswpdj)
	ON_EN_SETFOCUS(IDC_jswpdj, OnSetfocusjswpdj)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Csdwpdjdlg message handlers

void Csdwpdjdlg::OnChangejswpdj() 
{
	// 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_jswpdj,buf,12);
    l = strlen(buf);
	if (l > 8){
	  buf[8] = 0;
	  SetDlgItemText(IDC_jswpdj,buf);
	  Set_to_item_end(this,IDC_jswpdj);
	  return ;
    }
	if (l > 0){
		for (i=0;i<l;i++){
	      if (((buf[i] < '0')||(buf[i] > '9'))&&(buf[i] != '.')){
		    buf[i] = 0;
	        SetDlgItemText(IDC_jswpdj,buf);
			Set_to_item_end(this,IDC_jswpdj);
		  }
		}
        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_jswpdj,buf);
			    Set_to_item_end(this,IDC_jswpdj);
            } 
        }
	}

}

void Csdwpdjdlg::OnChangeqswpdj() 
{
	// 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_qswpdj,buf,12);
    l = strlen(buf);
	if (l > 8){
	  buf[8] = 0;
	  SetDlgItemText(IDC_qswpdj,buf);
	  Set_to_item_end(this,IDC_qswpdj);
	  return ;
    }
	if (l > 0){
		for (i=0;i<l;i++){
	      if (((buf[i] < '0')||(buf[i] > '9'))&&(buf[i] != '.')){
		    buf[i] = 0;
	        SetDlgItemText(IDC_qswpdj,buf);
			Set_to_item_end(this,IDC_qswpdj);
		  }
		}
        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_qswpdj,buf);
 			    Set_to_item_end(this,IDC_qswpdj);
            } 
        }
	}
}

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

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

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

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

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

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

⌨️ 快捷键说明

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