Bluetooth Printing

Bluetooth Printing

Postby Wolfgang Ciriack » Tue Oct 28, 2008 4:43 pm

Hello,
when i print to a bluetooth printer (EXTECH S2500THS) with
Code: Select all  Expand view
local hOut := CreateFile( gd_PrinterPort, GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL )

cText+=.....

for n = 1 to Len( cText )
   WriteByte( hOut, Asc( SubStr( cText, n, 1 ) ) )
next
return nil


some of the characters get lost (always other characters, sometimes only one, sometimes 2, 3 or 4). The printer is connected via Bluetooth seriell at COM8.

Must i configure something for bluetooth seriell communication at COM8 ?
Would it help, if i put a sleep in the WriteByte loop ? If yes, with which command ?
Best regards
Wolfgang Ciriack
Wolfgang Ciriack
 
Posts: 37
Joined: Sun Aug 03, 2008 8:02 am
Location: Germany, Berlin

Postby Antonio Linares » Tue Oct 28, 2008 5:30 pm

Wolfgang,

Please try calling SysRefresh() from inside the loop
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Wolfgang Ciriack » Tue Oct 28, 2008 5:52 pm

Hello Antonio,

do yo mean it in this way ?
Code: Select all  Expand view
for n = 1 to Len( cText )
   WriteByte( hOut, Asc( SubStr( cText, n, 1 ) ) )
   SysRefresh()
next
return nil
Best regards
Wolfgang Ciriack
Wolfgang Ciriack
 
Posts: 37
Joined: Sun Aug 03, 2008 8:02 am
Location: Germany, Berlin

Postby Antonio Linares » Tue Oct 28, 2008 5:52 pm

yes
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Wolfgang Ciriack » Thu Oct 30, 2008 8:46 am

Hello Antonio,

first tests did not change anything, but now i have reseted the whole system and the printing seems to be ok now.
Thank you for your help.
Best regards
Wolfgang Ciriack
Wolfgang Ciriack
 
Posts: 37
Joined: Sun Aug 03, 2008 8:02 am
Location: Germany, Berlin

Postby Richard Chidiak » Thu Oct 30, 2008 4:19 pm

Wolfgang

release the handle or you may go into trouble
The sysrefresh is needed after sending a msginfo or msgyesno, not needed in the loop.

i have been using BT printing with success since quite a while now . Only problem i have is printing french accented characters... still not solved

HTH

Code: Select all  Expand view
for n = 1 to Len( cText )
   WriteByte( hOut, Asc( SubStr( cText, n, 1 ) ) )
   SysRefresh()
next
CloseHandle( hOut )    // this is missing
return nil
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Postby Wolfgang Ciriack » Thu Oct 30, 2008 4:47 pm

Hello Richard,

thank you for your advice, i will add this to my prog.
Best regards
Wolfgang Ciriack
Wolfgang Ciriack
 
Posts: 37
Joined: Sun Aug 03, 2008 8:02 am
Location: Germany, Berlin

Postby Maurizio » Thu Oct 30, 2008 5:27 pm

Wolfgang ,

I use this DLL

http://www.fieldsoftware.com/PrintDC.htm

You cann print to a wide variety of printers using Infrared, Bluetooth and 802.11b wireless network , choose the font and the color.

Maurizio
User avatar
Maurizio
 
Posts: 796
Joined: Mon Oct 10, 2005 1:29 pm

Postby Wolfgang Ciriack » Thu Oct 30, 2008 6:00 pm

Maurizio,
i have ordered this SDK together with the Extech printer, but i am waiting for the delivery. Until now, i have no idea how to integrate this in my app.
For now, it is ok with the text output, but perhaps a little bit later i will come back with questions to that SDK :wink:
There are now some other programming hints which i have to solve, connecting via seriell communication to a GPS-Logger, sending Data via Wireless Lan (if connected) and so on....
Best regards
Wolfgang Ciriack
Wolfgang Ciriack
 
Posts: 37
Joined: Sun Aug 03, 2008 8:02 am
Location: Germany, Berlin

Postby Maurizio » Fri Oct 31, 2008 7:21 am

