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.
morefaltAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.