Printing a rich edit control

Printing a rich edit control

Postby Enrico Maria Giordano » Tue May 01, 2007 3:59 pm

How to get a printout equal to what I see on the rich edit control? I'm using testrtf.prg/testrtf.rtf sample but the printed text gets a different formatting.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Fri May 04, 2007 6:16 am

Enrico,

It depends on the size of the control: the texts gets adjusted to the control dimensions that may not be the same as the printer dimensions
regards, saludos

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

Postby Enrico Maria Giordano » Fri May 04, 2007 6:57 am

Yes, I know. I'm trying to size the window to have exactly what I will get when printing but I don't succeded so far.

This is what I write:

Code: Select all  Expand view
#define LOGPIXELSX 88
#define LOGPIXELSY 90

#define HORZRES  8
#define VERTRES 10

#define HORZSIZE 4
#define VERTSIZE 6

#define PHYSICALWIDTH   110
#define PHYSICALHEIGHT  111
#define PHYSICALOFFSETX 112
#define PHYSICALOFFSETY 113


STATIC FUNCTION ADJRTF( oRtf )

    LOCAL hPrnDC := GETPRINTDEFAULT()
    LOCAL hVidDC := GETDC( oRtf:hWnd )

    LOCAL nHRatio := GETDEVICECAPS( hPrnDC, LOGPIXELSX ) / GETDEVICECAPS( hVidDC, LOGPIXELSX )
    LOCAL nVRatio := GETDEVICECAPS( hPrnDC, LOGPIXELSY ) / GETDEVICECAPS( hVidDC, LOGPIXELSY )

    LOCAL nHorzRes := GETDEVICECAPS( hPrnDC, HORZRES )
    LOCAL nVertRes := GETDEVICECAPS( hPrnDC, VERTRES )

    LOCAL nTMarg := PAGEGETMARGINS()[ 1 ] / 2540 * GETDEVICECAPS( hPrnDC, LOGPIXELSY )
    LOCAL nLMarg := PAGEGETMARGINS()[ 2 ] / 2540 * GETDEVICECAPS( hPrnDC, LOGPIXELSX )
    LOCAL nRMarg := PAGEGETMARGINS()[ 3 ] / 2540 * GETDEVICECAPS( hPrnDC, LOGPIXELSX )
    LOCAL nBMarg := PAGEGETMARGINS()[ 4 ] / 2540 * GETDEVICECAPS( hPrnDC, LOGPIXELSY )

    nHorzRes -= nLMarg + nRMarg
    nVertRes -= nTMarg + nBMarg

    ADJRTFRECT( oRtf:oWnd:hWnd, oRtf:hWnd, nHorzRes / nHRatio, nVertRes / nVRatio )

    DELETEDC( hPrnDC )
    RELEASEDC( hVidDC )

    RETURN NIL


#pragma BEGINDUMP

#include <Windows.h>
#include <HbApi.h>


HB_FUNC( ADJRTFRECT )
{
    RECT rct;

    GetClientRect( ( HWND ) hb_parnl( 1 ), &rct );

    rct.left += 5;
    rct.top  += 5;

    rct.right  = rct.left + hb_parnl( 3 );
    rct.bottom = rct.top + hb_parnl( 4 );

    SendMessage( ( HWND ) hb_parnl( 2 ), EM_SETRECT, 1, ( LPARAM ) &rct );
}

#pragma ENDDUMP


Can you see anything wrong? Any suggestions?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Natter and 47 guests