Discussion:
wxPrintDialog - empty wxPrintdata
(too old to reply)
Leonti Bielski
2009-04-25 00:48:33 UTC
Permalink
Hello!
I want to call a PrintDialog just to set printing properties. Not before the
actual printing but like program settings for future printing.
Here is my code:

http://pastebin.com/m5c9947f6

The problem is that printer name is always an empty string.
Also tried to check for printdata1 -> GetCollate(); and it's always false.
No matter what I'm doing in popped up dialog.
What am I doing wrong?

Thanks in advance.
Leonti

p.s. Posted the same question on forum, but since I've got no reply trying
the same thing here.
Robert Luchner
2009-04-25 08:54:51 UTC
Permalink
Post by Leonti Bielski
Hello!
I want to call a PrintDialog just to set printing properties. Not
before the actual printing but like program settings for future printing.
http://pastebin.com/m5c9947f6
The problem is that printer name is always an empty string.
Also tried to check for printdata1 -> GetCollate(); and it's always
false. No matter what I'm doing in popped up dialog.
What am I doing wrong?
Thanks in advance.
Leonti
p.s. Posted the same question on forum, but since I've got no reply
trying the same thing here.
------------------------------------------------------------------------
_______________________________________________
wx-users mailing list
http://lists.wxwidgets.org/mailman/listinfo/wx-users
I have solved the problem in the folliwing way:

void IkStmRFNewGre::OnInit()
{
m_printData = (wxPrintData*)NULL;
m_pageSetupData = (wxPageSetupData*)NULL;

m_printData = new wxPrintData;
// both ConvertToNative and ConvertFromNative must be called!!!
m_printData->ConvertToNative();
m_printData->ConvertFromNative();

m_pageSetupData = new wxPageSetupDialogData();
(*m_pageSetupData) = *m_printData;
m_pageSetupData->SetMarginTopLeft(wxPoint(20, 20)); //
Std-Rand Links-Oben
m_pageSetupData->SetMarginBottomRight(wxPoint(20, 20)); //
Std-Rand Rechts-Unten
SetPrinterName();
}

void IkStmRFNewGre::SetPrinterName()
{
wxPrintData printData;
printData.ConvertToNative();
printData.ConvertFromNative();

// Wenn Druckername gleich == "" --> Standarddrucker
WTEXT druckerName[MAXSTR];
WTEXT printerName[MAXSTR];
strcpy((char*)druckerName, printData.GetPrinterName().c_str());
strcpy((char*)printerName, m_printData->GetPrinterName().c_str());
if (StrGleich(druckerName, printerName))
m_printData->SetPrinterName(wxT(""));
}

In Windows (Vista) it seems to be OK!
By
Robert Luchner
Leonti Bielski
2009-04-27 18:12:13 UTC
Permalink
Hi! Thanks for answering!

I'm a little lost there. Are you overriding OnInit() and SetPrinterName() of
wxPrintDialog?
Where dialog actually gets called?
What is the trick to get printer name?
What is StrGleich function?

