|
This snippet activates the paper feed but does not result in any printed text.
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
using System.Drawing.Printing;<br />
<br />
namespace _316CH11<br />
{<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
private System.Windows.Forms.TextBox txtText;<br />
private System.Windows.Forms.Button btnPrint;<br />
private System.Drawing.Printing.PrintDocument printDocument1;<br />
private System.ComponentModel.Container components = null;<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if (components != null) <br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
#region Windows Form Designer generated code<br />
private void InitializeComponent()<br />
{<br />
this.txtText = new System.Windows.Forms.TextBox();<br />
this.btnPrint = new System.Windows.Forms.Button();<br />
this.printDocument1 = new System.Drawing.Printing.PrintDocument();<br />
this.SuspendLayout();<br />
this.txtText.Location = new System.Drawing.Point(0, 0);<br />
this.txtText.Multiline = true;<br />
this.txtText.Name = "txtText";<br />
this.txtText.Size = new System.Drawing.Size(176, 125);<br />
this.txtText.TabIndex = 0;<br />
this.txtText.Text = "";<br />
this.btnPrint.Location = new System.Drawing.Point(0, 136);<br />
this.btnPrint.Name = "btnPrint";<br />
this.btnPrint.Size = new System.Drawing.Size(176, 23);<br />
this.btnPrint.TabIndex = 1;<br />
this.btnPrint.Text = "&Print";<br />
this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click);<br />
this.printDocument1.DocumentName = "NetDocument11-1";<br />
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
this.ClientSize = new System.Drawing.Size(292, 262);<br />
this.Controls.Add(this.btnPrint);<br />
this.Controls.Add(this.txtText);<br />
this.Name = "Form1";<br />
this.Text = "Form1";<br />
this.Load += new System.EventHandler(this.Form1_Load);<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
<br />
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
}<br />
<br />
private void btnPrint_Click(object sender, System.EventArgs e)<br />
{<br />
printDocument1.Print();<br />
}<br />
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)<br />
{<br />
Font fnt = new Font("Arial", 10, FontStyle.Regular, GraphicsUnit.Pixel);<br />
e.Graphics.DrawString(txtText.Text, fnt, Brushes.Black, 0, 0);<br />
e.HasMorePages=false;<br />
}<br />
<br />
private void Form1_Load(object sender, System.EventArgs e)<br />
{<br />
<br />
}<br />
}<br />
}<br />
Any suggestion on what might wrong here?
Most people are willing to pay more to be amused than to be educated--Robert C. Savage, Life Lessons
Toasty0.com
Ladder League (beta)
My Grandkids
|
|
|
|
|
Maybe it is printing outside the margins of the page.
Try: e.Graphics.DrawString(txtText.Text, fnt, Brushes.Black, e.MarginBounds.Location);
-Chris
|
|
|
|
|
cmaissan wrote:
Try: e.Graphics.DrawString(txtText.Text, fnt, Brushes.Black, e.MarginBounds.Location);
No joy. Tried it and get the same behavior. Thank you for the suggestion.
Jerry
Most people are willing to pay more to be amused than to be educated--Robert C. Savage, Life Lessons
Toasty0.com
Ladder League (beta)
My Grandkids
|
|
|
|
|
I m not finding solution to this problem. Can anybody please help me regarding this problem?
I need to obtain ip address and computer names of all machines of a LAN, which are ACTIVE in the network. The problem has to be solved in C#.
Aakash
|
|
|
|
|
Hey buddy, I did post a reply to your original post. You could have asked for more information instead of posting it again
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
sorry, i didnt mean to hurt you mr. senthil kumar. But i am trying from past 2 weeks on that context. Suggestions from this forum always helps me. Thanks to everyone.
Aakash
|
|
|
|
|
|
Hi Friends...
I wanna create a toolbar on my windows taskbar and add its name to system context menu of taskbar Like QuickLaunch,Address and Windows Media Player toolbar. My toolbar
may consists a Textbox and a button just like 'Google Deskbar' Application.
Can anybody help me ?
|
|
|
|
|
i wanna do the same thing,
if you got some thing, can you mail it to me,thx
gavin@m165.com
|
|
|
|
|
In working on a small C#.net program that starts another program via rundll32. This program performs an operation and then opens a IE page showing some results. I would like to be able to close this IE process after the WaitForExit() call.
Process proc = new Process();<br />
ProcessStartInfo processInfo = new ProcessStartInfo("rundll32.exe");<br />
processInfo.Arguments = Config.DLL_ARGUMENTS;<br />
proc.StartInfo = processInfo;<br />
proc.Start();<br />
proc.WaitForExit();<br />
I know how to get a list of processes running, but how do I know which was the IE started by my other proc. call??
Thanks for any help!
|
|
|
|
|
You'll have to get the list of processes, launch your .DLL thing and wait for it to terminate. Then enumerate the processes again, comparing the list to the one you have stored. You'll be able to find the IE instance that was launched then.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
In addition to, or instead of this, you could have the page that's created and displayed have a particular title. The new IE window with the "[title] - Microsoft Internet Explorer" title will be the one you're looking for.
Matt Gerrans
|
|
|
|
|
He can't change the title, since it's a seperate .DLL he's running using rundll32 that's launching the IE window, not his application.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How do you know its not a separate .DLL that he or someone he works with wrote? Anyway, the same idea applies if the title of the page is fairly consistent, whether or not he has any influence over exactly what it is. It's just a little extra insurance in case where two or more instances of IE appear in that same timeframe.
By the way, you might also have trouble in the case where an existing instance of IE picks up the page, instead of a new instance of IE being launched; this depends upon how the DLL is launching the page.
Matt Gerrans
|
|
|
|
|
Matt Gerrans wrote:
How do you know its not a separate .DLL that he or someone he works with wrote?
Who cares? Usually when they say something like that it's something they didn't write.
Matt Gerrans wrote:
By the way, you might also have trouble in the case where an existing instance of IE picks up the page, instead of a new instance of IE being launched; this depends upon how the DLL is launching the page.
Very true.
In either case, it's a bad idea to go hunting for a process then close it. Since he didn't directly launch it, he shouldn't be closing it in the first place. IMHO, it's just bad practice.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
In either case, it's a bad idea to go hunting for a process then close it. Since he didn't directly launch it, he shouldn't be closing it in the first place. IMHO, it's just bad practice.
Good point; I agree.
That's kind of why I was suggesting the extra checks. However, now that you mention it, I think the better suggestion is to either not try to kill the instance of IE that's created by this other process, or work out a better interface with the creators of that other process, if possible. The idea of a browser window appearing with some stuff, then automatically disappearing seems pretty bad. Long before you are doing something this kludgy, it is time to start trying to work out a better solution.
Matt Gerrans
|
|
|
|
|
Hello
I want to change the icon of exe of my program as i want to place an icon of my choice as to appear if i place it on my desktop. If any body can help.
Regards
asmyan
|
|
|
|
|
You can add an icon of your choice to File System Editor.
Go to File System Editor in Setup and Deployment, add a shortcut of Priamry output to User's Desktop and right click on the copied shortcut and goto ICON property and select the ICON you want.
As far as I know, you can only add an ICON to an exe with extension .ico
Hope this helps.
Looney
|
|
|
|
|
Assuming you are using VS .NET 2003, Right click on the Project in Solution Explorer, click Properties, go to Common Properties->General, you'll find an entry for Application Icon.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I would to convert to int a number got by a division of two doubles....
For example 500/900 i get 0.555... that is converted using Convert.ToInt16() in 1.
I would get 0 instead, then 1 if i divide 900/900 or 970/900.
How can i do?
|
|
|
|
|
Perhaps you are looking for the Math.Round function?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Math.Round just convert a double value to the nearest one, i need to convert it to the littlest one,
example:
1,43 to 1
1,21 to 1
1,98 to 1
2,01 to 2
2,54 to 2
8,76 to 8
5,99 to 5
ok? How can i do?
|
|
|
|
|
ok Floor is the method i need.
|
|
|
|
|
You are talking about the Floor function (returning nearest LOWER integer):
<br />
double a = 1.43;
int i = (int)Math.Floor(a);
Similar function is Ceiling, it returns a nearest higher integer ( Math.Ceiling(1.43) = 2 ), just for curiosity.
|
|
|
|
|
Have you considered Math.Floor() ?
modified 12-Sep-18 21:01pm.
|
|
|
|