Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » PrintJob does not works on "large project"
PrintJob does not works on "large project" [message #30404] Tue, 28 December 2010 15:51 Go to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
Hi all
I have a problem on printing that just happens on a large UPP project I have.

If I compile and execute the following project:

#include "teste2.h"
teste2::teste2()
{
	CtrlLayout(*this, "Window title");
	btBut <<= THISBACK(OnBut);	
}
void teste2::OnBut(void)
{
	PrinterJob pj;
	Draw& w = pj;
	w.StartPage();
	w.DrawText(0, 0, "Hello world!", Roman(100));
	w.EndPage();
	
}
GUI_APP_MAIN
{
	teste2().Run();
}

the printer prints the message.


But in a large GUI project I use the same code on a button handler and the printer does not move its printing head...
(In this large project I included also the Report support for printing other things on other menu/button options.)


void CSearchHistory::OnButtonOPrint(void)
{
PrinterJob pj1("History job");
Draw& w1 = pj1;
w1.StartPage();
w1.DrawText(0, 0, "Hello world!", Roman(100));
w1.EndPage();
}

Any ideads to catch the problem?
I put an Exclamation on the method beginning and at method end and i realized that OnButtonOPrint method is executed from the beginning until the end.

By the way, debuging facility on the IDE never worked for me...

Env: win7, Mingw and Upp 2901

Thanks a lot
Alex
Re: PrintJob does not works on "large project" [message #30405 is a reply to message #30404] Tue, 28 December 2010 17:39 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
alex100 wrote on Tue, 28 December 2010 09:51

Hi all
I have a problem on printing that just happens on a large UPP project I have.

If I compile and execute the following project:

#include "teste2.h"
teste2::teste2()
{
	CtrlLayout(*this, "Window title");
	btBut <<= THISBACK(OnBut);	
}
void teste2::OnBut(void)
{
	PrinterJob pj;
	Draw& w = pj;
	w.StartPage();
	w.DrawText(0, 0, "Hello world!", Roman(100));
	w.EndPage();
	
}
GUI_APP_MAIN
{
	teste2().Run();
}

the printer prints the message.


But in a large GUI project I use the same code on a button handler and the printer does not move its printing head...
(In this large project I included also the Report support for printing other things on other menu/button options.)


void CSearchHistory::OnButtonOPrint(void)
{
PrinterJob pj1("History job");
Draw& w1 = pj1;
w1.StartPage();
w1.DrawText(0, 0, "Hello world!", Roman(100));
w1.EndPage();
}

Any ideads to catch the problem?



First thing that comes to mind is that you have problem with default printer.

Try pj1.Execute() before Draw& .... line to find out.

Quote:



By the way, debuging facility on the IDE never worked for me...

Env: win7, Mingw and Upp 2901



I strongly recommend avoiding mingw and using free Win7 SDK... Saves a lot of troubles, debugging included, and produces better code too.

Mirek
Re: PrintJob does not works on "large project" [message #30406 is a reply to message #30405] Tue, 28 December 2010 18:15 Go to previous messageGo to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
If I put the following code lines

bool b= pj1.Execute();
if(!b)
Exclamation("Error");

The printer dialog do not shows up and Execute returns false Sad


By the way, I thought that all of you (UPP authors) would advice to use Mingw... But ok, if you are saying that free VC++ from MS is a better choise (for windows development) I will try it.
But tell me, does free VC++ builds applications that do not need to run above .NET framework? I hate .NET framewaork. It is a monster!
I like windows applications that run without the need of .NET.

Alex
Re: PrintJob does not works on "large project" [message #30407 is a reply to message #30406] Wed, 29 December 2010 09:32 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
alex100 wrote on Tue, 28 December 2010 12:15

If I put the following code lines

bool b= pj1.Execute();
if(!b)
Exclamation("Error");

The printer dialog do not shows up and Execute returns false Sad



Interesting!

I would now tried DDUMP(GetLastErrorMessage()) - perhaps it would give a clue what is wrong.

Then, of course, install SDK and try to debug .Execute.

Quote:


By the way, I thought that all of you (UPP authors) would advice to use Mingw... But ok, if you are saying that free VC++ from MS is a better choise (for windows development) I will try it.
But tell me, does free VC++ builds applications that do not need to run above .NET framework? I hate .NET framewaork. It is a monster!



Yes. You have to install .NET to install SDK, but compiled apps are .NET free...

Re: PrintJob does not works on "large project" [message #30412 is a reply to message #30407] Wed, 29 December 2010 12:51 Go to previous messageGo to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
GetLastErrorMessage() = Error not specified...

But what SDK do you mean? Do you mean VC++ express edition?

Alex

[Updated on: Wed, 29 December 2010 12:53]

Report message to a moderator

Re: PrintJob does not works on "large project" [message #30415 is a reply to message #30412] Wed, 29 December 2010 15:44 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
alex100 wrote on Wed, 29 December 2010 06:51

GetLastErrorMessage() = Error not specified...



Well, thinking about it, the most likely hypothesis is that you have screwed stack or heap somewhere in your code.

Should be testable by putting this to the beginning of MAIN.

Quote:


But what SDK do you mean? Do you mean VC++ express edition?

Alex


The one that is recommended when installing U++.

http://www.ultimatepp.org/app$ide$install$en-us.html

It also contains C++ compiler... So no need to install VC++ (unless you want to use it as 'external' debugger).

And it is the one and proper C SDK for Windows anyway.
Re: PrintJob does not works on "large project" [message #30418 is a reply to message #30415] Wed, 29 December 2010 17:55 Go to previous messageGo to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
Great, but i did not found anything about licence, saying that it is free for developping commercial applications. Is it?


Alex
Re: PrintJob does not works on "large project" [message #30509 is a reply to message #30418] Wed, 05 January 2011 16:46 Go to previous messageGo to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
The problem arises from the code

printjob.cpp
::Execute0
if(!PrintDlg(&dlg)) 
{
    DWORD x= CommDlgExtendedError();



the CommDlgExtendedError returns 0x1008 which means
"A default printer does not exist."

How to solve this?



Again, the following small project runs well...
#include "teste2.h"



teste2::teste2()
{
	CtrlLayout(*this, "Window title");
	btBut <<= THISBACK(OnBut);
	

	
}

void teste2::OnBut(void)
{
	PrinterJob pj;
	Draw& w = pj;
	w.StartPage();
	w.DrawText(0, 0, "Hello world!", Roman(100));
	w.EndPage();
	
}

GUI_APP_MAIN
{
	teste2().Run();
}




It seems that it is something related with that project/executable...


Thanks

Alex

[Updated on: Wed, 05 January 2011 17:01]

Report message to a moderator

Re: PrintJob does not works on "large project" [message #30557 is a reply to message #30509] Sat, 08 January 2011 13:15 Go to previous message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
alex100 wrote on Wed, 05 January 2011 10:46

The problem arises from the code

printjob.cpp
::Execute0
if(!PrintDlg(&dlg)) 
{
    DWORD x= CommDlgExtendedError();



the CommDlgExtendedError returns 0x1008 which means
"A default printer does not exist."

How to solve this?



Again, the following small project runs well...
#include "teste2.h"



teste2::teste2()
{
	CtrlLayout(*this, "Window title");
	btBut <<= THISBACK(OnBut);
	

	
}

void teste2::OnBut(void)
{
	PrinterJob pj;
	Draw& w = pj;
	w.StartPage();
	w.DrawText(0, 0, "Hello world!", Roman(100));
	w.EndPage();
	
}

GUI_APP_MAIN
{
	teste2().Run();
}




It seems that it is something related with that project/executable...


Thanks

Alex


Well, the general approach I am using in cases like this (you have big project with strange behaviour of unknown source) is to "exclude" the code until it starts working.

E.g. rename "GUI_APP_MAIN" of above code to "DoTest", then put all of that to your project (temorarily) and call DoTest at beginning of your big app GUI_APP_MAIN. If it does not work, there is a bug in global constructor somewhere. If it works ok, start it moving down the code... until it stops - then you have identified what makes the error.



Previous Topic: GUI app arguments?
Next Topic: How to maximize printing area of the RichEdit Ctrl? [SOLVED]
Goto Forum:
  


Current Time: Sun Jun 23 01:30:03 CEST 2024

Total time taken to generate the page: 0.01904 seconds