Leonti
Post by Robert Luchner
Post by Leonti Bielski
Hello!
I want to call a PrintDialog just to set printing properties. Not before
the actual printing but like program settings for future printing.
http://pastebin.com/m5c9947f6
The problem is that printer name is always an empty string.
Also tried to check for printdata1 -> GetCollate(); and it's always false.
No matter what I'm doing in popped up dialog.
What am I doing wrong?
Thanks in advance.
Leonti
p.s. Posted the same question on forum, but since I've got no reply trying
the same thing here.
------------------------------------------------------------------------
_______________________________________________
wx-users mailing list
http://lists.wxwidgets.org/mailman/listinfo/wx-users
void IkStmRFNewGre::OnInit()
{
m_printData = (wxPrintData*)NULL;
m_pageSetupData = (wxPageSetupData*)NULL;
m_printData = new wxPrintData;
// both ConvertToNative and ConvertFromNative must be called!!!
m_printData->ConvertToNative();
m_printData->ConvertFromNative();
m_pageSetupData = new wxPageSetupDialogData();
(*m_pageSetupData) = *m_printData;
m_pageSetupData->SetMarginTopLeft(wxPoint(20, 20)); //
Std-Rand Links-Oben
m_pageSetupData->SetMarginBottomRight(wxPoint(20, 20)); //
Std-Rand Rechts-Unten
SetPrinterName();
}
void IkStmRFNewGre::SetPrinterName()
{
wxPrintData printData;
printData.ConvertToNative();
printData.ConvertFromNative();
// Wenn Druckername gleich == "" --> Standarddrucker
WTEXT druckerName[MAXSTR];
WTEXT printerName[MAXSTR];
strcpy((char*)druckerName, printData.GetPrinterName().c_str());
strcpy((char*)printerName, m_printData->GetPrinterName().c_str());
if (StrGleich(druckerName, printerName))
m_printData->SetPrinterName(wxT(""));
}
In Windows (Vista) it seems to be OK!
By
Robert Luchner
_______________________________________________
wx-users mailing list
http://lists.wxwidgets.org/mailman/listinfo/wx-users
r***@gmx.at
2009-04-28 12:10:24 UTC
Permalink
Hallo,
no i do not override the functions! It is only the name of my Base Class (IkStmRFNewGre).
By
Robert
-------- Original-Nachricht --------
Datum: Mon, 27 Apr 2009 20:12:13 +0200
Betreff: Re: wxPrintDialog - empty wxPrintdata
Hi! Thanks for answering!
I'm a little lost there. Are you overriding OnInit() and SetPrinterName()
of
wxPrintDialog?
Where dialog actually gets called?
What is the trick to get printer name?
What is StrGleich function?
Leonti
Post by Robert Luchner
Post by Leonti Bielski
Hello!
I want to call a PrintDialog just to set printing properties. Not
before
Post by Robert Luchner
Post by Leonti Bielski
the actual printing but like program settings for future printing.
http://pastebin.com/m5c9947f6
The problem is that printer name is always an empty string.
Also tried to check for printdata1 -> GetCollate(); and it's always
false.
Post by Robert Luchner
Post by Leonti Bielski
No matter what I'm doing in popped up dialog.
What am I doing wrong?
Thanks in advance.
Leonti
p.s. Posted the same question on forum, but since I've got no reply
trying
Post by Robert Luchner
Post by Leonti Bielski
the same thing here.
------------------------------------------------------------------------
Post by Robert Luchner
Post by Leonti Bielski
_______________________________________________
wx-users mailing list
http://lists.wxwidgets.org/mailman/listinfo/wx-users
void IkStmRFNewGre::OnInit()
{
m_printData = (wxPrintData*)NULL;
m_pageSetupData = (wxPageSetupData*)NULL;
m_printData = new wxPrintData;
// both ConvertToNative and ConvertFromNative must be called!!!
m_printData->ConvertToNative();
m_printData->ConvertFromNative();
m_pageSetupData = new wxPageSetupDialogData();
(*m_pageSetupData) = *m_printData;
m_pageSetupData->SetMarginTopLeft(wxPoint(20, 20)); //
Std-Rand Links-Oben
m_pageSetupData->SetMarginBottomRight(wxPoint(20, 20)); //
Std-Rand Rechts-Unten
SetPrinterName();
}
void IkStmRFNewGre::SetPrinterName()
{
wxPrintData printData;
printData.ConvertToNative();
printData.ConvertFromNative();
// Wenn Druckername gleich == "" --> Standarddrucker
WTEXT druckerName[MAXSTR];
WTEXT printerName[MAXSTR];
strcpy((char*)druckerName, printData.GetPrinterName().c_str());
strcpy((char*)printerName, m_printData->GetPrinterName().c_str());
if (StrGleich(druckerName, printerName))
m_printData->SetPrinterName(wxT(""));
}
In Windows (Vista) it seems to be OK!
By
Robert Luchner
_______________________________________________
wx-users mailing list
http://lists.wxwidgets.org/mailman/listinfo/wx-users
--
Neu: GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate + Telefonanschluss für nur 17,95 Euro/mtl.!* http://dslspecial.gmx.de/freedsl-surfflat/?ac=OM.AD.PD003K11308T4569a
Robert Luchner
2009-04-28 17:30:06 UTC
Permalink
Post by Leonti Bielski
Hi! Thanks for answering!
I'm a little lost there. Are you overriding OnInit() and
SetPrinterName() of wxPrintDialog?
I do not override the OnInit etc of wxPrintDialog.
OnInit() and SetPrinterName() are methods of MY BaseClass
<IkStmRFNewGre> to initalize m_printData and m_pageSetupData and the
variables m_printData and m_pageSetupData are defined in the class
IkStmRFNewGre.
Post by Leonti Bielski
Where dialog actually gets called?
I have Buttons in the dialog (in the BaseClass IkStmRFNewGre to call the
printer and also the page layout

void IkStmRFNewGre::OnPrinter(wxCommandEvent &event)
{
wxPrintDialogData printDialogData(*m_printData);
wxPrinter printer(&printDialogData);
wxDC* dc;
if (dc = printer.PrintDialog(this))
{
(*m_printData) = printer.GetPrintDialogData().GetPrintData();
(*m_pageSetupData) = *m_printData;
SetPrinterName();
delete dc;
}
event.Skip();
}

void IkStmRFNewGre::OnSeite(wxCommandEvent& event)
{
wxPageSetupDialog pageSetupDialog(this, m_pageSetupData);
pageSetupDialog.ShowModal();
(*m_printData) = pageSetupDialog.GetPageSetupData().GetPrintData();
(*m_pageSetupData) = pageSetupDialog.GetPageSetupData();
SetPrinterName();
event.Skip();
}
Post by Leonti Bielski
What is the trick to get printer name?
There is no trick to get the printer name!
If you initialize the printer data in the OnInit() and you don't call
ConvertToNative and ConvertFramNative then the printerData are not
initialized.
If you call both methods you get the inital values without a call to to
wxPrintDialog.
Post by Leonti Bielski
What is StrGleich function?
Sorry this function is an old function in C to compare both arguments.
If the variable druckerName and printerName are the same you get true
return. And if there is the same name i take the standard printer name
of empty value.
Post by Leonti Bielski
Leonti
Hello!
I want to call a PrintDialog just to set printing properties.
Not before the actual printing but like program settings for
future printing.
http://pastebin.com/m5c9947f6
The problem is that printer name is always an empty string.
Also tried to check for printdata1 -> GetCollate(); and it's
always false. No matter what I'm doing in popped up dialog.
What am I doing wrong?
Thanks in advance.
Leonti
p.s. Posted the same question on forum, but since I've got no
reply trying the same thing here.
------------------------------------------------------------------------
_______________________________________________
wx-users mailing list
http://lists.wxwidgets.org/mailman/listinfo/wx-users
void IkStmRFNewGre::OnInit()
{
m_printData = (wxPrintData*)NULL;
m_pageSetupData = (wxPageSetupData*)NULL;
m_printData = new wxPrintData;
// both ConvertToNative and ConvertFromNative must be called!!!
m_printData->ConvertToNative();
m_printData->ConvertFromNative();
m_pageSetupData = new wxPageSetupDialogData();
(*m_pageSetupData) = *m_printData;
m_pageSetupData->SetMarginTopLeft(wxPoint(20, 20));
// Std-Rand Links-Oben
m_pageSetupData->SetMarginBottomRight(wxPoint(20, 20));
// Std-Rand Rechts-Unten
SetPrinterName();
}
void IkStmRFNewGre::SetPrinterName()
{
wxPrintData printData;
printData.ConvertToNative();
printData.ConvertFromNative();
// Wenn Druckername gleich == "" --> Standarddrucker
WTEXT druckerName[MAXSTR];
WTEXT printerName[MAXSTR];
strcpy((char*)druckerName, printData.GetPrinterName().c_str());
strcpy((char*)printerName, m_printData->GetPrinterName().c_str());
if (StrGleich(druckerName, printerName))
m_printData->SetPrinterName(wxT(""));
}
In Windows (Vista) it seems to be OK!
By
Robert Luchner
_______________________________________________
wx-users mailing list
http://lists.wxwidgets.org/mailman/listinfo/wx-users
------------------------------------------------------------------------
_______________________________________________
wx-users mailing list
http://lists.wxwidgets.org/mailman/listinfo/wx-users
Leonti Bielski
2009-04-28 20:05:09 UTC
Permalink
Thanks a lot for explanations!
Will try this later!

Thanks again! Leonti
Post by Robert Luchner
Post by Leonti Bielski
Hi! Thanks for answering!
I'm a little lost there. Are you overriding OnInit() and SetPrinterName()
of wxPrintDialog?
I do not override the OnInit etc of wxPrintDialog.
OnInit() and SetPrinterName() are methods of MY BaseClass <IkStmRFNewGre>
to initalize m_printData and m_pageSetupData and the variables m_printData
and m_pageSetupData are defined in the class IkStmRFNewGre.
Post by Leonti Bielski
Where dialog actually gets called?
I have Buttons in the dialog (in the BaseClass IkStmRFNewGre to call the
printer and also the page layout
void IkStmRFNewGre::OnPrinter(wxCommandEvent &event)
{
wxPrintDialogData printDialogData(*m_printData);
wxPrinter printer(&printDialogData);
wxDC* dc;
if (dc = printer.PrintDialog(this))
{
(*m_printData) = printer.GetPrintDialogData().GetPrintData();
(*m_pageSetupData) = *m_printData;
SetPrinterName();
delete dc;
}
event.Skip();
}
void IkStmRFNewGre::OnSeite(wxCommandEvent& event)
{
wxPageSetupDialog pageSetupDialog(this, m_pageSetupData);
pageSetupDialog.ShowModal();
(*m_printData) = pageSetupDialog.GetPageSetupData().GetPrintData();
(*m_pageSetupData) = pageSetupDialog.GetPageSetupData();
SetPrinterName();
event.Skip();
}
What is the trick to get printer name?
There is no trick to get the printer name!
If you initialize the printer data in the OnInit() and you don't call
ConvertToNative and ConvertFramNative then the printerData are not
initialized.
If you call both methods you get the inital values without a call to to
wxPrintDialog.
Post by Leonti Bielski
What is StrGleich function?
Sorry this function is an old function in C to compare both arguments.
If the variable druckerName and printerName are the same you get true
return. And if there is the same name i take the standard printer name of
empty value.
Post by Leonti Bielski
Leonti
Hello!
I want to call a PrintDialog just to set printing properties.
Not before the actual printing but like program settings for
future printing.
http://pastebin.com/m5c9947f6
The problem is that printer name is always an empty string.
Also tried to check for printdata1 -> GetCollate(); and it's
always false. No matter what I'm doing in popped up dialog.
What am I doing wrong?
Thanks in advance.
Leonti
p.s. Posted the same question on forum, but since I've got no
reply trying the same thing here.
------------------------------------------------------------------------
_______________________________________________
wx-users mailing list
http://lists.wxwidgets.org/mailman/listinfo/wx-users
void IkStmRFNewGre::OnInit()
{
m_printData = (wxPrintData*)NULL;
m_pageSetupData = (wxPageSetupData*)NULL;
m_printData = new wxPrintData;
// both ConvertToNative and ConvertFromNative must be called!!!
m_printData->ConvertToNative();
m_printData->ConvertFromNative();
m_pageSetupData = new wxPageSetupDialogData();
(*m_pageSetupData) = *m_printData;
m_pageSetupData->SetMarginTopLeft(wxPoint(20, 20)); //
Std-Rand Links-Oben
m_pageSetupData->SetMarginBottomRight(wxPoint(20, 20)); //
Std-Rand Rechts-Unten
SetPrinterName();
}
void IkStmRFNewGre::SetPrinterName()
{
wxPrintData printData;
printData.ConvertToNative();
printData.ConvertFromNative();
// Wenn Druckername gleich == "" --> Standarddrucker
WTEXT druckerName[MAXSTR];
WTEXT printerName[MAXSTR];
strcpy((char*)druckerName, printData.GetPrinterName().c_str());
strcpy((char*)printerName, m_printData->GetPrinterName().c_str());
if (StrGleich(druckerName, printerName))
m_printData->SetPrinterName(wxT(""));
}
In Windows (Vista) it seems to be OK!
By
Robert Luchner
_______________________________________________
wx-users mailing list
http://lists.wxwidgets.org/mailman/listinfo/wx-users
------------------------------------------------------------------------
_______________________________________________
wx-users mailing list
http://lists.wxwidgets.org/mailman/listinfo/wx-users
_______________________________________________
wx-users mailing list
http://lists.wxwidgets.org/mailman/listinfo/wx-users
Leonti Bielski
2009-04-30 21:52:02 UTC
Permalink
Didn't work :(

I guess my problem is described here:
http://trac.wxwidgets.org/ticket/3410

Leonti
Post by Leonti Bielski
Thanks a lot for explanations!
Will try this later!
Thanks again! Leonti
Post by Robert Luchner
Post by Leonti Bielski
Hi! Thanks for answering!
I'm a little lost there. Are you overriding OnInit() and SetPrinterName()
of wxPrintDialog?
I do not override the OnInit etc of wxPrintDialog.
OnInit() and SetPrinterName() are methods of MY BaseClass <IkStmRFNewGre>
to initalize m_printData and m_pageSetupData and the variables m_printData
and m_pageSetupData are defined in the class IkStmRFNewGre.
Post by Leonti Bielski
Where dialog actually gets called?
I have Buttons in the dialog (in the BaseClass IkStmRFNewGre to call the
printer and also the page layout
void IkStmRFNewGre::OnPrinter(wxCommandEvent &event)
{
wxPrintDialogData printDialogData(*m_printData);
wxPrinter printer(&printDialogData);
wxDC* dc;
if (dc = printer.PrintDialog(this))
{
(*m_printData) = printer.GetPrintDialogData().GetPrintData();
(*m_pageSetupData) = *m_printData;
SetPrinterName();
delete dc;
}
event.Skip();
}
void IkStmRFNewGre::OnSeite(wxCommandEvent& event)
{
wxPageSetupDialog pageSetupDialog(this, m_pageSetupData);
pageSetupDialog.ShowModal();
(*m_printData) = pageSetupDialog.GetPageSetupData().GetPrintData();
(*m_pageSetupData) = pageSetupDialog.GetPageSetupData();
SetPrinterName();
event.Skip();
}
What is the trick to get printer name?
There is no trick to get the printer name!
If you initialize the printer data in the OnInit() and you don't call
ConvertToNative and ConvertFramNative then the printerData are not
initialized.
If you call both methods you get the inital values without a call to to
wxPrintDialog.
Post by Leonti Bielski
What is StrGleich function?
Sorry this function is an old function in C to compare both arguments.
If the variable druckerName and printerName are the same you get true
return. And if there is the same name i take the standard printer name of
empty value.
Post by Leonti Bielski
Leonti
Hello!
I want to call a PrintDialog just to set printing properties.
Not before the actual printing but like program settings for
future printing.
http://pastebin.com/m5c9947f6
The problem is that printer name is always an empty string.
Also tried to check for printdata1 -> GetCollate(); and it's
always false. No matter what I'm doing in popped up dialog.
What am I doing wrong?
Thanks in advance.
Leonti
p.s. Posted the same question on forum, but since I've got no
reply trying the same thing here.
------------------------------------------------------------------------
_______________________________________________
wx-users mailing list
http://lists.wxwidgets.org/mailman/listinfo/wx-users
void IkStmRFNewGre::OnInit()
{
m_printData = (wxPrintData*)NULL;
m_pageSetupData = (wxPageSetupData*)NULL;
m_printData = new wxPrintData;
// both ConvertToNative and ConvertFromNative must be called!!!
m_printData->ConvertToNative();
m_printData->ConvertFromNative();
m_pageSetupData = new wxPageSetupDialogData();
(*m_pageSetupData) = *m_printData;
m_pageSetupData->SetMarginTopLeft(wxPoint(20, 20)); //
Std-Rand Links-Oben
m_pageSetupData->SetMarginBottomRight(wxPoint(20, 20)); //
Std-Rand Rechts-Unten
SetPrinterName();
}
void IkStmRFNewGre::SetPrinterName()
{
wxPrintData printData;
printData.ConvertToNative();
printData.ConvertFromNative();
// Wenn Druckername gleich == "" --> Standarddrucker
WTEXT druckerName[MAXSTR];
WTEXT printerName[MAXSTR];
strcpy((char*)druckerName, printData.GetPrinterName().c_str());
strcpy((char*)printerName, m_printData->GetPrinterName().c_str());
if (StrGleich(druckerName, printerName))
m_printData->SetPrinterName(wxT(""));
}
In Windows (Vista) it seems to be OK!
By
Robert Luchner
_______________________________________________
wx-users mailing list
http://lists.wxwidgets.org/mailman/listinfo/wx-users
------------------------------------------------------------------------
_______________________________________________
wx-users mailing list
http://lists.wxwidgets.org/mailman/listinfo/wx-users
_______________________________________________
wx-users mailing list
http://lists.wxwidgets.org/mailman/listinfo/wx-users
Loading...