15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Problem with 'Print' toolbar

achyuth -- achyuth@geocities.com
Wednesday, December 25, 1996

Hi,

I have a problem with using the 'Print' toolbar. In my application I
want to give 'Word' like interface with the 'Print' toolbar button. I
want to suppress the 'Print' Dialog that will be thrown up. Because the
menu item and the toolbar button refer to the same command, clicking on
the menu item should throw up the 'Print' dialog and clicking on the
toolbar button should print directly with the current print settings.
Can you please tell me how this can be done. 

Environment: Win95 and MSVC 1.52

Thanks

Achyuth



Lin Sebastian Kayser -- Lin.Kayser@munich.netsurf.de
Thursday, December 26, 1996

Achyuth,

You have to assign the undocumented ID_FILE_PRINT_DIRECT instead of =
ID_FILE_PRINT to achieve direct printing to the currently selected =
printer.

Regards,

Lin

-----Original Message-----
From:	achyuth [SMTP:achyuth@geocities.com]
Sent:	Mittwoch, 25. Dezember 1996 08:19
To:	mfc-l@netcom.com
Subject:	Problem with 'Print' toolbar

Hi,

I have a problem with using the 'Print' toolbar. In my application I
want to give 'Word' like interface with the 'Print' toolbar button. I
want to suppress the 'Print' Dialog that will be thrown up. Because the
menu item and the toolbar button refer to the same command, clicking on
the menu item should throw up the 'Print' dialog and clicking on the
toolbar button should print directly with the current print settings.
Can you please tell me how this can be done.=20

Environment: Win95 and MSVC 1.52

Thanks

Achyuth



Michael P Erickson -- mpericks@sprynet.com
Thursday, December 26, 1996

Achyuth wrote:
> 
> Hi,
> 
> I have a problem with using the 'Print' toolbar. In my application I
> want to give 'Word' like interface with the 'Print' toolbar button. I
> want to suppress the 'Print' Dialog that will be thrown up. Because the
> menu item and the toolbar button refer to the same command, clicking on
> the menu item should throw up the 'Print' dialog and clicking on the
> toolbar button should print directly with the current print settings.
> Can you please tell me how this can be done.
> 
> Environment: Win95 and MSVC 1.52
> 
> Thanks
> 
> Achyuth

Look in Help for OnPreparePrinting() which you should override in your view and from 
which you should call DoPreparePrinting().  The Help says

_quote_
"DoPreparePrinting does not display the Print dialog box for a preview job. If you want 
to bypass the Print dialog box for a print job, check that the m_bPreview member of 
pInfo is FALSE and then set it to TRUE before passing it to DoPreparePrinting; reset it 
to FALSE afterwards."
_end_quote_

You'll have to make your toolbar button have a different resource ID than the menu item, 
manually implement the message handler for that ID, set a flag in that handler, call the 
handler for the menu OnFilePrint() or whatever from the toolbar handler after you set 
the flag and then check the flag in OnPreparePrinting to see if the print was initiated 
by the button or the menu.  Of course you'll have to fill in your CPrintInfo data from 
the defaults.  At least that's how I've done it.  There is probably a much slicker way 
to do it but I'm not real good with CDC. HTH

Mike Erickson
The Torrington Co.
mpericks@sprynet.com
erickm@torrington.com



WnDBSoft@aol.com
Saturday, December 28, 1996

In a message dated 96-12-25 15:01:52 EST, you write:

> I have a problem with using the 'Print' toolbar. In my application I
>  want to give 'Word' like interface with the 'Print' toolbar button. I
>  want to suppress the 'Print' Dialog that will be thrown up. Because the
>  menu item and the toolbar button refer to the same command, clicking on
>  the menu item should throw up the 'Print' dialog and clicking on the
>  toolbar button should print directly with the current print settings.
>  Can you please tell me how this can be done. 


In CMyView::OnPreparePrinting (given that CMyView is the view you're printing
from), you want to implement it this way:

// COMMAND handler for a toolbar button ID_FILE_PRINT_DEFAULTS
void CMyView::OnPrintDefaults( )
{
        // m_bPrintDefaults is a BOOL member of CMyView initialized to FALSE
in the
        // constructor
        m_bPrintDefaults = TRUE;
        OnFilePrint( );
}

BOOL CMyView::OnPreparePrinting(CPrintInfo* pInfo)
{
        if (m_bPrintDefaults)
                pInfo->m_bPreview = TRUE;
        BOOL bResult = C/**/View::DoPreparePrinting( pInfo );
        return bResult;
}

And voila!  Hope that helps!

Sincerely,
Brian Hart




| Вернуться в корень Архива |