How to print an image & data on it

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
gfilatov
Posts: 1100
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: How to print an image & data on it

Post by gfilatov »

Roberto Lopez wrote:
swapan wrote:Can I accomplish the job using Report Writer?

I've used this kind of code:

DEFINE REPORT Report1
* Report Layout ***********************************************
BEGIN LAYOUT
PAPERSIZE PRINTER_PAPER_A4
ORIENTATION PRINTER_ORIENT_PORTRAIT
END LAYOUT
* Header Band *************************************************
BEGIN HEADER
BANDHEIGHT 25


Its generating 2 labels in 1 A4 sized sheet, but no. of copies option is disabled, how can I initialize this value and the user can put values for No. of copies??

For Dot Matrix Printer (local) its coming, but for others (network printers) which are deskjets - no. of copies is disabled.... Not sure if the network printers at my office are right now offline or not....
Number of copies will be enabled only when the printer driver supports it, so it depends upon the printer you are using.
Hello Roberto,

I've solve this problem by changing of the following C-function:

Code: Select all

HB_FUNC ( _HMG_PRINTER_PRINTDIALOG )
{

	PRINTDLG pd ;

	LPDEVMODE   pDevMode;

	pd.lStructSize = sizeof(PRINTDLG); 
	pd.hDevMode = (HANDLE) NULL; 
	pd.hDevNames = (HANDLE) NULL; 
	pd.Flags = PD_RETURNDC | PD_PRINTSETUP ; 
	pd.hwndOwner = NULL ; 
	pd.hDC = (HDC) NULL; 
	pd.nFromPage = 1; 
	pd.nToPage = 0x3E7;    // 999
	pd.nMinPage = 1; 
	pd.nMaxPage = 0x3E7;  // 999
	pd.nCopies = 1; 
	pd.hInstance = (HINSTANCE) NULL; 
	pd.lCustData = 0L; 
	pd.lpfnPrintHook = (LPPRINTHOOKPROC) NULL; 
	pd.lpfnSetupHook = (LPSETUPHOOKPROC) NULL; 
	pd.lpPrintTemplateName = (LPSTR) NULL; 
	pd.lpSetupTemplateName = (LPSTR)  NULL; 
	pd.hPrintTemplate = (HANDLE) NULL; 
	pd.hSetupTemplate = (HANDLE) NULL; 
 
	if ( PrintDlg(&pd) ) 
	{
		pDevMode = (LPDEVMODE) GlobalLock(pd.hDevMode);

		hb_reta( 4 );
		HB_STORNL	( (LONG) pd.hDC		, -1, 1 ); 
		HB_STORC	( pDevMode->dmDeviceName, -1, 2 ); 
		HB_STORNI	( pDevMode->dmCopies	, -1, 3 ); 
		HB_STORNI	( pDevMode->dmCollate	, -1, 4 ); 

		GlobalUnlock(pd.hDevMode);
	}
	else
	{
		hb_reta( 4 );
		HB_STORNL	( 0	, -1, 1 ); 
		HB_STORC	( ""	, -1, 2 ); 
		HB_STORNI	( 0	, -1, 3 ); 
		HB_STORNI	( 0	, -1, 4 ); 
	}

}
I hope that helps. :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: How to print an image & data on it

Post by Roberto Lopez »

gfilatov wrote:
Hello Roberto,

I've solve this problem by changing of the following C-function:

Code: Select all

