Click here to Skip to main content
15,893,588 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# Build configuration in C# VS 2005 Pin
Dave Kreskowiak30-Oct-07 1:34
mveDave Kreskowiak30-Oct-07 1:34 
QuestionDisplaying a progress bar while executing an SQL Query Pin
yoavyoavyoav29-Oct-07 8:40
yoavyoavyoav29-Oct-07 8:40 
AnswerRe: Displaying a progress bar while executing an SQL Query Pin
Ennis Ray Lynch, Jr.29-Oct-07 8:43
Ennis Ray Lynch, Jr.29-Oct-07 8:43 
GeneralRe: Displaying a progress bar while executing an SQL Query Pin
yoavyoavyoav29-Oct-07 9:21
yoavyoavyoav29-Oct-07 9:21 
GeneralRe: Displaying a progress bar while executing an SQL Query Pin
Ennis Ray Lynch, Jr.29-Oct-07 9:30
Ennis Ray Lynch, Jr.29-Oct-07 9:30 
QuestionBackgroundWorker, delegates, and exceptions? Pin
JerryNakamura29-Oct-07 8:21
JerryNakamura29-Oct-07 8:21 
AnswerRe: BackgroundWorker, delegates, and exceptions? Pin
Nathan Holt at EMOM29-Oct-07 9:28
Nathan Holt at EMOM29-Oct-07 9:28 
Questionprinting String problem Pin
netJP12L29-Oct-07 7:29
netJP12L29-Oct-07 7:29 
Hi guys, I used the class below to print RTF format text on the screen the problem is that once the text is converted into an image by using the class bleow the text letters are not clear, and sharp. The text letter edges are little blurred. Could somebody please help me.

Thanks

<br />
 public class RichTextBoxPrintCtrl : RichTextBox<br />
    {<br />
<br />
        //Convert the unit used by the .NET framework (1/100 inch) <br />
<br />
        //and the unit used by Win32 API calls (twips 1/1440 inch)<br />
<br />
        private const double anInch = 14.4;<br />
<br />
        [StructLayout(LayoutKind.Sequential)]<br />
<br />
        private struct RECT<br />
        {<br />
<br />
            public int Left;<br />
<br />
            public int Top;<br />
<br />
            public int Right;<br />
<br />
            public int Bottom;<br />
<br />
        }<br />
<br />
        [StructLayout(LayoutKind.Sequential)]<br />
<br />
        private struct CHARRANGE<br />
        {<br />
<br />
            public int cpMin; //First character of range (0 for start of doc)<br />
<br />
            public int cpMax; //Last character of range (-1 for end of doc)<br />
<br />
        }<br />
<br />
        [StructLayout(LayoutKind.Sequential)]<br />
<br />
        private struct FORMATRANGE<br />
        {<br />
<br />
            public IntPtr hdc; //Actual DC to draw on<br />
<br />
            public IntPtr hdcTarget; //Target DC for determining text formatting<br />
<br />
            public RECT rc; //Region of the DC to draw to (in twips)<br />
<br />
            public RECT rcPage; //Region of the whole DC (page size) (in twips)<br />
<br />
            public CHARRANGE chrg; //Range of text to draw (see earlier declaration)<br />
<br />
        }<br />
<br />
        private const int WM_USER = 0x0400;<br />
<br />
        private const int EM_FORMATRANGE = WM_USER + 57;<br />
<br />
        [DllImport("USER32.dll")]<br />
<br />
        private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);<br />
<br />
        // Render the contents of the RichTextBox for printing<br />
<br />
        // Return the last character printed + 1 (printing start from this point for next page)<br />
