| | |
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 application array asp assignment binary bitmap blogger blogging c# c++ char char* class code codeblocks console decide delete developer development download email encryption error exam facebook file fpx fstream function functions game gdata gdi gnu google graph hmenu icon int java keyboard linker linux linuxmagazine magazines math maze messaging modal music myspace mysql network networking news opensource openssh output parallel pearl php picture pong print problem program programming python qt read recursion recursive rss search server socialnetwork store storm string struct symbian template text textbox tree url visual voice voip webzines win32 windows windowsce wxwidgets xml






