Link to home
Start Free TrialLog in
Avatar of RanBN
RanBN

asked on

Change title to an object from CPrintDialog class

hi,
I would like to change on run time the title of CPrintDialog dialog. I cannot inherit it. is there a way to do so by using one of its members?
thanks in advance, RanBN
Avatar of GloriousRain
GloriousRain

Use SetWindowText in OnInitDialog, RanBN
Ex:
BOOL CYourDlg::OnInitDialog()
{
...
   SetWindowText("YourTitle");
...
}
ok, if you cannot inherit it, instantiate a CPrintDialog object then call SetWindowText()
Ex:
...
CPrintDialog dlg(FALSE);
dlg.SetWindowText("YourTitle")
...
Avatar of RanBN

ASKER

thanks but,
before DoModal(), hWnd member is NULL, therefore SetWindowText fails.
Avatar of Meir Rivkin
why can't u create your own CPrintDialog derived class?
in the constructor u can send a CString which would later be the title of your CPrintDialog:

//constructor
CMyPrintDialog::CMyPrintDialog(CString sTitle, bool bPrintSetupOnly, ...)
{
m_strTitle = sTitle;
}

CMyPrintDialog::OnInitDialog()
{
     CPrintDialog::OnInitDialog();
     
     SetWindowText(m_strTitle);
     return TRUE;  
}


the code to display your CPrintDialog:
CMyPrintDialog dlg("My Print Dialog", FALSE);    
dlg.DoModal();



good luck
the other way i think is to use modaless CPrintDialog and after ->Create() use SetWindowText to change its title, and ShowWindow() to display it.

Avatar of RanBN

ASKER

Hi and thanks again,
please let me be more specific about my request:
I would like to take the original CPrintDialog, the one which is located when I click on the standard toolBar "File->Print".
well, I would like to change it my my CMyView class. according the MSDN help, I should override massage OnPreparePrinting(CPrintInfo* pInfo).
in class CPrintInfo there is a member m_pPD which provides information about the Print dialog. does anyone know what to do with it in order to change caption?
thanks, RanBN
Avatar of RanBN

ASKER

Hi and thanks again,
please let me be more specific about my request:
I would like to take the original CPrintDialog, the one which is located when I click on the standard toolBar "File->Print".
well, I would like to change it my my CMyView class. according the MSDN help, I should override massage OnPreparePrinting(CPrintInfo* pInfo).
in class CPrintInfo there is a member m_pPD which provides information about the Print dialog. does anyone know what to do with it in order to change caption?
thanks, RanBN
as far as i know there's no member in PRINTDLG (m_pd) which is the caption. (according to MSDN)
Avatar of RanBN

ASKER

the m_pPD is a pointer to CPrintDialog, but its m_hWnd member is NULL when I have it OnPreparePrinting.
does anyone have an idea?
thanks, RanBN
ASKER CERTIFIED SOLUTION
Avatar of migel
migel

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
oops
m_pPD
 must be
pInfo->m_pPD
Avatar of RanBN

ASKER

thanks alot