打印图形,是二维条码吗?
我有一段打印字符的示范程序,
void CBarCodeView::OnButton1()
{
// TODO: Add your control notification handler code here
DWORD dwSize;
DWORD dwBytes;
UpdateData(TRUE);
if (!hCom &&
!(gTracesFlags &
TRACES_NO_COM_OUTPUT))
{
hCom = CreateFile (COM_PORT_STRING,
GENERIC_WRITE | GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
if (INVALID_HANDLE_VALUE == hCom)
{
hCom = NULL;
}
else
{
DCB dcb;
BOOL bg;
bg=GetCommState (hCom, &dcb);
if(!bg)
{
MessageBox("对不起,你在此端口上没有打码机","警告",MB_OK);
}
dcb.BaudRate = COM_BAUD_RATE;
dcb.ByteSize = COM_DATA_BYTE_SIZE;
dcb.Parity = COM_PARITY;
dcb.StopBits = COM_STOP_BIT;
SetCommState (hCom, &dcb);
if (!fComInit)
{
DWORD dwBytes;
for (int i=0;
i<55;
i++)
{
WriteFile (hCom, "/r/n", 2, &dwBytes, NULL);
}
fComInit = TRUE;
}
}
}
m_nbarCode="^XA/r/n^LH"
+m_nhorizontal
+","
+m_nvertical
+"/r/n^FO300,0^AB^FD"
+"2001-7-16"
+"^FS/r/n^FO0,20,0^BY2^B3,N,70 ^FD"
+m_nbarCode+"^FS/r/n^XZ";
//char s[]=1234^FS/r/n^XZ/r/n";
//char *s;
//strcpy(s,m_nbarCode.GetBuffer);
//strcat(s,);
dwSize=m_nbarCode.GetLength();
if(fComInit)
{
WriteFile (hCom, m_nbarCode.GetBuffer(dwSize), dwSize, &dwBytes, NULL);
}
CloseHandle (hCom);
hCom = NULL;
}