Print Windows Form
Moderator: Rathinagiri
Re: Print Windows Form
Thank you Esgici for your modification
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
Re: Print Windows Form
Rathinagiri wrote: ↑Sat Oct 15, 2016 3:42 amThese are the new functions we have:mol wrote:Nice work, thanks for sharing!
I don't know if it's good place to ask my question:
Is it the way to print bitmap created in memory without saving it to temporary file?
I need to generate labels for range of goods with barcodes.
And you can use the following BosTaurus function to draw a bitmap in memory to the PageDC as above.Code: Select all
New Functions: OpenPrinterGetDC() --> hDC of the current Open Printer OpenPrinterGetPageDC() --> hDC of the current Page being printed
Code: Select all
BT_DrawBitmap (hDC, Row, Col, Width, Height, Mode_Stretch, hBitmap) Draws a bitmap in the Device Context (DC) specified. hDC: is a handle to the device context. Row, Col, Width, Height: specifies the size of the rectangle in pixels in the DC where you will draw the bitmap. For default: Row = 0, Col = 0, Width = BT_BitmapWidth(hBitmap), Height = BT_BitmapHeight(hBitmap). Mode_Stretch: sets the mode as the bitmap is adjusts (is stretches or compresses) in the specified rectangle in the DC, it is one of the constants: BT_SCALE, BT_STRETCH or BT_COPY (defined in BosTaurus.CH). hBitmap: is a handle to the bitmap.
I want to refresh this topic. I need to create codebars and print them without saving to temporary file.
Have you working sample to place here?
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Print Windows Form
Try this Marek.
Code: Select all
#include <hmg.ch>
Function Main
define window main at 0, 0 width 200 height 200 main
define button click
row 10
col 10
caption 'Click me!'
action barcodeprint()
end button
end window
main.center
main.activate
Return
function barcodeprint
local hDC, hBitmap
select printer default preview
start printdoc
start printpage
hDC := OpenPrinterGetPageDC()
hBitmap := HMG_CreateBarCode( "http://harbour-project.org/",;
"QRCODE",;
2,;
110,;
.f.,;
'',;
{ 0, 0, 0 },;
{ 255, 255, 255 },;
.t.,; // checksum
.f.,; // wide2_5
.f. ) // wide3
BT_DrawBitmap ( hDC, ;
150, ;
150, ;
600, 600, BT_STRETCH, hBitmap )
end printpage
end printdoc
return nil
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: Print Windows Form
How can I convert pixels to millimeters depend of printer selection?
From where can I get selected printer resolution to enumerate right scale for printing generated image?
Now I took 600 dpi for laser printers, but it can be 1200, too.
From where can I get selected printer resolution to enumerate right scale for printing generated image?
Now I took 600 dpi for laser printers, but it can be 1200, too.
Re: Print Windows Form
Hi guys!
I need to return to this topic.
I need to know printer resolution to print image directly from memory without using temporary file.
My code prints graph on whole page:
I need to return to this topic.
I need to know printer resolution to print image directly from memory without using temporary file.
My code prints graph on whole page:
Code: Select all
local i
local nScale := 1
local DPM := 600/25.4 // Dots per millimeter, for laser printers with 600 dpi resolution
select printer default ;
ORIENTATION PRINTER_ORIENT_LANDSCAPE ;
preview
nWidth:= (GetPrintableAreaWidth()-20)*DPM
start printdoc
start printpage
hDC := OpenPrinterGetPageDC()
nScale := nWidth / BT_BitMapWidth(hGraphToPrint)
// 25,10 - position on the page
BT_DrawBitmap ( hDC, 25*DPM, 10*DPM,;
nSkala* BT_BitMapWidth(hGraphToPrint),;
nSkala* BT_BitMapHeight(hGraphToPrint),;
BT_STRETCH,;
hGraphToPrint)
end printpage
end printdoc
Re: Print Windows Form
TaDa!
Some searching, some thinking and solution is ready!
I've prepared function
HMG_GetPrinterResolution( hDC) => { nResX, nRexY }
where you can get hDC after selecting printer and starting printdoc
This function return array of horizontal and vertical resolution in DPI (dot per inch) of selected printer in pixels.
Some searching, some thinking and solution is ready!
I've prepared function
HMG_GetPrinterResolution( hDC) => { nResX, nRexY }
where you can get hDC after selecting printer and starting printdoc
This function return array of horizontal and vertical resolution in DPI (dot per inch) of selected printer in pixels.
Code: Select all
hDC := OpenPrinterGetDC()
aRes := HMG_GetPrinterResolution( hDC)
msgdebug( aRes )
#pragma begindump
#include <windows.h>
#include <hbapi.h>
HB_FUNC ( HMG_GETPRINTERRESOLUTION )
{
hb_reta (2);
hb_storvni ( GetDeviceCaps( (HDC) hb_parnl (1), LOGPIXELSX ), -1, 1 );
hb_storvni ( GetDeviceCaps( (HDC) hb_parnl (1), LOGPIXELSY ), -1, 2 );
}
#pragma ENDDUMP
Re: Print Windows Form
Hello friends!
The question seems to me a bit silly, but...
How can I print suspension points to a particular column?
Example:
Code.............: 000001
Description......: PEPPER MARMALADE
Price............: 2.35
I want the next result without having to do several tests placing dots or spaces in one and another row until it fits.
Code .................: 000001
Description..........: PEPPER MARMALADE
Price .................: 2.35
PS: By printer. In screen solves quickly.
The question seems to me a bit silly, but...
How can I print suspension points to a particular column?
Example:
Code.............: 000001
Description......: PEPPER MARMALADE
Price............: 2.35
I want the next result without having to do several tests placing dots or spaces in one and another row until it fits.
Code .................: 000001
Description..........: PEPPER MARMALADE
Price .................: 2.35
PS: By printer. In screen solves quickly.
I get by with a little help from my friends
Re: Print Windows Form
Hola BeGes
Deberás usar un Font de ancho fijo. ( Times New, Consolas, etc )
Ejemplo: PADR( "Price", 15, "." ) + ":"
NOTA:
Trata de hacer tu pregunta en un nuevo Post para que no se confundan o pierdan las respuestas...
Deberás usar un Font de ancho fijo. ( Times New, Consolas, etc )
Ejemplo: PADR( "Price", 15, "." ) + ":"
NOTA:
Trata de hacer tu pregunta en un nuevo Post para que no se confundan o pierdan las respuestas...
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
Re: Print Windows Form
It won't work fine if you use proportional font.