HB_FUNC ( _HMG_PRINTER_PRINTDIALOG )
{

	PRINTDLG pd ;

	LPDEVMODE   pDevMode;

	pd.lStructSize = sizeof(PRINTDLG); 
	pd.hDevMode = (HANDLE) NULL; 
	pd.hDevNames = (HANDLE) NULL; 
	pd.Flags = PD_RETURNDC | PD_PRINTSETUP ; 
	pd.hwndOwner = NULL ; 
	pd.hDC = (HDC) NULL; 
	pd.nFromPage = 1; 
	pd.nToPage = 0x3E7;    // 999
	pd.nMinPage = 1; 
	pd.nMaxPage = 0x3E7;  // 999
	pd.nCopies = 1; 
	pd.hInstance = (HINSTANCE) NULL; 
	pd.lCustData = 0L; 
	pd.lpfnPrintHook = (LPPRINTHOOKPROC) NULL; 
	pd.lpfnSetupHook = (LPSETUPHOOKPROC) NULL; 
	pd.lpPrintTemplateName = (LPSTR) NULL; 
	pd.lpSetupTemplateName = (LPSTR)  NULL; 
	pd.hPrintTemplate = (HANDLE) NULL; 
	pd.hSetupTemplate = (HANDLE) NULL; 
 
	if ( PrintDlg(&pd) ) 
	{
		pDevMode = (LPDEVMODE) GlobalLock(pd.hDevMode);

		hb_reta( 4 );
		HB_STORNL	( (LONG) pd.hDC		, -1, 1 ); 
		HB_STORC	( pDevMode->dmDeviceName, -1, 2 ); 
		HB_STORNI	( pDevMode->dmCopies	, -1, 3 ); 
		HB_STORNI	( pDevMode->dmCollate	, -1, 4 ); 

		GlobalUnlock(pd.hDevMode);
	}
	else
	{
		hb_reta( 4 );
		HB_STORNL	( 0	, -1, 1 ); 
		HB_STORC	( ""	, -1, 2 ); 
		HB_STORNI	( 0	, -1, 3 ); 
		HB_STORNI	( 0	, -1, 4 ); 
	}

}
I hope that helps. :idea:
At first, thanks for the suggestion.

Could be you so kind to give me a brief explanation about which is the change and what it the code does?

TIA.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
gfilatov
Posts: 1100
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: How to print an image & data on it

Post by gfilatov »

Roberto Lopez wrote: At first, thanks for the suggestion.

Could be you so kind to give me a brief explanation about which is the change and what it the code does?
Roberto,

I've changed a few lines only:

Code: Select all

...
   pd.nToPage = 0x3E7;    // 999
   pd.nMinPage = 1; 
   pd.nMaxPage = 0x3E7;  // 999
...
These changes indicates a right range of min/max page number (available on printer setup page).

It works fine with my home Samsung and work HP lazer printers. :)
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: How to print an image & data on it

Post by Roberto Lopez »

gfilatov wrote:
Roberto Lopez wrote: At first, thanks for the suggestion.

Could be you so kind to give me a brief explanation about which is the change and what it the code does?
Roberto,

I've changed a few lines only:

Code: Select all

...
   pd.nToPage = 0x3E7;    // 999
   pd.nMinPage = 1; 
   pd.nMaxPage = 0x3E7;  // 999
...
These changes indicates a right range of min/max page number (available on printer setup page).

It works fine with my home Samsung and work HP lazer printers. :)
Ok. I'll take a look at that, but, if I've not misunderstood, the answer was about the number of copies and not the range.

Please, correct me if I'm wrong.

TIA.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
gfilatov
Posts: 1100
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: How to print an image & data on it

Post by gfilatov »

Roberto Lopez wrote: Ok. I'll take a look at that, but, if I've not misunderstood, the answer was about the number of copies and not the range.

Please, correct me if I'm wrong.
Roberto,

You are right, of course :)

There is a small change for manage the number of copies also :arrow:

Code: Select all

...
		HB_STORNI	( pDevMode->dmCopies > 1 ? pDevMode->dmCopies : pd.nCopies, -1, 3 ); 
...
I've tested on my Win7 x64 and it works smoothly ;)
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: How to print an image & data on it

Post by Roberto Lopez »

gfilatov wrote:
Roberto Lopez wrote: Ok. I'll take a look at that, but, if I've not misunderstood, the answer was about the number of copies and not the range.

Please, correct me if I'm wrong.
Roberto,

You are right, of course :)

There is a small change for manage the number of copies also :arrow:

Code: Select all

