[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

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.
0
morefalt
Asked:
morefalt
1 Solution
 
morefaltAuthor Commented:
Adjusted points to 500
0
 
inprasCommented:
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
0
 
chensuCommented:
Probably it is working but you can't see it. Try assigning a valid parent window instead of passing NULL.

CPageSetupDialog(DWORD dwFlags = PSD_MARGINS | PSD_INWININIINTLMEASURE, CWnd* pParentWnd = NULL);
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now