Click here to Skip to main content
15,910,471 members
Home / Discussions / C#
   

C#

 
QuestionDraw rtf on user control Pin
ZGelic28-Apr-09 4:49
ZGelic28-Apr-09 4:49 
AnswerRe: Draw rtf on user control Pin
Tom Deketelaere28-Apr-09 4:52
professionalTom Deketelaere28-Apr-09 4:52 
GeneralRe: Draw rtf on user control Pin
ZGelic28-Apr-09 4:57
ZGelic28-Apr-09 4:57 
GeneralRe: Draw rtf on user control Pin
Tom Deketelaere28-Apr-09 5:01
professionalTom Deketelaere28-Apr-09 5:01 
AnswerRe: Draw rtf on user control Pin
0x3c028-Apr-09 5:41
0x3c028-Apr-09 5:41 
GeneralRe: Draw rtf on user control Pin
Luc Pattyn28-Apr-09 6:46
sitebuilderLuc Pattyn28-Apr-09 6:46 
GeneralRe: Draw rtf on user control Pin
0x3c028-Apr-09 7:06
0x3c028-Apr-09 7:06 
GeneralRe: Draw rtf on user control Pin
Luc Pattyn28-Apr-09 7:22
sitebuilderLuc Pattyn28-Apr-09 7:22 
public void DrawToBitmap(Bitmap bitmap) {
	//Calculate the area to render and print
	RECT rectToPrint;
	rectToPrint.Top = 0;
	rectToPrint.Bottom = (int)(bitmap.Height*anInch);
	rectToPrint.Left = 0;
	rectToPrint.Right = (int)(bitmap.Width*anInch);

	//Calculate the size of the page
	RECT rectPage;
	rectPage.Top = 0;
	rectPage.Bottom = (int)(bitmap.Height*anInch);
	rectPage.Left = 0;
	rectPage.Right = (int)(bitmap.Width*anInch);

	Graphics g=Graphics.FromImage(bitmap);
	IntPtr hdc = g.GetHdc();

	FORMATRANGE fmtRange;
	// [0,-1]=everything
	fmtRange.chrg.cpMax = -1;				//Indicate character from to character to 
	fmtRange.chrg.cpMin = 0;
	fmtRange.hdc = hdc;                    //Use the same DC for measuring and rendering
	fmtRange.hdcTarget = hdc;              //Point at printer hDC
	fmtRange.rc = rectToPrint;             //Indicate the area on page to print
	fmtRange.rcPage = rectPage;            //Indicate size of page

	IntPtr res = IntPtr.Zero;

	IntPtr wparam = IntPtr.Zero;
	wparam = new IntPtr(1);

	//Get the pointer to the FORMATRANGE structure in memory
	IntPtr lparam= IntPtr.Zero;
	lparam = Marshal.AllocCoTaskMem(Marshal.SizeOf(fmtRange));
	Marshal.StructureToPtr(fmtRange, lparam, false);

	//Send the rendered data for printing 
	res = SendMessage(Handle, EM_FORMATRANGE, wparam, lparam);

	//Free the block of memory allocated
	Marshal.FreeCoTaskMem(lparam);

	//Release the device context handle obtained by a previous call
	g.ReleaseHdc(hdc);

}


Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in


GeneralRe: Draw rtf on user control Pin
ZGelic28-Apr-09 9:30
ZGelic28-Apr-09 9:30 
GeneralRe: Draw rtf on user control Pin
Jim Crafton28-Apr-09 9:39
Jim Crafton28-Apr-09 9:39 
GeneralRe: Draw rtf on user control Pin
ZGelic28-Apr-09 10:39
ZGelic28-Apr-09 10:39 
QuestionHow to access internal methods Pin
Andre Vianna28-Apr-09 4:38
Andre Vianna28-Apr-09 4:38 
AnswerRe: How to access internal methods Pin
Heywood28-Apr-09 4:52
Heywood28-Apr-09 4:52 
AnswerRe: How to access internal methods Pin
S. Senthil Kumar30-Apr-09 9:56
S. Senthil Kumar30-Apr-09 9:56 
Questionassigning ownership of files and folders??? Pin
lane0p228-Apr-09 4:22
lane0p228-Apr-09 4:22 
Questionc# or c++ image processing? Pin
Jon Hulatt28-Apr-09 3:58
Jon Hulatt28-Apr-09 3:58 
QuestionRe: c# or c++ image processing? Pin
led mike28-Apr-09 9:05
led mike28-Apr-09 9:05 
AnswerRe: c# or c++ image processing? Pin
Jon Hulatt28-Apr-09 21:35
Jon Hulatt28-Apr-09 21:35 
QuestionRe: c# or c++ image processing? Pin
led mike29-Apr-09 5:36
led mike29-Apr-09 5:36 
Questiondll security flaw Pin
ferroariel28-Apr-09 3:30
ferroariel28-Apr-09 3:30 
Question[Message Deleted] Pin
bhargava240928-Apr-09 3:01
bhargava240928-Apr-09 3:01 
AnswerRe: 3D Auto Cadd viewer Pin
musefan28-Apr-09 3:05
musefan28-Apr-09 3:05 
AnswerRe: 3D Auto Cadd viewer Pin
Simon P Stevens28-Apr-09 3:49
Simon P Stevens28-Apr-09 3:49 
General[Message Deleted] Pin
bhargava240930-Apr-09 2:02
bhargava240930-Apr-09 2:02 
GeneralRe: 3D Auto Cadd viewer Pin
Simon P Stevens30-Apr-09 2:50
Simon P Stevens30-Apr-09 2:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.