Link to home
Start Free TrialLog in
Avatar of morefalt
morefalt

asked on

CPrintSetupDialog

Hi!

I have a problem with CPageSetupDialog. I have two classes CMyclass1 (in the first DLL) and CMyclass2 (in the second DLL) that use my CMyPrint-class (in a third DLL). From CMyclass1 CPageSetupDialog work great, but form CMyclass2 CPrintSetupDialog hangs when I call DoModa(). I have traced it to the API call to PrintSetupDlg().

Do anyone have a clue how to findout why??

Thank's in advance.
Bertil Morefeldt

My code look like this:

void CMyclass1::PrintAkut(long lID)
{
      CMyPrint clPrint;
      CString szRapport = ".\\Rapporter\\Akut.rpt";
      CString szSQL;
      szSQL.Format("{Akut.Uh_id}=%ld",lID);
      clPrint.Print(GetRptEngine(),GRANSKA,1,szRapport,szSQL);
}

void CMyclass2::PrintReciept(long lID)
{
      CMyPrint clPrint;
      CString szRapport = ".\\Rapporter\\NyckelReciept.rpt";
      CString szSQL;
      szSQL.Format("{NyckelUtl.ID}=%ld",nID);
      clPrint.Print(GetRptEngine(),SKRIVUT,1,szRapport,szSQL);
}

void CMyPrint::Print(....)
{
.....
....
CPageSetupDialog dlg;
dlg.m_psd.hDevMode    = NULL;
dlg.m_psd.hDevNames   = NULL;
if( dlg.DoModal() == IDOK )
{
      if(!pJob->SelectPrinter(dlg.GetDriverName(),
            dlg.GetDeviceName(),
            dlg.GetPortName(),0) )
      {
            AfxMessageBox(pEngine->GetErrorText());
            GlobalFree(dlg.m_psd.hDevMode);
            GlobalFree(dlg.m_psd.hDevNames);
            return FALSE;
      }
}
GlobalFree(dlg.m_psd.hDevMode);
GlobalFree(dlg.m_psd.hDevNames);
....
....
}

I an using Visual C++ 6.0 an WinNT 4.0 sp 4.
Avatar of morefalt
morefalt

ASKER

Adjusted points to 500
Hi
cannot figure out why by the code snippet so
If it is OK with U can U send me the files my email id is inpras@hotmail.com
Just a interest OK
Regards
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial