// C:\FWH\SAMPLES\BOXROUND.PRG - kapiabafwh@gmail.com - 14/08/2024 - Joao.#include "FiveWin.ch"#define PAD_LEFT
0#define PAD_RIGHT
1#define PAD_CENTER
2FUNCTION BoxRed
() // CAIXA REDONDA - BOXROUND. LOCAL oPrn, oFont, oFont2, oFont3, oPen, oPen1, oPen2, oPen3
LOCAL oBrush, oFondo
LOCAL ResLinha, ResColuna, nLinha, nColuna
LOCAL nLinBox, nColBox, nAltBox, nTamBox, lBorEsq, lBorDir
// 60 caracteres en el maximo LOCAL cTxt1 :=
"Lo que quiero es imprimir un informe en hoja A4 y que se" LOCAL cTxt2 :=
"respete el tamaño sin que tenga en cuenta la impresora " LOCAL cTxt3 :=
"predeterminada. El tema es que se usa en varias pc y " LOCAL cTxt4 :=
"tienen distintas impresoras y tamaños de papel " LOCAL cTxt5 :=
"predeterminados y sale en algunas bien y en otras mal, " LOCAL cTxt6 :=
"porque no se respeta el A4 que necesito. " LOCAL cTxt7 :=
"Cómo imprimir en centímetros en cualquier impresora " LOCAL cTxt8 :=
" jpcavagnaro - Jorge" LOCAL xAncho, xAltocm
PRINT oPrn
NAME "Ejemplo de caja redondeada" PREVIEW
DEFINE BRUSH oBrush
COLOR nRGB
(250,
213,
174) // Bello DEFINE BRUSH oFondo
COLOR CLR_GRAY
// HGRAY DEFINE PEN oPen WIDTH
2 COLOR CLR_CYAN
OF oPrn
Define Pen oPen1 Width
25 COLOR nRgb
( 192,
192,
192 ) OF oPrn
DEFINE PEN oPen2 WIDTH
2 COLOR CLR_BROWN
OF oPrn
DEFINE PEN oPen3 WIDTH
50 COLOR nRgb
( 192,
192,
192 ) OF oPrn
DEFINE FONT oFont
NAME "Arial" SIZE 0, -
6 BOLD
OF oPrn
DEFINE FONT oFont2
NAME "Arial" SIZE 0, -
12 BOLD Underline
OF oPrn
DEFINE FONT oFont3
NAME "Arial" SIZE 0, -
16 BOLD
OF oPrn
oPrn:
SetPage( 9 ) //-> A4 //9 oPrn:
SetPortrait() //-> Vertical(Retrato) /*
// Cómo imprimir en centímetros en cualquier impresora
ResLinha := oPrn:nLogPixely() / 2.54
ResColuna := oPrn:nLogPixelx() / 2.54
*/ /* MEJOR, SIEMPRE USAR LOCAL.
publ xAncho := ( ( oPrn:nHorzRes() / 25.4 ) / 10 ) //-1
publ xAltocm := ( ( oPrn:nVertRes() / 25.4 ) / 10 ) // -1.5
*/ // USANDO: oPrn:Say xAncho :=
( ( oPrn:
nHorzRes() /
25.4 ) ) xAltocm :=
( ( oPrn:
nVertRes() /
25.4 ) ) ResLinha := xAncho
ResColuna := xAltocm
PAGE nLinha :=
2.25 nColuna :=
9.50 nLinBox :=
1.60 // Linha que Inicia o Box // 1.60 nColBox :=
7.40 // Coluna que inicia o Box // 7.50 nAltBox :=
3.50 // Altura do Box nTamBox :=
15.60 // Tamanho(Largura) do Box horizontal // 13.60 lBorEsq :=
90 // Bordas arredondadas esquerda. lBorDir :=
90 // Bordas arrendondadas direita. Box_Round
( nLinBox , nColBox , nAltBox, nTamBox, oPrn, lBorEsq, lBorDir, oPen, oFondo
) oPrn:
Say( nLinha * ResLinha, nColuna * ResColuna, ;
+
"DESCRIZIONE DOCUMENTO", oFont2,, CLR_BLACK,, PAD_CENTER
) nLinha := nLinha +
1.50 oPrn:
Say( nLinha * ResLinha, nColuna * ResColuna, ;
+
"FiveWin is invincible.", oFont,, CLR_BLACK,, PAD_CENTER
) nLinha := nLinha +
3.50 oPrn:
Say( nLinha * ResLinha, nColuna +
8.9 * ResColuna, ;
+ cTxt7, oFont3,, CLR_BLACK,, PAD_CENTER
) nLinha := nLinha +
1.50 oPrn:
Say( nLinha * ResLinha, nColuna +
8.9 * ResColuna, ;
+ cTxt1, oFont3,, CLR_BLACK,, PAD_CENTER
) nLinha := nLinha +
1.50 oPrn:
Say( nLinha * ResLinha, nColuna +
8.9 * ResColuna, ;
+ cTxt2, oFont3,, CLR_BLACK,, PAD_CENTER
) nLinha := nLinha +
1.50 oPrn:
Say( nLinha * ResLinha, nColuna +
8.9 * ResColuna, ;
+ cTxt3, oFont3,, CLR_BLACK,, PAD_CENTER
) nLinha := nLinha +
1.50 oPrn:
Say( nLinha * ResLinha, nColuna +
8.9 * ResColuna, ;
+ cTxt4, oFont3,, CLR_BLACK,, PAD_CENTER
) nLinha := nLinha +
1.50 oPrn:
Say( nLinha * ResLinha, nColuna +
8.9 * ResColuna, ;
+ cTxt5, oFont3,, CLR_BLACK,, PAD_CENTER
) nLinha := nLinha +
1.50 oPrn:
Say( nLinha * ResLinha, nColuna +
8.9 * ResColuna, ;
+ cTxt6, oFont3,, CLR_BLACK,, PAD_CENTER
) nLinha := nLinha +
1.50 oPrn:
Say( nLinha * ResLinha, nColuna +
8.9 * ResColuna, ;
+ cTxt7, oFont3,, CLR_BLACK,, PAD_CENTER
) nLinha := nLinha +
15.00 oPrn:
Say( nLinha * ResLinha, nColuna +
8.9 * ResColuna, ;
+ cTxt8, oFont3,, METRO_VIOLET,, PAD_CENTER
) ENDPAGE ENDPRINT oBrush:
End() oFondo:
End() oPen:
End() oPen:
Release()RETURN nilFUNCTION Box_Round
( nArriba, nIzq, nAbajo, nDerecha, oPrn, a, b, oPen, oBrush
) LOCAL hOldPen, xCor :=
{} , yCor :=
{} LOCAL hOldBrush
// Pasamos coordenadas de cms a pixel xCor := oPrn:
Cmtr2Pix(nArriba,nIzq
) yCor := oPrn:
Cmtr2Pix(nAbajo,nDerecha
) // Guardamos el Lapiz y la brocha que teniamos hOldPen := SelectObject
( oPrn:
hDcOut, oPen:
hPen ) hOldBrush := SelectObject
( oPrn:
hDcOut, oBrush:
hBrush ) //Dibujamos el rectangulo redondeado roundrect
(oPrn:
hdcOut,xCor
[2],xCor
[1],yCor
[2],yCor
[1],a,b
) // y seleccionamos el que habiamos guardado selectObject
( oPrn:
hDcOut, hOldPen
) selectObject
( oPrn:
hDcOut, hOldBrush
)RETURN NIL#IFDEF __HARBOUR__
DLL
FUNCTION RoundRect
( hDC AS LONG, ;
iLeft AS _INT , iTop AS _INT, ;
iRight AS _INT, iBottom AS _INT, ;
iWidth AS _INT, iHeight AS _INT
) AS BOOL PASCAL LIB
"GDI32.DLL"#ELSE
DLL
FUNCTION RoundRect
( hDC AS WORD, ;
iLeft AS _INT , iTop AS _INT, ;
iRight AS _INT, iBottom AS _INT, ;
iWidth AS _INT, iHeight AS _INT
) AS BOOL PASCAL LIB
"GDI.EXE"#ENDIF
// FIN / END