-
February 19th, 2004, 02:57 PM
#1
GetWindow reurns NULL when printing
My application is a SDI with three splitter windows. I want to print one of the windows which contains a graph (Brian Convery's X-Y line graph). A CDC pointer pDC is passed to a function called CGraph::PrintGraphBase(CDC *pDC) when OnDraw is called. In this function pDC->GetWindow is called. But the function returns NULL. I don't know why but when looking in MSDN I find,
"This is an advanced function. For example, this member function may not return the view window when printing or in print preview"
...may not...
What is this?
Is there another function to use to get the window from the pDC?
-
February 20th, 2004, 08:54 AM
#2
A HDC is ually associated with a window, but in the case of printing or print previewing, the HDC is of a Printer Device Context. These do not have a window associated with them.
If you code you will probably have to check to see whether its a printer device ontext in use, and if it is, get he window in question a different way:
if (pDC->IsPrinting())
{
GetParent()
}
else
{
GetWindow()
}
Now, I am not familiar with the graph control you mentioned, but if its a child window, then you can probably just call GetParent() to return the view its drawing itself in. If its not a window of some sort, then you may have a more difiicult time getting the HWND you need.
Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
Please remember to rate useful answers. It lets us know when a question has been answered.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|