From: Hans-J. Ude on
In my drawing I have different options, depending on the device
(printer, screen or metafile). To distinguish them, I thought to use
their DCs. The following code seems to work but I wonder if it's
reliable in any case. Any purposes?

void CChordView::OnDraw(CDC* pDC)
{
BOOL bMetafile = FALSE;

if (pDC->m_bPrinting) // Printer or Preview
{
...
}
else // Screen or Metafile
{
if (pDC->m_hAttribDC != pDC->m_hDC)
bMetafile = TRUE;
}
...
}

TIA,
Hans

From: Joseph M. Newcomer on
One of the questions is "Why would it make a difference?"; you need to say why you think
you need to do something different (I have never had to make this test). Most commonly,
there are issues that often have a simpler solution than the conditional code, but without
knowing the problem you are trying to solve, it is hard to suggest which one should work.
joe

On Thu, 20 May 2010 15:55:03 +0200, Hans-J. Ude <news(a)s237965939.online.de> wrote:

>In my drawing I have different options, depending on the device
>(printer, screen or metafile). To distinguish them, I thought to use
>their DCs. The following code seems to work but I wonder if it's
>reliable in any case. Any purposes?
>
>void CChordView::OnDraw(CDC* pDC)
>{
> BOOL bMetafile = FALSE;
>
> if (pDC->m_bPrinting) // Printer or Preview
> {
> ...
> }
> else // Screen or Metafile
> {
> if (pDC->m_hAttribDC != pDC->m_hDC)
> bMetafile = TRUE;
> }
> ...
>}
>
>TIA,
>Hans
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Hans-J. Ude on
Joseph M. Newcomer schrieb:

>One of the questions is "Why would it make a difference?"; you need to say why you think
>you need to do something different (I have never had to make this test). Most commonly,
>there are issues that often have a simpler solution than the conditional code, but without
>knowing the problem you are trying to solve, it is hard to suggest which one should work.
> joe

My program finds how to play guitar chords, i.e. you enter "Em7/9" and
it finds up to 50 different ways where to put your fingers. When I
print them out all together, I need headers and footers (name, tuning,
page number, etc.) and they have numbers to identify because all have
the same name. When I copy a single object to the clipboard
(metafile), i need their name instead of number. And on screen they
need to be rearranged in rows and cols when window size changes.
That all works but I'm not sure if it's bullet proof under any
condition.

Hans

From: Joseph M. Newcomer on
OK, that is a reasonable need. Frankly, I just let the headings and page numbers appear
in the preview, but it is a matter of taste. I was concerned that you were doing
(needlessly) complex things with coordinate systems, when you actually should be handling
that uniformly. I've seen some pretty convoluted printer code in my day (back when I was
starting to use MFC, I even wrote some)
joe

On Thu, 20 May 2010 20:09:18 +0200, Hans-J. Ude <news(a)s237965939.online.de> wrote:

>Joseph M. Newcomer schrieb:
>
>>One of the questions is "Why would it make a difference?"; you need to say why you think
>>you need to do something different (I have never had to make this test). Most commonly,
>>there are issues that often have a simpler solution than the conditional code, but without
>>knowing the problem you are trying to solve, it is hard to suggest which one should work.
>> joe
>
>My program finds how to play guitar chords, i.e. you enter "Em7/9" and
>it finds up to 50 different ways where to put your fingers. When I
>print them out all together, I need headers and footers (name, tuning,
>page number, etc.) and they have numbers to identify because all have
>the same name. When I copy a single object to the clipboard
>(metafile), i need their name instead of number. And on screen they
>need to be rearranged in rows and cols when window size changes.
>That all works but I'm not sure if it's bullet proof under any
>condition.
>
>Hans
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm