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

📄 cdwnd.cpp

📁 中国石油二期加油站IC系统后台通讯软件
💻 CPP
字号:
// CdWnd.cpp : implementation file
//

#include "stdafx.h"
#include "Test.h"
#include "CdWnd.h"

#include "interface.h"

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

const int MAX_COPY_DATA = 1024;

CCdWnd* g_pCdWnd;


BOOL UpData(unsigned long data,unsigned long len,unsigned char* buf)
{
	if(g_pCdWnd==NULL)
		return 0;

	return g_pCdWnd->UpData(data,len,buf);
}

/////////////////////////////////////////////////////////////////////////////
// CCdWnd

CCdWnd::CCdWnd()
{
}

CCdWnd::~CCdWnd()
{
}


BEGIN_MESSAGE_MAP(CCdWnd, CWnd)
	//{{AFX_MSG_MAP(CCdWnd)
	ON_WM_COPYDATA()
	ON_WM_DESTROY()
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CCdWnd message handlers

BOOL CCdWnd::PreCreateWindow(CREATESTRUCT& cs) 
{
	ASSERT(cs.lpszClass == NULL);       // must not be specified

	cs.lpszClass = "TConsole";

	WNDCLASS wndcls;
	wndcls.style = CS_HREDRAW | CS_VREDRAW;//CS_DBLCLKS
	wndcls.lpfnWndProc = ::DefWindowProc;
	wndcls.cbClsExtra = 0;
	wndcls.cbWndExtra = 0;
	wndcls.hInstance = AfxGetInstanceHandle();
	wndcls.hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	wndcls.hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
	wndcls.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
	wndcls.lpszMenuName = NULL;
	wndcls.lpszClassName = cs.lpszClass;
	if (!AfxRegisterClass(&wndcls))
		AfxThrowResourceException();

	return TRUE;
}

int CCdWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	g_pCdWnd=this;

	return 0;
}

void CCdWnd::OnDestroy() 
{
	if(g_pCdWnd==NULL)
		return;

	g_pCdWnd=NULL;

	CWnd::OnDestroy();
	
	AfxGetApp()->m_pMainWnd->SendMessage(WM_CLOSE);
	
	// TODO: Add your message handler code here
	
}

BOOL CCdWnd::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct) 
{
	// TODO: Add your message handler code here and/or call default
	DWORD data;
	DWORD len;
	unsigned char buf[MAX_COPY_DATA];
	
	data=pCopyDataStruct->dwData;
	len=pCopyDataStruct->cbData;
	if(len>MAX_COPY_DATA)
		len=MAX_COPY_DATA;
	memcpy(buf,pCopyDataStruct->lpData,len);

	AddCopyData(data,len,buf);

	return DownData(data,len,buf);
}

BOOL CCdWnd::UpData(unsigned long data, unsigned long len, unsigned char *buf)
{
	BOOL ret=0;

	COPYDATASTRUCT cds;
	cds.dwData=data;
	cds.cbData=len;
	cds.lpData=buf;

	AddCopyData(data,len,buf,1);

	HWND hWnd=::FindWindow("Toil_Station",NULL);
	if(hWnd)
		ret=::SendMessage(hWnd,WM_COPYDATA,(WPARAM)m_hWnd,(LPARAM)&cds);

	return ret;
}

⌨️ 快捷键说明

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