lance100
asked on
HELP!!!! Print Dialog Big Problem
I am having a difficult time learning how to print the info out that need. Can any find it in there heart to help out struggling beginner programmer like myself. I have a dialog box(below) which I want printed. I struggled with this for three days and I can't figure it out. If someone is nice enough can they either write the code for me or explain in detail how to do it. Also can you referr to my variable names show I can understand more clearly.
Thank you so much for the help I that I need so much.
// ServiceDialog.cpp : implementation file
//
#include "stdafx.h"
#include "afxdlgs.h"
#include "menu.h"
#include "ServiceDialog.h"
#include "Service2Dialog.h"
#include "SaveDialog.h"
#include "iostream.h"
#include "afxwin.h"
#include "stdio.h"
#include "process.h"
#include "dos.h"
#include <fstream.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
////////////////////////// ////////// ////////// ////////// ////////// ////////// /
// CServiceDialog dialog
CServiceDialog::CServiceDi alog(CWnd* pParent /*=NULL*/)
: CDialog(CServiceDialog::ID D, pParent)
{
//{{AFX_DATA_INIT(CService Dialog)
m_billtravel = 0.0;
m_totinv = 0.0;
m_totlabour = 0.0;
m_totparts = 0.0;
m_tottravel = 0.0;
m_billtime = 0.0;
m_ratelabour = 60.0;
m_ratetravel = 60.0;
m_custnum = _T("");
m_ordernum = _T("");
m_address = _T("");
m_assigned = _T("");
m_billcode = _T("");
m_company = _T("");
m_contact = _T("");
m_contract = _T("");
m_custponum = _T("");
m_custref = _T("");
m_faxnum = _T("");
m_makemod = _T("");
m_onsite = FALSE;
m_opersys = _T("");
m_phonenum = _T("");
m_problem = _T("");
m_promised = _T("");
m_response = _T("");
m_serialnum = _T("");
m_servtype = _T("");
m_siteaddress = _T("");
m_software = _T("");
m_status = _T("");
m_urgency = _T("");
m_version = _T("");
m_waitparts = _T("");
//varialbles to hold info from page 2
//does not need to be printed!!
m_contacts22 = _T("");
m_dates22 = _T("");
m_date1s22 = _T("");
m_date12s22 = _T("");
m_date2s22 = _T("");
m_date3s22 = _T("");
m_extension1s22 = _T("");
m_extension2s22 = _T("");
m_extension3s22 = _T("");
m_faxnums22 = _T("");
m_loanagrees22 = _T("");
m_ourponums22 = _T("");
m_partnum1s22 = _T("");
m_partnum2s22 = _T("");
m_partnum3s22 = _T("");
m_partsused1s22 = _T("");
m_partsused2s22 = _T("");
m_partsused3s22 = _T("");
m_phonenums22 = _T("");
m_rmas22 = _T("");
m_servpref1s22 = _T("");
m_servpref2s22 = _T("");
m_servpref3s22 = _T("");
m_tech1s22 = _T("");
m_tech2s22 = _T("");
m_tech3s22 = _T("");
m_vendors22 = _T("");
m_starttime12 = 0.0;
m_starttime22 = 0.0;
m_starttime32=0.0;
m_endtime12=0.0;
m_endtime22=0.0;
m_endtime32=0.0;
m_hours12=0.0;
m_hours22=0.0;
m_hours32=0.0;
m_price12=0.0;
m_price22=0.0;
m_price32=0.0;
m_qty12=0.0;
m_qty22=0.0;
m_qty32=0.0;
m_tot2=0.0;
m_totlab2=0.0;
m_totprice2=0.0;
m_travel12=0.0;
m_travel22=0.0;
m_travel32=0.0;
m_calldate = time_t(0);
//}}AFX_DATA_INIT
}
void CServiceDialog::DoDataExch ange(CData Exchange* pDX)
{
CDialog::DoDataExchange(pD X);
//{{AFX_DATA_MAP(CServiceD ialog)
DDX_Text(pDX, IDC_BILLTRAVEL_EDIT, m_billtravel);
DDX_Text(pDX, IDC_TOTINV_EDIT, m_totinv);
DDX_Text(pDX, IDC_TOTLABOUR_EDIT, m_totlabour);
DDX_Text(pDX, IDC_TOTPARTS_EDIT, m_totparts);
DDX_Text(pDX, IDC_TOTTAVEL_EDIT, m_tottravel);
DDX_Text(pDX, IDC_BILLTIME_EDIT, m_billtime);
DDX_Text(pDX, IDC_RATELABOUR_EDIT, m_ratelabour);
DDX_Text(pDX, IDC_RATETRAVEL_EDIT, m_ratetravel);
DDX_Text(pDX, IDC_CUSTNUM_EDIT, m_custnum);
DDX_Text(pDX, IDC_ORDERNUM_EDIT, m_ordernum);
DDX_Text(pDX, IDC_ADDRESS_EDIT, m_address);
DDX_CBString(pDX, IDC_ASSIGNED_COMBO, m_assigned);
DDX_CBString(pDX, IDC_BILLCODE_COMBO, m_billcode);
DDX_Text(pDX, IDC_COMPANY_EDIT, m_company);
DDX_Text(pDX, IDC_CONTACT_EDIT, m_contact);
DDX_Text(pDX, IDC_CONTRACT_EDIT, m_contract);
DDX_Text(pDX, IDC_CUSTPONUM_EDIT, m_custponum);
DDX_Text(pDX, IDC_CUSTREF_EDIT, m_custref);
DDX_Text(pDX, IDC_FAXNUM_EDIT, m_faxnum);
DDX_Text(pDX, IDC_MAKEMOD_EDIT, m_makemod);
DDX_Check(pDX, IDC_ONSITE_CHECK, m_onsite);
DDX_CBString(pDX, IDC_OPERSYS_COMBO, m_opersys);
DDX_Text(pDX, IDC_PHONENUM_EDIT, m_phonenum);
DDX_Text(pDX, IDC_PROBLEM_EDIT, m_problem);
DDX_Text(pDX, IDC_PROMISED_EDIT, m_promised);
DDX_Text(pDX, IDC_RESPONSE_EDIT, m_response);
DDX_Text(pDX, IDC_SERIALNUM_EDIT, m_serialnum);
DDX_CBString(pDX, IDC_SERVTYPE_COMBO, m_servtype);
DDX_Text(pDX, IDC_SITEADDRESS_EDIT, m_siteaddress);
DDX_Text(pDX, IDC_SOFTWARE_EDIT, m_software);
DDX_CBString(pDX, IDC_STATUS_COMBO, m_status);
DDX_CBString(pDX, IDC_URGENCY_COMBO, m_urgency);
DDX_Text(pDX, IDC_VERSION_EDIT, m_version);
DDX_CBString(pDX, IDC_WAITPARTS_COMBO, m_waitparts);
DDX_Text(pDX, IDC_CALLDATE_EDIT, m_calldate);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CService Dialog, CDialog)
//{{AFX_MSG_MAP(CServiceDi alog)
ON_BN_CLICKED(IDC_PAGE2_BU TTON, OnPage2Button)
ON_BN_CLICKED(IDC_EXIT_BUT TON2, OnExitButton2)
ON_BN_CLICKED(IDC_CALC_BUT TON, OnCalcButton)
ON_BN_CLICKED(IDC_PRINT_BU TTON, OnPrintButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
////////////////////////// ////////// ////////// ////////// ////////// ////////// /
// CServiceDialog message handlers
void CServiceDialog::OnPage2But ton()
{
// TODO: Add your control notification handler code here
//sets varibles to another page
UpdateData(TRUE);
OnOK();
CService2Dialog Srv2Dlg;
Srv2Dlg.m_calldate2 = m_calldate;
Srv2Dlg.m_custnum2 = m_custnum;
Srv2Dlg.m_address2 =m_address;
Srv2Dlg.m_assigned2 =m_assigned;
Srv2Dlg.m_company2 =m_company;
Srv2Dlg.m_contact2 =m_contact;
Srv2Dlg.m_contract2 =m_contract;
Srv2Dlg.m_custponum2 =m_custponum;
Srv2Dlg.m_custref2 =m_custref;
Srv2Dlg.m_faxnum2 =m_faxnum;
Srv2Dlg.m_makemod2 =m_makemod;
Srv2Dlg.m_opersys2 =m_opersys;
Srv2Dlg.m_ordernum2 =m_ordernum;
Srv2Dlg.m_phonenum2 =m_phonenum;
Srv2Dlg.m_problem2 = m_problem;
Srv2Dlg.m_promised2 = m_promised;
Srv2Dlg.m_response2 = m_response;
Srv2Dlg.m_serialnum2 =m_serialnum;
Srv2Dlg.m_servtype2 = m_servtype;
Srv2Dlg.m_siteaddress2 =m_siteaddress;
Srv2Dlg.m_software2 = m_software;
Srv2Dlg.m_status2 = m_status;
Srv2Dlg.m_urgency2 = m_urgency;
Srv2Dlg.m_version2 = m_version;
Srv2Dlg.m_waitparts2 = m_waitparts;
Srv2Dlg.m_billcode2 = m_billcode;
Srv2Dlg.m_onsite2 = m_onsite;
Srv2Dlg.m_contacts2=m_cont acts22;
Srv2Dlg.m_dates2=m_dates22 ;
Srv2Dlg.m_date1s2=m_date1s 22;
Srv2Dlg.m_date12s2=m_date1 2s22;
Srv2Dlg.m_date2s2=m_date2s 22;
Srv2Dlg.m_date3s2=m_date3s 22;
Srv2Dlg.m_extension1s2=m_e xtension1s 22;
Srv2Dlg.m_extension2s2=m_e xtension2s 22;
Srv2Dlg.m_extension3s2=m_e xtension3s 22;
Srv2Dlg.m_faxnums2=m_faxnu ms22;
Srv2Dlg.m_loanagrees2=m_lo anagrees22 ;
Srv2Dlg.m_ourponums2=m_our ponums22;
Srv2Dlg.m_partnum1s2=m_par tnum1s22;
Srv2Dlg.m_partnum2s2=m_par tnum2s22;
Srv2Dlg.m_partnum3s2=m_par tnum3s22;
Srv2Dlg.m_partsused1s2=m_p artsused1s 22;
Srv2Dlg.m_partsused2s2=m_p artsused2s 22;
Srv2Dlg.m_partsused3s2=m_p artsused3s 22;
Srv2Dlg.m_phonenums2=m_pho nenums22;
Srv2Dlg.m_rmas2=m_rmas22;
Srv2Dlg.m_servpref1s2=m_se rvpref1s22 ;
Srv2Dlg.m_servpref2s2=m_se rvpref2s22 ;
Srv2Dlg.m_servpref3s2=m_se rvpref3s22 ;
Srv2Dlg.m_tech1s2=m_tech1s 22;
Srv2Dlg.m_tech2s2=m_tech2s 22;
Srv2Dlg.m_tech3s2=m_tech3s 22;
Srv2Dlg.m_vendors2=m_vendo rs22;
Srv2Dlg.m_starttime1= m_starttime12;
Srv2Dlg.m_starttime2=m_sta rttime22;
Srv2Dlg.m_starttime3=m_sta rttime32;
Srv2Dlg.m_endtime1=m_endti me12;
Srv2Dlg.m_endtime2=m_endti me22;
Srv2Dlg.m_endtime3=m_endti me32;
Srv2Dlg.m_hours1=m_hours12 ;
Srv2Dlg.m_hours2=m_hours22 ;
Srv2Dlg.m_hours3=m_hours32 ;
Srv2Dlg.m_price1=m_price12 ;
Srv2Dlg.m_price2=m_price22 ;
Srv2Dlg.m_price3=m_price32 ;
Srv2Dlg.m_qty1=m_qty12;
Srv2Dlg.m_qty2=m_qty22;
Srv2Dlg.m_qty3=m_qty32;
Srv2Dlg.m_tot=m_tot2;
Srv2Dlg.m_totlab=m_totlab2 ;
Srv2Dlg.m_totprice=m_totpr ice2;
Srv2Dlg.m_travel1=m_travel 12;
Srv2Dlg.m_travel2=m_travel 22;
Srv2Dlg.m_travel3=m_travel 32;
Srv2Dlg.DoModal();
}
void CServiceDialog::OnExitButt on2()
{
// TODO: Add your control notification handler code here
//connects to another dialog box to save info
CSaveDialog SaveDlg;
SaveDlg.DoModal();
OnOK();
}
void CServiceDialog::OnCalcButt on()
{
// TODO: Add your control notification handler code here
//does simple calulates in my dialog
UpdateData(TRUE); // get data from controls
m_tottravel=m_billtravel*m _ratetrave l; //calculate total labour
m_totlabour=m_billtime*m_r atelabour;
m_totinv=m_totparts+m_tott ravel+m_to tlabour; // calc total invoice
cout<<m_tottravel;
cout<<m_totlabour;
cout<<m_totinv;
UpdateData(FALSE); // send data to controls
}
void CServiceDialog::OnPrintBut ton()
{
// TODO: Add your control notification handler code here
//Here is the print button which I want to print from.
//Please place the code here.
Thank you so much for the help I that I need so much.
// ServiceDialog.cpp : implementation file
//
#include "stdafx.h"
#include "afxdlgs.h"
#include "menu.h"
#include "ServiceDialog.h"
#include "Service2Dialog.h"
#include "SaveDialog.h"
#include "iostream.h"
#include "afxwin.h"
#include "stdio.h"
#include "process.h"
#include "dos.h"
#include <fstream.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//////////////////////////
// CServiceDialog dialog
CServiceDialog::CServiceDi
: CDialog(CServiceDialog::ID
{
//{{AFX_DATA_INIT(CService
m_billtravel = 0.0;
m_totinv = 0.0;
m_totlabour = 0.0;
m_totparts = 0.0;
m_tottravel = 0.0;
m_billtime = 0.0;
m_ratelabour = 60.0;
m_ratetravel = 60.0;
m_custnum = _T("");
m_ordernum = _T("");
m_address = _T("");
m_assigned = _T("");
m_billcode = _T("");
m_company = _T("");
m_contact = _T("");
m_contract = _T("");
m_custponum = _T("");
m_custref = _T("");
m_faxnum = _T("");
m_makemod = _T("");
m_onsite = FALSE;
m_opersys = _T("");
m_phonenum = _T("");
m_problem = _T("");
m_promised = _T("");
m_response = _T("");
m_serialnum = _T("");
m_servtype = _T("");
m_siteaddress = _T("");
m_software = _T("");
m_status = _T("");
m_urgency = _T("");
m_version = _T("");
m_waitparts = _T("");
//varialbles to hold info from page 2
//does not need to be printed!!
m_contacts22 = _T("");
m_dates22 = _T("");
m_date1s22 = _T("");
m_date12s22 = _T("");
m_date2s22 = _T("");
m_date3s22 = _T("");
m_extension1s22 = _T("");
m_extension2s22 = _T("");
m_extension3s22 = _T("");
m_faxnums22 = _T("");
m_loanagrees22 = _T("");
m_ourponums22 = _T("");
m_partnum1s22 = _T("");
m_partnum2s22 = _T("");
m_partnum3s22 = _T("");
m_partsused1s22 = _T("");
m_partsused2s22 = _T("");
m_partsused3s22 = _T("");
m_phonenums22 = _T("");
m_rmas22 = _T("");
m_servpref1s22 = _T("");
m_servpref2s22 = _T("");
m_servpref3s22 = _T("");
m_tech1s22 = _T("");
m_tech2s22 = _T("");
m_tech3s22 = _T("");
m_vendors22 = _T("");
m_starttime12 = 0.0;
m_starttime22 = 0.0;
m_starttime32=0.0;
m_endtime12=0.0;
m_endtime22=0.0;
m_endtime32=0.0;
m_hours12=0.0;
m_hours22=0.0;
m_hours32=0.0;
m_price12=0.0;
m_price22=0.0;
m_price32=0.0;
m_qty12=0.0;
m_qty22=0.0;
m_qty32=0.0;
m_tot2=0.0;
m_totlab2=0.0;
m_totprice2=0.0;
m_travel12=0.0;
m_travel22=0.0;
m_travel32=0.0;
m_calldate = time_t(0);
//}}AFX_DATA_INIT
}
void CServiceDialog::DoDataExch
{
CDialog::DoDataExchange(pD
//{{AFX_DATA_MAP(CServiceD
DDX_Text(pDX, IDC_BILLTRAVEL_EDIT, m_billtravel);
DDX_Text(pDX, IDC_TOTINV_EDIT, m_totinv);
DDX_Text(pDX, IDC_TOTLABOUR_EDIT, m_totlabour);
DDX_Text(pDX, IDC_TOTPARTS_EDIT, m_totparts);
DDX_Text(pDX, IDC_TOTTAVEL_EDIT, m_tottravel);
DDX_Text(pDX, IDC_BILLTIME_EDIT, m_billtime);
DDX_Text(pDX, IDC_RATELABOUR_EDIT, m_ratelabour);
DDX_Text(pDX, IDC_RATETRAVEL_EDIT, m_ratetravel);
DDX_Text(pDX, IDC_CUSTNUM_EDIT, m_custnum);
DDX_Text(pDX, IDC_ORDERNUM_EDIT, m_ordernum);
DDX_Text(pDX, IDC_ADDRESS_EDIT, m_address);
DDX_CBString(pDX, IDC_ASSIGNED_COMBO, m_assigned);
DDX_CBString(pDX, IDC_BILLCODE_COMBO, m_billcode);
DDX_Text(pDX, IDC_COMPANY_EDIT, m_company);
DDX_Text(pDX, IDC_CONTACT_EDIT, m_contact);
DDX_Text(pDX, IDC_CONTRACT_EDIT, m_contract);
DDX_Text(pDX, IDC_CUSTPONUM_EDIT, m_custponum);
DDX_Text(pDX, IDC_CUSTREF_EDIT, m_custref);
DDX_Text(pDX, IDC_FAXNUM_EDIT, m_faxnum);
DDX_Text(pDX, IDC_MAKEMOD_EDIT, m_makemod);
DDX_Check(pDX, IDC_ONSITE_CHECK, m_onsite);
DDX_CBString(pDX, IDC_OPERSYS_COMBO, m_opersys);
DDX_Text(pDX, IDC_PHONENUM_EDIT, m_phonenum);
DDX_Text(pDX, IDC_PROBLEM_EDIT, m_problem);
DDX_Text(pDX, IDC_PROMISED_EDIT, m_promised);
DDX_Text(pDX, IDC_RESPONSE_EDIT, m_response);
DDX_Text(pDX, IDC_SERIALNUM_EDIT, m_serialnum);
DDX_CBString(pDX, IDC_SERVTYPE_COMBO, m_servtype);
DDX_Text(pDX, IDC_SITEADDRESS_EDIT, m_siteaddress);
DDX_Text(pDX, IDC_SOFTWARE_EDIT, m_software);
DDX_CBString(pDX, IDC_STATUS_COMBO, m_status);
DDX_CBString(pDX, IDC_URGENCY_COMBO, m_urgency);
DDX_Text(pDX, IDC_VERSION_EDIT, m_version);
DDX_CBString(pDX, IDC_WAITPARTS_COMBO, m_waitparts);
DDX_Text(pDX, IDC_CALLDATE_EDIT, m_calldate);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CService
//{{AFX_MSG_MAP(CServiceDi
ON_BN_CLICKED(IDC_PAGE2_BU
ON_BN_CLICKED(IDC_EXIT_BUT
ON_BN_CLICKED(IDC_CALC_BUT
ON_BN_CLICKED(IDC_PRINT_BU
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//////////////////////////
// CServiceDialog message handlers
void CServiceDialog::OnPage2But
{
// TODO: Add your control notification handler code here
//sets varibles to another page
UpdateData(TRUE);
OnOK();
CService2Dialog Srv2Dlg;
Srv2Dlg.m_calldate2 = m_calldate;
Srv2Dlg.m_custnum2 = m_custnum;
Srv2Dlg.m_address2 =m_address;
Srv2Dlg.m_assigned2 =m_assigned;
Srv2Dlg.m_company2 =m_company;
Srv2Dlg.m_contact2 =m_contact;
Srv2Dlg.m_contract2 =m_contract;
Srv2Dlg.m_custponum2 =m_custponum;
Srv2Dlg.m_custref2 =m_custref;
Srv2Dlg.m_faxnum2 =m_faxnum;
Srv2Dlg.m_makemod2 =m_makemod;
Srv2Dlg.m_opersys2 =m_opersys;
Srv2Dlg.m_ordernum2 =m_ordernum;
Srv2Dlg.m_phonenum2 =m_phonenum;
Srv2Dlg.m_problem2 = m_problem;
Srv2Dlg.m_promised2 = m_promised;
Srv2Dlg.m_response2 = m_response;
Srv2Dlg.m_serialnum2 =m_serialnum;
Srv2Dlg.m_servtype2 = m_servtype;
Srv2Dlg.m_siteaddress2 =m_siteaddress;
Srv2Dlg.m_software2 = m_software;
Srv2Dlg.m_status2 = m_status;
Srv2Dlg.m_urgency2 = m_urgency;
Srv2Dlg.m_version2 = m_version;
Srv2Dlg.m_waitparts2 = m_waitparts;
Srv2Dlg.m_billcode2 = m_billcode;
Srv2Dlg.m_onsite2 = m_onsite;
Srv2Dlg.m_contacts2=m_cont
Srv2Dlg.m_dates2=m_dates22
Srv2Dlg.m_date1s2=m_date1s
Srv2Dlg.m_date12s2=m_date1
Srv2Dlg.m_date2s2=m_date2s
Srv2Dlg.m_date3s2=m_date3s
Srv2Dlg.m_extension1s2=m_e
Srv2Dlg.m_extension2s2=m_e
Srv2Dlg.m_extension3s2=m_e
Srv2Dlg.m_faxnums2=m_faxnu
Srv2Dlg.m_loanagrees2=m_lo
Srv2Dlg.m_ourponums2=m_our
Srv2Dlg.m_partnum1s2=m_par
Srv2Dlg.m_partnum2s2=m_par
Srv2Dlg.m_partnum3s2=m_par
Srv2Dlg.m_partsused1s2=m_p
Srv2Dlg.m_partsused2s2=m_p
Srv2Dlg.m_partsused3s2=m_p
Srv2Dlg.m_phonenums2=m_pho
Srv2Dlg.m_rmas2=m_rmas22;
Srv2Dlg.m_servpref1s2=m_se
Srv2Dlg.m_servpref2s2=m_se
Srv2Dlg.m_servpref3s2=m_se
Srv2Dlg.m_tech1s2=m_tech1s
Srv2Dlg.m_tech2s2=m_tech2s
Srv2Dlg.m_tech3s2=m_tech3s
Srv2Dlg.m_vendors2=m_vendo
Srv2Dlg.m_starttime1= m_starttime12;
Srv2Dlg.m_starttime2=m_sta
Srv2Dlg.m_starttime3=m_sta
Srv2Dlg.m_endtime1=m_endti
Srv2Dlg.m_endtime2=m_endti
Srv2Dlg.m_endtime3=m_endti
Srv2Dlg.m_hours1=m_hours12
Srv2Dlg.m_hours2=m_hours22
Srv2Dlg.m_hours3=m_hours32
Srv2Dlg.m_price1=m_price12
Srv2Dlg.m_price2=m_price22
Srv2Dlg.m_price3=m_price32
Srv2Dlg.m_qty1=m_qty12;
Srv2Dlg.m_qty2=m_qty22;
Srv2Dlg.m_qty3=m_qty32;
Srv2Dlg.m_tot=m_tot2;
Srv2Dlg.m_totlab=m_totlab2
Srv2Dlg.m_totprice=m_totpr
Srv2Dlg.m_travel1=m_travel
Srv2Dlg.m_travel2=m_travel
Srv2Dlg.m_travel3=m_travel
Srv2Dlg.DoModal();
}
void CServiceDialog::OnExitButt
{
// TODO: Add your control notification handler code here
//connects to another dialog box to save info
CSaveDialog SaveDlg;
SaveDlg.DoModal();
OnOK();
}
void CServiceDialog::OnCalcButt
{
// TODO: Add your control notification handler code here
//does simple calulates in my dialog
UpdateData(TRUE); // get data from controls
m_tottravel=m_billtravel*m
m_totlabour=m_billtime*m_r
m_totinv=m_totparts+m_tott
cout<<m_tottravel;
cout<<m_totlabour;
cout<<m_totinv;
UpdateData(FALSE); // send data to controls
}
void CServiceDialog::OnPrintBut
{
// TODO: Add your control notification handler code here
//Here is the print button which I want to print from.
//Please place the code here.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
trestan, no offence, but he needs to create the printer DC, OnPrint is only called for Doc/View applications.
You are right. I ignored that.
ASKER
I am getting 2 errors when I but in the code.
1. the OnBeginPrinting is not declared
2. the OnEnd Printing is not declared
can you tell me what to do and what to place in the functions if I have to make them.
I am a beginner at this and I need help.
1. the OnBeginPrinting is not declared
2. the OnEnd Printing is not declared
can you tell me what to do and what to place in the functions if I have to make them.
I am a beginner at this and I need help.
Now to printing...
In a Doc/View application MFC does most of the work for you. Unfortunately in a dialog based application, you need to write code to initialize the printer, etc.
When printing you "draw" to the printer using an HDC (which is encapsulated in the MFC class CDC)
Here is a sample, I've sorta adapted for your app
void CServiceDialog::OnPrintBut
{
CDC dc;
CPrintDialog printDlg(FALSE);
//---> you can setup members of printDlg here to allow
// printing of a selection, or to allow only the "all pages"
// option, m_pd member of printDlg contains most of the
// options, m_pd.Flags is the main one you're probably
// interested in
if (printDlg.DoModal() == IDCANCEL) // Get printer settings from user
return;
dc.Attach(printDlg.GetPrin
dc.m_bPrinting = TRUE;
CString strTitle; // Get the application title
//---> change this if you want to print under a differnt
// title, this is used for the print job name.
strTitle.LoadString(AFX_ID
DOCINFO di; // Initialise print document details
::ZeroMemory (&di, sizeof (DOCINFO));
di.cbSize = sizeof (DOCINFO);
di.lpszDocName = strTitle;
BOOL bPrintingOK = dc.StartDoc(&di); // Begin a new print job
// Get the printing extents and store in the m_rectDraw field of a
// CPrintInfo object
CPrintInfo Info;
Info.m_rectDraw.SetRect(0,
dc.GetDeviceCaps(HORZRES),
dc.GetDeviceCaps(VERTRES))
OnBeginPrinting(&dc, &Info); // Call your "Init printing" funtion
for (UINT page = Info.GetMinPage();
page <= Info.GetMaxPage() && bPrintingOK;
page++)
{
dc.StartPage(); // begin new page
Info.m_nCurPage = page;
//---> add your code to "draw" here
// you may prefer to put it in another function and call that
// for example,
dc.TextOut( 0, 0, "Hello world" ) ;
// will "draw" this phrase at the top left of the page
bPrintingOK = (dc.EndPage() > 0); // end page
}
OnEndPrinting(&dc, &Info); // Call your "Clean up" funtion
if (bPrintingOK)
dc.EndDoc(); // end a print job
else
dc.AbortDoc(); // abort job.
dc.Detach(); // detach the printer DC
}