Click here to Skip to main content
16,007,779 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to incorporate a DLL from visual C++ inside a sample C# .NET IM project. Pin
NoobNooberNoobest25-Jun-06 16:30
NoobNooberNoobest25-Jun-06 16:30 
GeneralRe: How to incorporate a DLL from visual C++ inside a sample C# .NET IM project. Pin
Nader Elshehabi25-Jun-06 23:50
Nader Elshehabi25-Jun-06 23:50 
QuestionHelp me plz!!!! Pin
longlh25-Jun-06 15:34
longlh25-Jun-06 15:34 
Questionmatrix Pin
haytham_mohammad25-Jun-06 14:42
haytham_mohammad25-Jun-06 14:42 
AnswerRe: matrix Pin
Jun Du25-Jun-06 15:55
Jun Du25-Jun-06 15:55 
GeneralRe: matrix Pin
haytham_mohammad25-Jun-06 16:04
haytham_mohammad25-Jun-06 16:04 
GeneralRe: matrix Pin
Jun Du25-Jun-06 16:09
Jun Du25-Jun-06 16:09 
Questionprinting url [modified] Pin
toink toink25-Jun-06 12:48
toink toink25-Jun-06 12:48 
i tried to use these lines of codes:

[CODE]
public class PrintingExample : System.Windows.Forms.Form
{
private System.ComponentModel.Container components;
private System.Windows.Forms.Button printButton;
private Font printFont;
private StreamReader streamToPrint;

public PrintingExample() : base()
{
// The Windows Forms Designer requires the following call.
InitializeComponent();
}

// The Click event is raised when the user clicks the Print button.
private void printButton_Click(object sender, EventArgs e)
{
try
{
streamToPrint = new StreamReader
("C:\\My Documents\\MyFile.txt");
try
{
printFont = new Font("Arial", 10);
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler
(this.pd_PrintPage);
pd.Print();
}
finally
{
streamToPrint.Close();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}

// The PrintPage event is raised for each page to be printed.
private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
float linesPerPage = 0;
float yPos = 0;
int count = 0;
float leftMargin = ev.MarginBounds.Left;
float topMargin = ev.MarginBounds.Top;
string line = null;

// Calculate the number of lines per page.
linesPerPage = ev.MarginBounds.Height /
printFont.GetHeight(ev.Graphics);

// Print each line of the file.
while(count < linesPerPage &&
((line=streamToPrint.ReadLine()) != null))
{
yPos = topMargin + (count *
printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString(line, printFont, Brushes.Black,
leftMargin, yPos, new StringFormat());
count++;
}

// If more lines exist, print another page.
if(line != null)
ev.HasMorePages = true;
else
ev.HasMorePages = false;
}


// The Windows Forms Designer requires the following procedure.
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.printButton = new System.Windows.Forms.Button();

this.ClientSize = new System.Drawing.Size(504, 381);
this.Text = "Print Example";

printButton.ImageAlign =
System.Drawing.ContentAlignment.MiddleLeft;
printButton.Location = new System.Drawing.Point(32, 110);
printButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
printButton.TabIndex = 0;
printButton.Text = "Print the file.";
printButton.Size = new System.Drawing.Size(136, 40);
printButton.Click += new System.EventHandler(printButton_Click);

this.Controls.Add(printButton);
}

// This is the main entry point for the application.
public static void Main(string[] args)
{
Application.Run(new PrintingExample());
}
}




replacing :


streamToPrint = new StreamReader
("C:\\My Documents\\MyFile.txt");
try


with :


streamToPrint = new StreamReader
("http://www.google.com");
try


but it has an error message : " URI format not supported"

so what must i do so that i can print url format?

[/CODE]
-- modified at 22:21 Sunday 25th June, 2006
AnswerRe: printing url Pin
Nader Elshehabi25-Jun-06 23:59
Nader Elshehabi25-Jun-06 23:59 
Questionhow to encrypt/decrypt data on the fly ? Pin
hdv21225-Jun-06 12:13
hdv21225-Jun-06 12:13 
AnswerRe: how to encrypt/decrypt data on the fly ? Pin
Ed.Poore25-Jun-06 12:15
Ed.Poore25-Jun-06 12:15 
QuestionHow to make my application more cool Pin
ZHENG.YANG.POINTER25-Jun-06 10:17
professionalZHENG.YANG.POINTER25-Jun-06 10:17 
AnswerRe: How to make my application more cool Pin
Nader Elshehabi25-Jun-06 10:47
Nader Elshehabi25-Jun-06 10:47 
GeneralRe: How to make my application more cool Pin
Jun Du25-Jun-06 12:58
Jun Du25-Jun-06 12:58 
GeneralRe: How to make my application more cool Pin
Nader Elshehabi25-Jun-06 16:19
Nader Elshehabi25-Jun-06 16:19 
AnswerRe: Pinvoke CreateRemoteThread Pin
led mike25-Jun-06 8:36
led mike25-Jun-06 8:36 
GeneralRe: Pinvoke CreateRemoteThread Pin
Colin Angus Mackay25-Jun-06 23:06
Colin Angus Mackay25-Jun-06 23:06 
GeneralRe: Pinvoke CreateRemoteThread Pin
led mike26-Jun-06 5:41
led mike26-Jun-06 5:41 
QuestionRegular Expression to convert from PHP to C# Pin
AngryC25-Jun-06 7:09
AngryC25-Jun-06 7:09 
AnswerRe: Regular Expression to convert from PHP to C# Pin
User 665825-Jun-06 7:26
User 665825-Jun-06 7:26 
GeneralRe: Regular Expression to convert from PHP to C# Pin
AngryC25-Jun-06 7:43
AngryC25-Jun-06 7:43 
GeneralRe: Regular Expression to convert from PHP to C# Pin
Kevin McFarlane25-Jun-06 9:09
Kevin McFarlane25-Jun-06 9:09 
AnswerRe: Regular Expression to convert from PHP to C# [modified] Pin
Graham Nimbley25-Jun-06 9:28
Graham Nimbley25-Jun-06 9:28 
GeneralRe: Regular Expression to convert from PHP to C# Pin
AngryC25-Jun-06 11:02
AngryC25-Jun-06 11:02 
GeneralRe: Regular Expression to convert from PHP to C# [modified] Pin
User 665825-Jun-06 11:52
User 665825-Jun-06 11:52 

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.