Solved

print preview doesn't work !!!

Posted on 1998-02-20
2
221 Views
Last Modified: 2013-11-20
I have implemented a print preview in my mdi-application. When the print preview is called the following OnDraw-function will be executed:

void CMyView::OnDraw(CDC* pDC)
{
  CString text=_T("This is a test");
  pDC->SetTextColor(RGB(255,0,0)); // or any other color
  pDC->SetBkColor(::GetSysColor(COLOR_WINDOW));
  GetClientRect(rect);
  pDC->DrawText(text,-1,rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
}

There is now a problem:
In print preview the text color will not be displayed !!!
The text string will always painted in black !!!

How can I change the color to that I want to have in print preview ?
I can debug the above code and the text color is the one I wanted to have but the screen shows always a black text !!!

Any ideas about that ?
0
Comment
Question by:atari
2 Comments
 
LVL 7

Accepted Solution

by:
galkin earned 30 total points
ID: 1316451
When you display your document in print preview you are dealing with two device contexts. First is printer device context the secont is window DC. two members m_hDC and m_hAttribDC in MFC CDC class define these DCs. In spite of the fact you actually draw on preview window DC it has the same properties as printer DC. Since you are likely to be printing on b/w printer print preview window DC also uses only black and white.
0
 
LVL 1

Author Comment

by:atari
ID: 1316452
Thank you, I will try it with a color printer and then I hope that the print preview shows my text in color.

Cannot try it at once, so I will graduade you before.

Bye,
atari
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Show shut-down message as Windows 8 shuts down. 9 90
Windows Drag & Drop Location 2 100
if loop in java 3 139
building a service to accessed via telnet client, want colors ? 4 88
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli‚Ķ
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

806 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question