Wolfgang ,

This is a sample .

Regards MAurizio
Code: Select all  Expand view
#include "FWCE.ch"
#define PD_SELECTPORTRAIT                 0x00040000
#define PD_SELECTLANDSCAPE                0x00080000
//----------------------------------------------------------------------------//
function Main()

   local oWnd, cValue := "One"
   Local oFont
   Local cTitle := "Stampa"
   
   DEFINE WINDOW oWnd TITLE cTitle
   
   
   DEFINE FONT oFont NAME "Tahoma" SIZE 80, 80
   
   @ 1, 2 BUTTON "Test" SIZE 80, 30 ACTION PrintCE()
   
   ACTIVATE WINDOW oWnd
   
return nil
//----------------------------------------------------------------------------//
function PrintCE()

OPEN_CE()

PrintLine("Print this line")

CLOSE_CE()

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

#pragma BEGINDUMP


#include <hbapi.h>
#include <windows.h>
#include <aygshell.h>
#include <commdlg.h>   
#include "PrintDC.h"   

static far HDC hPrDC;
//==============================================================================================

//TCHAR * AnsiToWide( char * );
extern "C" {
TCHAR * AnsiToWide( char * );
};

HB_FUNC( PRINTLINE )
{

   int nLen = hb_parclen( 1 );
   LPSTR pW = hb_parc( 1 ) ;
   PDC_ExtTextOut(hPrDC,100,100, 0, NULL,  AnsiToWide(pW ), nLen * 2 , NULL);
   
}

//==============================================================================================

HB_FUNC( OPEN_CE )
{
   //Initialize PrintDC
   HWND hWnd;
   hWnd = FindWindow (NULL,L"Stampa");
   // MessageBox( 0, wName, L"TRUE", 0 );
   PDC_Init(_T("Key"));  // 
   PRINTDLG pdlg;
   memset(&pdlg, 0, sizeof(PRINTDLG));
   pdlg.cbStruct = sizeof(PRINTDLG);
   pdlg.hwndOwner= hWnd;
   pdlg.dwFlags = PD_SELECTPORTRAIT | PD_INTHOUSANDTHSOFINCHES;
   if (!PDC_PrintDlg(&pdlg)) {  //Show "Select Printer" dialog
      PDC_KillDoc(NULL);  //user may have pressed cancel - free PrintDC resources and clear error condition
      return;
   }
   //Get the printer DC
   hPrDC=pdlg.hdc; //Can also use PDC_GetPrinterDC()
   if (hPrDC==NULL) return;
   //Get printer resolution
   int DPI;
   DPI=PDC_GetDeviceCaps(hPrDC,LOGPIXELSX);
   //Get our margins - stored as thousandths of an inch.since used PD_INTHOUSANDTHSOFINCHES
   // Convert margins to printer units (DPI) and subract physical offsets
   int leftmargin,topmargin;
   leftmargin=(pdlg.rcMargin.left*DPI)/1000 - PDC_GetDeviceCaps(hPrDC,PHYSICALOFFSETX);
   topmargin=(pdlg.rcMargin.top*DPI)/1000 - PDC_GetDeviceCaps(hPrDC,PHYSICALOFFSETY);
   //Lets get started printing
   DOCINFO di;
   PDC_StartDoc(hPrDC,&di);
   PDC_StartPage(hPrDC);
   //Print our text using default font
}


//==============================================================================================
HB_FUNC( CLOSE_CE )
{
   PDC_EndPage(hPrDC);
   PDC_EndDoc(hPrDC);
   if (hPrDC) PDC_DeleteDC((HDC) hPrDC);
   PDC_UnInit();
}

#pragma ENDDUMP
User avatar
Maurizio
 
Posts: 796
Joined: Mon Oct 10, 2005 1:29 pm

Postby Wolfgang Ciriack » Fri Oct 31, 2008 7:25 am

Thank you very much Maurizio, i save this on my disk !
Best regards
Wolfgang Ciriack
Wolfgang Ciriack
 
Posts: 37
Joined: Sun Aug 03, 2008 8:02 am
Location: Germany, Berlin


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 21 guests