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

📄 jhcxdlg.cpp

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

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

static int out_flag;
static int cur_focus;
static int num_of_jhs;

Cjhcxdlg::Cjhcxdlg(CWnd* pParent /*=NULL*/)
	: CDialog(Cjhcxdlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(Cjhcxdlg)
	m_gg = _T("");
	m_grfs = _T("");
	m_jfxs = _T("");
	m_jg = _T("");
	m_mc = _T("");
	m_pc = _T("");
	m_rq = _T("");
	m_sl = _T("");
	m_ssbm = _T("");
	//}}AFX_DATA_INIT
	out_flag = 0;
	cur_focus = 0;
	num_of_jhs = 0;
}


void Cjhcxdlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Cjhcxdlg)
	DDX_Text(pDX, IDC_gg, m_gg);
	DDX_CBString(pDX, IDC_grfs, m_grfs);
	DDX_Text(pDX, IDC_jfxs, m_jfxs);
	DDX_Text(pDX, IDC_jg, m_jg);
	DDX_Control(pDX, IDC_jh, m_jh);
	DDX_Text(pDX, IDC_mc, m_mc);
	DDX_Text(pDX, IDC_pc, m_pc);
	DDX_Text(pDX, IDC_rq, m_rq);
	DDX_Text(pDX, IDC_sl, m_sl);
	DDX_CBString(pDX, IDC_ssbm, m_ssbm);
	//}}AFX_DATA_MAP
	if (out_flag == 0){
	  CBitmap *bitmapadd;

	  HBITMAP hbitmapadd;

      bitmapadd= new CBitmap();

	  bitmapadd->LoadBitmap(IDB_tc);

      hbitmapadd= (*bitmapadd).operator HBITMAP();
	
	  CWnd *wnadd;

	  wnadd = GetDlgItem(IDCANCEL);

      WPARAM wParam;
      LPARAM lParam;
      wParam =  (WPARAM) LOWORD(BS_LEFT | BS_BITMAP); // style 
      lParam =  MAKELPARAM(TRUE, 0);   // redraw flag 
      wnadd->SendMessage(BM_SETIMAGE, IMAGE_BITMAP,(long)hbitmapadd);

	    m_jh.SetColWidth(0L,600L);
	    m_jh.SetColWidth(1L,1600L);
	    m_jh.SetColWidth(2L,1800L);
	    m_jh.SetColWidth(4L,1600L);
		m_jh.SetRow(0L);
		m_jh.SetCol(0L);
		m_jh.SetText("批次");
		m_jh.SetCol(1L);
		m_jh.SetText("名称");
		m_jh.SetCol(2L);
		m_jh.SetText("日期");
		m_jh.SetCol(3L);
		m_jh.SetText("规格");
		m_jh.SetCol(4L);
		m_jh.SetText("申请部门");
		m_jh.SetCol(5L);
		m_jh.SetText("数量");
		m_jh.SetCol(6L);
		m_jh.SetText("申请原因");
		m_jh.SetCol(7L);
		m_jh.SetText("计量单位");
		m_jh.SetCol(8L);
		m_jh.SetText("购入方式");
		m_jh.SetCol(9L);
		m_jh.SetText("参考价格");
		m_jh.SetCol(10L);
		m_jh.SetText("经费系数");
        load_jh();		
	}
}


BEGIN_MESSAGE_MAP(Cjhcxdlg, CDialog)
	//{{AFX_MSG_MAP(Cjhcxdlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Cjhcxdlg message handlers

BEGIN_EVENTSINK_MAP(Cjhcxdlg, CDialog)
    //{{AFX_EVENTSINK_MAP(Cjhcxdlg)
	ON_EVENT(Cjhcxdlg, IDC_jh, 69 /* SelChange */, OnSelChangejh, VTS_NONE)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void Cjhcxdlg::OnSelChangejh() 
{
	long l;
	CString str;

	l = m_jh.GetRowSel();
	if ((l > 0)&&(l <= num_of_jhs)){
      m_jh.SetCol(0L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_pc,str.GetBuffer(10));
      m_jh.SetCol(1L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_mc,str.GetBuffer(40));
      m_jh.SetCol(2L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_rq,str.GetBuffer(20));
      m_jh.SetCol(3L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_gg,str.GetBuffer(20));
      m_jh.SetCol(4L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_ssbm,str.GetBuffer(20));
      m_jh.SetCol(5L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_sl,str.GetBuffer(15));
      m_jh.SetCol(6L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_sqyy,str.GetBuffer(20));
      m_jh.SetCol(7L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_jldw,str.GetBuffer(10));
      m_jh.SetCol(8L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_grfs,str.GetBuffer(20));
      m_jh.SetCol(9L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_jg,str.GetBuffer(15));
      m_jh.SetCol(10L);
	  str = m_jh.GetText();
	  SetDlgItemText(IDC_jfxs,str.GetBuffer(10));
	}
}

void Cjhcxdlg::OnCancel() 
{
    out_flag = 1;	
	CDialog::OnCancel();
}

void Cjhcxdlg::load_jh()
{
	FILE *fpe;
	long l,l1,i;

	fpe = fopen("c:\\xxsbgl\\jhsqbzm.dat","rb");
	if (fpe != NULL){
		m_jh.SetRows(1L);
		fseek(fpe,0L,SEEK_END);
		l = ftell(fpe);
		l1 = l;
		fseek(fpe,0L,SEEK_SET);
		l = l/sizeof(jhsqbstrt) + 1;
		if (l > 20)
		  m_jh.SetRows(l);
		else
		  m_jh.SetRows(20L);
		for (i=0;i<l1/sizeof(jhsqbstrt);i++){
	      fread(&(jhsqb.reserve[0]),sizeof(jhsqbstrt),1,fpe);
		  l = i + 1;
          m_jh.SetRow(l);
		  m_jh.SetCol(0L);
		  m_jh.SetText(jhsqb.pc);
		  m_jh.SetCol(1L);
		  m_jh.SetText(jhsqb.mc);
		  m_jh.SetCol(2L);
		  m_jh.SetText(jhsqb.rq);
		  m_jh.SetCol(3L);
		  m_jh.SetText(jhsqb.gg);
		  m_jh.SetCol(4L);
		  m_jh.SetText(jhsqb.ssbm);
		  m_jh.SetCol(5L);
		  m_jh.SetText(jhsqb.sl);
		  m_jh.SetCol(6L);
		  m_jh.SetText(jhsqb.sqyy);
		  m_jh.SetCol(7L);
		  m_jh.SetText(jhsqb.jldw);
		  m_jh.SetCol(8L);
		  m_jh.SetText(jhsqb.grfs);
		  m_jh.SetCol(9L);
		  m_jh.SetText(jhsqb.jg);
		  m_jh.SetCol(10L);
		  m_jh.SetText(jhsqb.jfxs);
		}
		num_of_jhs = l1/sizeof(jhsqbstrt);
		fclose(fpe);
	}
	else{
		m_jh.SetRows(1L);
		m_jh.SetRows(20L);
		num_of_jhs = 0;
	}
}

⌨️ 快捷键说明

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