<br />
        public int Print(int charFrom, int charTo, Graphics gr, Rectangle bounds)<br />
        {<br />
<br />
            //Calculate the area to render and print<br />
<br />
            RECT rectToPrint;<br />
<br />
            rectToPrint.Top = 0;// (int)(bounds.Top * anInch);<br />
<br />
            rectToPrint.Bottom = (int)(bounds.Height * anInch);// (int)(bounds.Bottom * anInch);<br />
<br />
            rectToPrint.Left = 0;// (int)(bounds.Left * anInch);<br />
<br />
            rectToPrint.Right = (int)(bounds.Width * anInch);// (int)(bounds.Right * anInch);<br />
<br />
            //Calculate the size of the page<br />
<br />
            RECT rectPage;<br />
<br />
            rectPage.Top = 0;//(int)(bounds.Top * anInch);<br />
<br />
            rectPage.Bottom = (int)(gr.ClipBounds.Height * anInch);//(int)(bounds.Bottom * anInch);<br />
<br />
            rectPage.Left = 0;//(int)(bounds.Left * anInch);<br />
<br />
            rectPage.Right = (int)(gr.ClipBounds.Right * anInch);//(int)(bounds.Right * anInch);<br />
<br />
            IntPtr hdc = gr.GetHdc();<br />
<br />
            FORMATRANGE fmtRange;<br />
<br />
            fmtRange.chrg.cpMax = charTo; //Indicate character from to character to <br />
<br />
            fmtRange.chrg.cpMin = charFrom;<br />
<br />
            fmtRange.hdc = hdc; //Use the same DC for measuring and rendering<br />
<br />
            fmtRange.hdcTarget = hdc; //Point at printer hDC<br />
<br />
            fmtRange.rc = rectToPrint; //Indicate the area on page to print<br />
<br />
            fmtRange.rcPage = rectPage; //Indicate size of page<br />
<br />
            IntPtr res = IntPtr.Zero;<br />
<br />
            IntPtr wparam = IntPtr.Zero;<br />
<br />
            wparam = new IntPtr(1);<br />
<br />
            //Get the pointer to the FORMATRANGE structure in memory<br />
<br />
            IntPtr lparam = IntPtr.Zero;<br />
<br />
            lparam = Marshal.AllocCoTaskMem(Marshal.SizeOf(fmtRange));<br />
<br />
            Marshal.StructureToPtr(fmtRange, lparam, false);<br />
<br />
            //Send the rendered data for printing <br />
<br />
            res = SendMessage(Handle, EM_FORMATRANGE, wparam, lparam);<br />
<br />
            //Free the block of memory allocated<br />
<br />
            Marshal.FreeCoTaskMem(lparam);<br />
<br />
            //Release the device context handle obtained by a previous call<br />
<br />
            gr.ReleaseHdc(hdc);<br />
<br />
            //Return last + 1 character printer<br />
<br />
            return res.ToInt32();<br />
<br />
        }<br />
<br />
    }<br />
<br />

AnswerRe: printing String problem Pin
Ennis Ray Lynch, Jr.29-Oct-07 8:40
Ennis Ray Lynch, Jr.29-Oct-07 8:40 
GeneralRe: printing String problem Pin
netJP12L29-Oct-07 8:55
netJP12L29-Oct-07 8:55 
GeneralI really don't know Pin
Ennis Ray Lynch, Jr.29-Oct-07 9:13
Ennis Ray Lynch, Jr.29-Oct-07 9:13 
GeneralRe: I really don't know Pin
netJP12L29-Oct-07 9:58
netJP12L29-Oct-07 9:58 
GeneralRe: I really don't know Pin
Ennis Ray Lynch, Jr.29-Oct-07 10:18
Ennis Ray Lynch, Jr.29-Oct-07 10:18 
QuestionProblem with code after ShowDialog and XML add node Pin
Rapier50329-Oct-07 7:23
Rapier50329-Oct-07 7:23 
AnswerRe: Problem with code after ShowDialog and XML add node Pin
Andrei Ungureanu29-Oct-07 22:38
Andrei Ungureanu29-Oct-07 22:38 
QuestionHow to make sure the string has only Alphabet and Numberic in it? Pin
Khoramdin29-Oct-07 7:04
Khoramdin29-Oct-07 7:04 
AnswerRe: How to make sure the string has only Alphabet and Numberic in it? Pin
Le centriste29-Oct-07 7:17
Le centriste29-Oct-07 7:17 
Questiontranslate own syntax to c# Pin
laserbaronen29-Oct-07 5:34
laserbaronen29-Oct-07 5:34 
AnswerRe: translate own syntax to c# Pin
Colin Angus Mackay29-Oct-07 5:37
Colin Angus Mackay29-Oct-07 5:37 
GeneralRe: translate own syntax to c# Pin
laserbaronen29-Oct-07 5:39
laserbaronen29-Oct-07 5:39 
GeneralRe: translate own syntax to c# Pin
Colin Angus Mackay29-Oct-07 6:07
Colin Angus Mackay29-Oct-07 6:07 
QuestionSystem.Drawing.Image from URL. Pin
Dio2229-Oct-07 4:52
Dio2229-Oct-07 4:52 
AnswerRe: System.Drawing.Image from URL. Pin
martin_hughes29-Oct-07 5:21
martin_hughes29-Oct-07 5:21 
QuestionChecking for well formed XML Pin
Ennis Ray Lynch, Jr.29-Oct-07 4:51
Ennis Ray Lynch, Jr.29-Oct-07 4:51 
AnswerRe: Checking for well formed XML Pin
martin_hughes29-Oct-07 5:27
martin_hughes29-Oct-07 5:27 

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.