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 » Community » Newbie corner » Printer's dialog shows up multiple times
Printer's dialog shows up multiple times [message #45471] Sat, 21 November 2015 11:39 Go to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi there,
I have this weird problem I can not fix. I developed an application with Ultimate++ interacting with a MySQL server. Basically there is a main window where user put some data and then save them in a SQL server. After some time the same user click on a button, a window opens and he puts some additional data. After doing that user clicks on a button to print those data on a label (the button is not on the main window, is on the window where user puts additional data) and finally clicks on a button to update the record on the SQL server with the additional data and comes back to the main window. The problem is on the print part of the workflow.

First time the user clicks on the print button, the printer's dialog window shows up (this is not a window created by me, is the standard window used by the operating system / printer's driver to manage printing), user clicks ok and the label is printed. When user creates a second record and has to print the label, he clicks the print button, printer's dialog shows up, he clicks ok, label printed BUT printer's dialog shows up again, so user clicks cancel and then can come back to normal operation. Third time user clicks on print button, the printer's dialog pops up three times: first time ok, then cancel, then cancel. I think you got where this is going: 4th label printed printer's dialog pops up 4 times, 5th 5 times and so on. If user completely exits the application, the "counting" of printer's dialog begins again from one.

My printing code is based on this example.

I thought that this was somehow related to the fact that I do not destroy the printer job after printing, but when I try to put a "delete pj;" line in my code it does not compile.

Please help me on fixing that, the application is unusable with this bug.
Thanks,
Giorgio
Re: Printer's dialog shows up multiple times [message #45472 is a reply to message #45471] Sat, 21 November 2015 12:19 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Did you try minimizing your example to the simplest possible case where bug is still reproduced?
Re: Printer's dialog shows up multiple times [message #45487 is a reply to message #45472] Mon, 23 November 2015 11:57 Go to previous messageGo to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi there,
I minimized the application: no sql code, no barcode, very few controls; basically it is just a main window with a button that opens a dialog.

I attach here the complete project, it is very small (the main.cpp is just 90 lines long), I hope someone could take the time to check it.

To reproduce the bug:
1. Launch the application;
2. Click on the button "Data", a diaolog opens;
3. Put something on the inputfield;
4. Click the print button - I use a pdf printer for the testing, but it happens with any printer;
5. Close the dialog using the "X", "Ok", or "Cancel".

Now - without exiting the application - repeat steps 2, 3, 4: at this point the printer's dialog will pop up two times, so the first time the user clicks Ok and prints and the second time clicks cancel.

If you repeat for the third time, the printer's dialog will pop up, three times and so on.

Any help is appreciated.
Thanks,
Giorgio
  • Attachment: Bugged.zip
    (Size: 2.31KB, Downloaded 178 times)
Re: Printer's dialog shows up multiple times [message #45492 is a reply to message #45487] Mon, 23 November 2015 21:26 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1075
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello Giorgio,

I think your code is hard to read for person that is not familiar with your language. It will be good if next time the code will be written in English. Backing to your problem, I think you wrongly assign callbacks (.

	dlgInserisciOEE.ok << THISBACK(dlgDatiOkPressed);
	dlgInserisciOEE.btnStampa << THISBACK(StampaRicevuta);


Should be,

	dlgInserisciOEE.ok <<= THISBACK(dlgDatiOkPressed);
	dlgInserisciOEE.btnStampa <<= THISBACK(StampaRicevuta);


Alternatively you can use When... clausul:
	dlgInserisciOEE.ok.WhenAction = THISBACK(dlgDatiOkPressed);
	dlgInserisciOEE.btnStampa.WhenAction = THISBACK(StampaRicevuta);


Please test and let me know if this works for you. I tested on Kubuntu and it seems ok - after above changes in code.

P.S.
Ultimate++ is designed to not used "delete" keyword with its components Smile

Sincerely,
Klugier


U++ - one framework to rule them all.

[Updated on: Mon, 23 November 2015 21:28]

Report message to a moderator

Re: Printer's dialog shows up multiple times [message #45502 is a reply to message #45492] Tue, 24 November 2015 16:50 Go to previous message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi Klugier,
thank you, the solution you suggested worked like a charm, now the application has been delivered to the users for intensive testing.
Regards,
Giorgio

Klugier wrote on Mon, 23 November 2015 21:26


Should be,

	dlgInserisciOEE.ok <<= THISBACK(dlgDatiOkPressed);
	dlgInserisciOEE.btnStampa <<= THISBACK(StampaRicevuta);



Previous Topic: Usage of Iml image data leads to linker error
Next Topic: How to use multiple schemas and databases?
Goto Forum:
  


Current Time: Fri Mar 29 14:33:15 CET 2024

Total time taken to generate the page: 0.02133 seconds