| | |
RichEdit printing!
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2009
Posts: 5
Reputation:
Solved Threads: 0
Hi everyone, I am trying to print content from a Win32 richedit control, but it doesn't work. The text wraps to the half width of the page, and after printing, the text in the richedit is also messed up (word wrap to the half width of the box).
I use this unmodified code taken directly from MSDN:
Any thoughts?
Thanks in advance!
I use this unmodified code taken directly from MSDN:
C++ Syntax (Toggle Plain Text)
bool PrintRTF(HWND Handle, HDC PrinterDC) { DOCINFO di = { sizeof(di) }; if (!StartDoc(PrinterDC, &di)) { return false; } int cxPhysOffset = GetDeviceCaps(PrinterDC, PHYSICALOFFSETX); int cyPhysOffset = GetDeviceCaps(PrinterDC, PHYSICALOFFSETY); int cxPhys = GetDeviceCaps(PrinterDC, PHYSICALWIDTH); int cyPhys = GetDeviceCaps(PrinterDC, PHYSICALHEIGHT); SendMessage(Handle, EM_SETTARGETDEVICE, (WPARAM)PrinterDC, cxPhys / 2); FORMATRANGE fr; fr.hdc = PrinterDC; fr.hdcTarget = PrinterDC; fr.rc.left = cxPhysOffset; fr.rc.right = cxPhysOffset + cxPhys; fr.rc.top = cyPhysOffset; fr.rc.bottom = cyPhysOffset + cyPhys; SendMessage(Handle, EM_SETSEL, 0, (LPARAM)-1); SendMessage(Handle, EM_EXGETSEL, 0, (LPARAM)&fr.chrg); bool fSuccess = true; while (fr.chrg.cpMin < fr.chrg.cpMax && fSuccess) { fSuccess = StartPage(PrinterDC) > 0; if (!fSuccess) break; int cpMin = SendMessage(Handle, EM_FORMATRANGE, true, (LPARAM)&fr); if (cpMin <= fr.chrg.cpMin) { fSuccess = false; break; } fr.chrg.cpMin = cpMin; fSuccess = EndPage(PrinterDC) > 0; } SendMessage(Handle, EM_FORMATRANGE, false, 0); if (fSuccess) { EndDoc(PrinterDC); } else { AbortDoc(PrinterDC); } DeleteDC(PrinterDC); return fSuccess; }
Any thoughts?
Thanks in advance!
![]() |
Similar Threads
- edges of print missing when printing web pages (Web Browsers)
- Windows 2000 Adv Server and "Printing Subsystem" (Windows NT / 2000 / XP)
- Problem printing from IE6 (Web Browsers)
- Mac10.3 Printing Problems (OS X)
- WinXP, RH9, Samba, and Printing (*nix Software)
- Printing pictures (Windows NT / 2000 / XP)
- Linux printing questions (*nix Hardware Configuration)
Other Threads in the C++ Forum
- Previous Thread: Add compression to my program
- Next Thread: Homework help: undefined reference error
| Thread Tools | Search this Thread |
aim ajax aol api appengine application array asp assignment beginner binary bitmap blogger blogging c# c++ char char* class cloud code compression console delete developer development directshow download email encryption error eweek facebook faq file fstream function functions game gdata google graph guess hardcopy int introduction java linux linuxmagazine magazines math messaging modal music myspace mysql network networking news node numbers objects opengl opensource output php primenumbersinrange print problem professor program programming python read recursion recursive registry rss sandbox search server socialnetwork store string template text textbox traverse tree unix url variable visual voice voip win32 windows winsock wxwidgets xml