...
		HB_STORNI	( pDevMode->dmCopies > 1 ? pDevMode->dmCopies : pd.nCopies, -1, 3 ); 
...
I've tested on my Win7 x64 and it works smoothly ;)
Oh no... my CPU does not support 64 bit instructions... :)
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: How to print an image & data on it

Post by Roberto Lopez »

gfilatov wrote:
Roberto Lopez wrote: Ok. I'll take a look at that, but, if I've not misunderstood, the answer was about the number of copies and not the range.

Please, correct me if I'm wrong.
Roberto,

You are right, of course :)

There is a small change for manage the number of copies also :arrow:

Code: Select all

...
		HB_STORNI	( pDevMode->dmCopies > 1 ? pDevMode->dmCopies : pd.nCopies, -1, 3 ); 
...
I've tested on my Win7 x64 and it works smoothly ;)
And...

Again, I'm afraid that this is an answer for a different question from the one posted here by swapan.

As swapan indicated the problem is "the no. of copies option is in disabled state in Print Preview"

This is not related in any way with Windows standard print dialog (the code submitted by you).

Then, I still sustaining my original answer: The number of copies is disabled in print preview when the printer driver does not support such feature.

The bottom line is that your code is not related with swapan question in any way :).
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: How to print an image & data on it

Post by Roberto Lopez »

Roberto Lopez wrote:
And...

Again, I'm afraid that this is an answer for a different question from the one posted here by swapan.

As swapan indicated the problem is "the no. of copies option is in disabled state in Print Preview"

This is not related in any way with Windows standard print dialog (the code submitted by you).

Then, I still sustaining my original answer: The number of copies is disabled in print preview when the printer driver does not support such feature.

The bottom line is that your code is not related with swapan question in any way :).
...and... and..

The number of copies spinner in print preview window is enabled or not depending on the capabilities of the current printer driver about that.

Please, take a look at 'h_controlmisc.prg' (about line 4878), 'i_print.ch' (about line 77) and c_controlmisc.c (_HMG_PRINTER_SETPRINTERPROPERTIES function).
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: How to print an image & data on it

Post by Roberto Lopez »

Roberto Lopez wrote: The bottom line is that your code is not related with swapan question in any way :).
and... and... and...

This is the reason because I do not apply your 'fixes' without a previous researching ;)
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
swapan
Posts: 242
Joined: Mon Mar 16, 2009 4:23 am
Location: Kolkata, India
Contact:

Re: How to print an image & data on it

Post by swapan »

Roberto Lopez wrote:
gfilatov wrote:
Roberto Lopez wrote: Ok. I'll take a look at that, but, if I've not misunderstood, the answer was about the number of copies and not the range.

Please, correct me if I'm wrong.
Roberto,

You are right, of course :)

There is a small change for manage the number of copies also :arrow:

Code: Select all

...
		HB_STORNI	( pDevMode->dmCopies > 1 ? pDevMode->dmCopies : pd.nCopies, -1, 3 ); 
...
I've tested on my Win7 x64 and it works smoothly ;)
And...

Again, I'm afraid that this is an answer for a different question from the one posted here by swapan.

As swapan indicated the problem is "the no. of copies option is in disabled state in Print Preview"

This is not related in any way with Windows standard print dialog (the code submitted by you).

Then, I still sustaining my original answer: The number of copies is disabled in print preview when the printer driver does not support such feature.

The bottom line is that your code is not related with swapan question in any way :).
Thanks Gfilatov for going deep into the issue...............

As pointed out by Roberto Sir, my actual issue is "The No. Of Copies" option is coming in disabled state with a pre-defined value of 1 in it. There's hell of other works right now consuming my time, so unable to test it on other printers. I tested it on a HP deskjet printer and found that issue. But Roberto Sir, the no. of copies option for that printer is active for ms-word/excel applications, then why it wiill be not active for my print preview?

Regards,

Swapan
Thanks & Regards,
Swapan Das

http://www.swapandas.com/
Post Reply