LPWSTR AnsiToWide( LPSTR );
HB_FUNC( PRINTLINE )
{
LPWSTR pW = AnsiToWide( hb_parc( 1 ) );
... use pW ...
hb_xfree( pW ); // free the allocated memory
}
#include "FWCE.ch"
function Main()
Print_1()
Print_2("Test")
return nil
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
#include <commdlg.h>
#include "PrintDC.h"
HB_FUNC( PRINT_1 )
{
HDC hPrDC2;
hPrDC2=PDC_GetPrinterDC() ;
LPTSTR pW ;
pW =_T("Hello World");
PDC_ExtTextOut(hPrDC2,100,100, 0, NULL, pW, _tcslen(pW), NULL);
}
LPWSTR AnsiToWide( LPSTR );
HB_FUNC( PRINT_2 )
{
HDC hPrDC2;
hPrDC2=PDC_GetPrinterDC() ;
LPWSTR pW = AnsiToWide( hb_parc( 1 ) );
PDC_ExtTextOut(hPrDC2,100,100, 0, NULL, pW, _tcslen(pW), NULL);
hb_xfree( pW ); // free the allocated memory
}
#include "FWCE.ch"
function Main()
Print_2("Test")
Print_1()
return nil
LPSTR pW = hb_parc( 1 ) ;
int len = hb_parclen( 1 );
TCHAR wName[ len ];
MultiByteToWideChar( CP_ACP, 0 ,pW , -1 , wName, len * 2 );
PDC_ExtTextOut(hPrDC,200,200, 0, NULL, wName, _tcslen(wName) , NULL);
LPSTR pW = hb_parc( 1 ) ;
int len = hb_parclen( 1 );
TCHAR * wName = ( TCHAR * ) hb_xgrab( len * sizeof( TCHAR ) );
...
hb_xfree( wName );
// FiveWin for Pocket PC - Testing comboboxes
#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;
//==============================================================================================
HB_FUNC( PRINTLINE )
{
LPSTR pW = hb_parc( 1 ) ;
int len = hb_parclen( 1 );
TCHAR * wName = ( TCHAR * ) hb_xgrab( len * sizeof( TCHAR ) );
MultiByteToWideChar( CP_ACP, 0 ,pW , -1 , wName, sizeof( wName ) / sizeof( wName[ 0 ] ) );
PDC_ExtTextOut(hPrDC,100,100, 0, NULL, wName, _tcslen(wName) , NULL);
hb_xfree( wName );
}
//==============================================================================================
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
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 83 guests