|
I don't know how to use the "window DC" suggested by you.
The blank page is both on preview (monitor display) and on printer output.
Thanks.
mnnca
|
|
|
|
|
I've just tried something else: I use different code (from an old proj) and it works ok now in both debug and release mode.
In a previous post, the OnPrepareDC is from a MFC sample.
void CDISKVERView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
CFormView::OnPrepareDC(pDC, pInfo);
CClientDC dcScreen(NULL); //Get the display's device context
pDC->SetMapMode(MM_ANISOTROPIC); //Map aspect ratio
// map 1 screen logical inch to 1 printer (/output) logical inch
pDC->SetWindowExt(dcScreen.GetDeviceCaps(LOGPIXELSX),
dcScreen.GetDeviceCaps(LOGPIXELSY)); //Window is display
pDC->SetViewportExt((2*pDC->GetDeviceCaps(LOGPIXELSX)),
(2*pDC->GetDeviceCaps(LOGPIXELSY))); //Viewport is printer
}
mnnca
|
|
|
|
|
mnnca wrote: // map 1 screen logical inch to 1 printer (/output) logical inch
Aren't you mapping 1 screen logical inch to 2 printer logical inches?
I'm still not sure why the other one worked in one build mode and not the other...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The comment didnt match the code, however, when I tried 1 to 1 mapping, it works the same (I dont really know why).
When it works with the old code, I was so relieved that I didnt investigate more into the problem.
After reading your post, I went back and traced all the code and found out why it didnt work (in release mode only):
the only code which was missing is the SetMapMode in the OnPrint(...)which made it not work:
void CDISKVERView::OnPrint(CDC* pDC, CPrintInfo* pInfo /*pInfo*/)
{
pDC->SetMapMode(MM_LOENGLISH);
CDISKVERView::PrintPage( pDC, pInfo);
}
when I add that line in the old prj file, it works. I dont understand why though.
mnnca
|
|
|
|
|
mnnca wrote: when I add that line in the old prj file, it works. I dont understand why though.
That's a good sign that OnPrepareDC() wasn't setting up the DC the way the code
doing the printing ( CDISKVERView::PrintPage()) was expecting. That's certainly a
different map mode than OnPrepareDC() is using
So did you get it all working the way you wanted??
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I've just read the def of the map modes:
MM_ANISOTROPIC Logical units are converted to arbitrary units with arbitrarily scaled axes.
It didnt work because it was set to that mode (again code is from a sample).
Now it works because right before printing, the mode is re-set to
MM_LOENGLISH Each logical unit is converted to 0.01 inch. Positive x is to the right; positive y is up.
It makes sense.
Thanks for helping.
mnnca
|
|
|
|
|
mnnca wrote: Thanks for helping.
I think I've only provided emotional support LOL
Anyway, OnPrepareDC() is called before OnPrint() is repeatedly called for each page,
so you are overriding any map mode set in OnPrepareDC().
If you want to, you can remove the code you have in OnPrepareDC() and
replace it with the pDC->SetMapMode(MM_LOENGLISH); call.
This should work the same:
void CDISKVERView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
CFormView::OnPrepareDC(pDC, pInfo);
pDC->SetMapMode(MM_LOENGLISH);
}
void CDISKVERView::OnPrint(CDC* pDC, CPrintInfo* pInfo )
{
CDISKVERView::PrintPage( pDC, pInfo);
} Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes, the scale mode should be set in OnPrepareDC (cleaner).
mnnca
|
|
|
|
|
Which Font are you using? It can be tht the font in your view fits and is visible, but after conversions to the printer is too small. In my project I had a similar problem. The output was just a single point because my font was so dammned small that a complete sentence was not visible. Take a look to the size of your document, the dimension that you are stablishing and create a compatible font to that dimensions/device printer
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
I think it's a different and strange problem because it works fine in debug mode.
The font I select is the "default" font which user is using, but I control the height and weight so it should not be the problem:
logFont.lfHeight = 35; // 3/4th inch high in MM_LOENGLISH
logFont.lfWeight = 400;//700;//max bold
CFont font;
if (font.CreateFontIndirect(&logFont))
pOldFont = pDC->SelectObject(&font);
Thanks.
mnnca
|
|
|
|
|
Hello,
I have a read only CEdit control on my dialog, when i run the application and there is always wait cursor
( | - this sign of wait cursor) on the Control, How can we hide the cursor?
thanks
|
|
|
|
|
Cursor or caret?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
yeah, i think it is called caret, the sign ( | ) is always flashing on the control
|
|
|
|
|
You could adjust the order of the controls in the dialog
so a different control gets the initial focus.
And/or you can use SetFocus() or WM_NEXTDLGCTL/GotoDlgCtrl()
to move the focus to a different control.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I just saw a method HideCaret(), but it didnt work
this->GetDlgItem(IDC_EDIT1)->HideCaret(); is this right?
|
|
|
|
|
HideCaret is a bad idea unless you're the one that called ShowCaret.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have only one control on my dialog, if so, what should i do?
thanks
|
|
|
|
|
In your dialog class OnOnitDialog() override, try
SetFocus();
...
return FALSE; //<-- just doing this may work
You can also disable the control, but it will look different.
You can also use a static text control, but it too will look different (although
you can maybe use WM_CTLCOLORSTATIC to provide a specific background).
That's all I can think of at the moment
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
No problem.
Did you get a solution? If so, what worked?
BTW, I still think it's silly that read-only edit controls show the caret
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: BTW, I still think it's silly that read-only edit controls show the caret
How else would you copy text from them?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
With the mouse, duh
Well there it is then.. I no longer think it's silly!
Thanks!
MArk
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
No i didnt get any solution, i just thanked for trying to help me.
i still have the same problem
|
|
|
|
|
Gofur Halmurat wrote: How can we hide the cursor?
Can you change the Z-order of the controls, such that this edit control is not the first one given focus? Or, can you disable the control?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
There is only one control on my dialog, yeah, i can disable it, but i need enabled Cedit control, what happens if i change z-order?
thanks
|
|
|
|