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

📄 xselinput.cpp

📁 超声影像工作站系统可与各种型号的B超、彩超连接
💻 CPP
字号:
// XSelInput.cpp : implementation file
//

#include "stdafx.h"
#include "Bxt.h"
#include "XSelInput.h"
//#include "dsprpt2.h"
//#include "report2.h"
//#include "daoabbr.h"
#include "clipboard.h"
#include "Report.h"
#include "BxtDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// XSelInput dialog


XSelInput::XSelInput(int x, int length, int mx, int my, int selid, CWnd* pParent /*=NULL*/)
	: CDialog(XSelInput::IDD, pParent)
{
	parentx = x;
	len = length;
	movex = mx;
	movey = my;
	selID = selid;
	//{{AFX_DATA_INIT(XSelInput)
	m_sel = _T("");
	//}}AFX_DATA_INIT
}


void XSelInput::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(XSelInput)
	DDX_Control(pDX, IDC_COMBO1, m_combo);
	DDX_CBString(pDX, IDC_COMBO1, m_sel);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(XSelInput, CDialog)
	//{{AFX_MSG_MAP(XSelInput)
	ON_CBN_EDITCHANGE(IDC_COMBO1, OnEditchangeCombo1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// XSelInput message handlers


void XSelInput::OnOK()
{
	//if(m_sel.GetText()
	if(m_combo.GetCurSel()==CB_ERR) m_combo.SetCurSel(0);
	UpdateData(true);
	//HGLOBAL mm;
	//mm=GlobalAlloc(GMEM_MOVEABLE & GMEM_DDESHARE,100);
	//while (m_sel.GetLength()<len)
	//{
	//	m_sel = _T(" ") + m_sel;
	//}
	//AfxMessageBox(m_sel);
	CClipboard::SetText(m_sel.GetBuffer(100));

	/*sprintf((char*)mm,"%s",m_sel);
	::OpenClipboard(NULL);
	if(SetClipboardData(CF_TEXT,mm)==NULL) AfxMessageBox("Set Faile!");
	CloseClipboard();*/
//	if (parentx==1) 
//	{
		Report *m	= ((CBxtDlg *)AfxGetMainWnd())->report;
//	Report *m=(Report*)GetParent();
		m->m_rich.Paste();
//	}
//	else
//	{
//		Report2* mr=(Report2*)GetParent();
//		mr->m_report.Paste();
//	}

	//GlobalFree(mm);	
	CDialog::OnOK();	
	DestroyWindow();
}

void XSelInput::OnCancel()
{
	CDialog::OnOK();	
	DestroyWindow();
}

BOOL XSelInput::OnInitDialog() 
{
	CDialog::OnInitDialog();

    SetWindowPos(NULL,movex,movey,0,0,SWP_NOSIZE);	
	/*
	CDAOABBR abr;
	char mx[100];
	//ltoa(selID);
	sprintf(mx,"select * from tblabbr where id=%d",selID);
	//CString msql=_T("select * from tblabbr where id")+selID;
	abr.Open(dbOpenDynaset,mx);
	while (!abr.IsEOF())
	{
		m_combo.AddString(abr.m_Name);
		abr.MoveNext();
	}
	abr.Close();
	*/
	FillCombo();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void XSelInput::OnEditchangeCombo1() 
{
	//if (selID>0) return;
	
	HENV	henv;
	HDBC	hdbc;
	HSTMT	hstmt;

	SQLAllocEnv(&henv);
	SQLAllocConnect(henv,&hdbc);
	SQLConnect(hdbc,(unsigned char *)"BXX",SQL_NTS,NULL,0,NULL,0);
	SQLAllocStmt(hdbc,&hstmt);

	SQLFreeStmt(hstmt,SQL_CLOSE);
	SQLFreeStmt(hstmt,SQL_CLOSE);
	char ts[68000];
	RETCODE rt;
	SDWORD cbValue;
	//sprintf(ts,"SELECT NAME FROM TBLABBR WHERE ID=%d",selID);
	UpdateData();
	if(selID>0)
		sprintf(ts,"select DISTINCT * from tblabbr where id<1 and abbr like '%s%%' and id=%d",m_sel,selID);
	else
		sprintf(ts,"select DISTINCT * from tblabbr where id<1 and abbr like '%s%%'",m_sel);

	rt	= SQLExecDirect(hstmt, (unsigned char *)ts, SQL_NTS);
	CString field;
	
	//m_combo.ResetContent();
	while(m_combo.DeleteString(0)>=0);
	for(;;)
	{
		rt	= SQLFetch(hstmt);
		if (rt != SQL_SUCCESS && rt != SQL_SUCCESS_WITH_INFO) break;
		rt	= SQLGetData(hstmt,2,SQL_C_CHAR,ts,sizeof(ts),&cbValue);
		if (rt != SQL_SUCCESS && rt != SQL_SUCCESS_WITH_INFO) break;
		field	= ts;
		field.TrimLeft();
		field.TrimRight();
		m_combo.AddString(field);
	}

//	CString xtemp;
//	xtemp	= ts;

//	EDITSTREAM es = {(DWORD)&xtemp, 0, EditStreamCallBack};

//	m_rich.StreamIn(SF_RTF, es);

	SQLFreeStmt(hstmt,SQL_DROP);
	SQLDisconnect(hdbc);
	SQLFreeConnect(hdbc);
	SQLFreeEnv(henv);
	
	/*CDAOABBR abr;
	char mx[100];
	//ltoa(selID);
	UpdateData();
	//m_combo.Clear();
	while(m_combo.DeleteString(0)>=0);
	if(selID>0)
		sprintf(mx,"select DISTINCT * from tblabbr where id<1 and abbr like '%s*' and id=%d",m_sel,selID);
	else
		sprintf(mx,"select DISTINCT * from tblabbr where id<1 and abbr like '%s*'",m_sel);
	//CString msql=_T("select * from tblabbr where id")+selID;
	//AfxMessageBox(mx);
	abr.Open(dbOpenDynaset,mx);
	while (!abr.IsEOF())
	{
		m_combo.AddString(abr.m_Name);
		abr.MoveNext();
	}
	abr.Close();
	*/
}

void XSelInput::FillCombo()
{
	HENV	henv;
	HDBC	hdbc;
	HSTMT	hstmt;

	SQLAllocEnv(&henv);
	SQLAllocConnect(henv,&hdbc);
	SQLConnect(hdbc,(unsigned char *)"BXX",SQL_NTS,NULL,0,NULL,0);
	SQLAllocStmt(hdbc,&hstmt);

	SQLFreeStmt(hstmt,SQL_CLOSE);
	SQLFreeStmt(hstmt,SQL_CLOSE);
	char ts[68000];
	RETCODE rt;
	SDWORD cbValue;
	sprintf(ts,"SELECT NAME FROM TBLABBR WHERE ID=%d",selID);
	rt	= SQLExecDirect(hstmt, (unsigned char *)ts, SQL_NTS);
	CString field;
	
	m_combo.ResetContent();
	for(;;)
	{
		rt	= SQLFetch(hstmt);
		if (rt != SQL_SUCCESS && rt != SQL_SUCCESS_WITH_INFO) break;
		rt	= SQLGetData(hstmt,1,SQL_C_CHAR,ts,sizeof(ts),&cbValue);
		if (rt != SQL_SUCCESS && rt != SQL_SUCCESS_WITH_INFO) break;
		field	= ts;
		field.TrimLeft();
		field.TrimRight();
		m_combo.AddString(field);
	}

//	CString xtemp;
//	xtemp	= ts;

//	EDITSTREAM es = {(DWORD)&xtemp, 0, EditStreamCallBack};

//	m_rich.StreamIn(SF_RTF, es);

	SQLFreeStmt(hstmt,SQL_DROP);
	SQLDisconnect(hdbc);
	SQLFreeConnect(hdbc);
	SQLFreeEnv(henv);
}

⌨️ 快捷键说明

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