Printing Framework

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
danielfrnt
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Oct 31, 2005 5:24 pm

Printing Framework

Post by danielfrnt » Mon Oct 31, 2005 5:36 pm

Hi all,
I'm getting some problems while trying to use printing framework in Wx-Widgets.
I've made a code for a printing program...but in a dot matrix printer, after some printing it suddenly stops...and the printer turn off automatically...
Anyone has any idea about what's happening?
Another question is that I wanna send some special chars to the printer...chars that it understant as commands....but it's not working...when I send one of this special chars ( In a DrawText )...the printer try to print them.

The code follows below:

Code: Select all


#include <ctype.h>
#include "wx/metafile.h"
#include "wx/print.h"
#include "wx/printdlg.h"
#include "wx/image.h"
#include "wx/accel.h"

#if wxTEST_POSTSCRIPT_IN_MSW
#include "wx/generic/printps.h"
#include "wx/generic/prntdlgg.h"
#endif

#include "printing.h"

#ifndef __WXMSW__
#include "mondrian.xpm"
#endif

#if wxUSE_LIBGNOMEPRINT
#include "wx/html/forcelnk.h"
#endif


// Declare a frame
MyFrame   *frame = (MyFrame *) NULL;
// int orientation = wxPORTRAIT;

// Global print data, to remember settings during the session
wxPrintData *g_printData = (wxPrintData*) NULL ;

// Global page setup data
wxPageSetupData* g_pageSetupData = (wxPageSetupData*) NULL;

// Main proc
IMPLEMENT_APP(MyApp)

//bool WritePageHeader(wxPrintout *printout, wxDC *dc, wxChar *text, float mmToLogical);

bool MyApp::OnInit( )
{
    wxInitAllImageHandlers();

    g_printData = new wxPrintData;
    g_pageSetupData = new wxPageSetupDialogData;

    // Cria janela principal
    frame = new MyFrame(( wxFrame *) NULL, _T("Logocenter Printer"), wxPoint(0, 0), wxSize(100, 100) );

    // Load icon and bitmap
    frame->SetIcon( wxICON( logocenter ) );

    frame->Centre(wxBOTH);
    frame->Show(false);

    if ( argc > 1 )
        frame->OnPrint( argv[1] );
    else
        wxMessageBox( wxT( "Favor informar o nome do arquivo" ), "Alerta", wxICON_EXCLAMATION );

    exit( 0 );
    return true;
}

int MyApp::OnExit()
{
    delete g_printData;
    delete g_pageSetupData;
    return 1;
}

MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size, long style ):
wxFrame(frame, wxID_ANY, title, pos, size)
{
}

void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event))
{
    Close( true );
}

void MyFrame::OnPrint( char *sFileName )
{
    wxPrintDialogData printDialogData(* g_printData);

    wxPrinter printer(& printDialogData);
    MyPrintout printout( wxT( sFileName ));
    printout.SetFileName( wxT( sFileName ) );

    printout.CountPages( );

    if (!printer.Print(this, &printout, true))
    {
        if (wxPrinter::GetLastError() == wxPRINTER_ERROR)
            wxMessageBox(_T("Ocorreu um problema ao tentar imprimir.\nVerifique as configura

eco
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 203
Joined: Tue Aug 31, 2004 7:06 pm
Location: Behind a can of Mountain Dew
Contact:

Post by eco » Wed Nov 02, 2005 12:28 am

If the printer is actually turning off I'd suspect it was a driver issue rather than an issue with your code.

danielfrnt
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Oct 31, 2005 5:24 pm

Post by danielfrnt » Fri Nov 04, 2005 10:45 am

But it works for other programs...like notepad, etc
only in my program the printer turn off...

danielfrnt
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Oct 31, 2005 5:24 pm

Post by danielfrnt » Fri Nov 04, 2005 5:28 pm

It's get the same error when I try to make something like "copy FileName MyPrinterPath"
It's happening when I've a File with more than 130 columns( or something close )...
Anyone have some idea of what I can do to fix this problem?

Post Reply