Not Solved Yet. Just Create an SDI Application and insert the following codes in OnDraw() CRect rcPos = CRect(10,10,500,40); CFont font; LOGFONT lf; ZeroMemory(&lf,sizeof(lf)); lf.lfHeight = 25; lstrcpy(lf.lfFaceName,"Arial"); lf.lfWeight = FW_BOLD; lf.lfCharSet = DEFAULT_CHARSET; font.CreateFontIndirect(&lf); pDC->SelectObject(&font); CString str = "Sample Text1 Sample Text1 Sample Text1"; pDC->DrawText(str, &rcPos, DT_LEFT|DT_VCENTER|DT_SINGLELINE); font.DeleteObject(); rcPos.top += 30; rcPos.bottom += 30; lf.lfHeight = 30; lstrcpy(lf.lfFaceName,"Comic Sans MS"); font.CreateFontIndirect(&lf); pDC->SelectObject(&font); str = "Sample Text2 Sample Text2"; pDC->DrawText(str, &rcPos, DT_LEFT|DT_VCENTER|DT_SINGLELINE); font.DeleteObject();
and insert following code to OnPrepareDC() pDC->SetMapMode(MM_ANISOTROPIC); CSize sizeDoc = CSize(1000,1000); pDC->SetWindowExt(sizeDoc); CDC dcScreen; dcScreen.CreateCompatibleDC(0); int nLogPixelX = dcScreen.GetDeviceCaps(LOGPIXELSX); int nLogPixelY = dcScreen.GetDeviceCaps(LOGPIXELSY); int nDevPixelX = pDC->GetDeviceCaps(LOGPIXELSX); int nDevPixelY = pDC->GetDeviceCaps(LOGPIXELSY); if (nLogPixelX != nDevPixelX || nLogPixelY != nDevPixelY) { sizeDoc.cx = (sizeDoc.cx * nDevPixelX) / nLogPixelX; sizeDoc.cy = (sizeDoc.cy * nDevPixelY) / nLogPixelY; } pDC->SetViewportExt(sizeDoc);
Now run the exe. and see print preview.
Anik33
Posts
-
Text Draw problem with Print Preview -
Text Draw problem with Print PreviewI am using Visual Studio 6.0. Print preview changes text width on different zoom view. Let me describe in details.(Tested in an SDI application) I want to draw a text "Sample text1 Sample text1 Sample text1" whose font size is 10 and face is Arial.Just below this text I want to draw another text "Sample text2 Sample text2" whose font size is 15 and face is Comic Sans MS. Both are aligned LEFT or RIGHT.It draws fine. Now when I want to see the print preview it shows different text width than what was drawn previously. Now after zoom in again the view changes. In a word I dont get actual print preview. Can you help me plz?
-
Resource Localization (Polish Character)I am using Visual Studio 6.0. VS resource editor does not support unicode. So when I write some polish characters in string table or dialog controller "??" values are shown. How should I make a resource file/ resource dll for Polish language? Thanks in advance.
-
Smoking & Software Relation?ccc
-
ping a remote serverHi, I need to know whether a remote(in other LAN)host/server is up or down. I can ping any host in my LAN. But when I want to ping any server as for example www.codeproject.com from my pc I get Request timed out message. Thanks in advance. Nayan Kumar Sarkar