|
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace PrintForm
{
///
/// Summary description for frmTest.
///
public class frmTest : System.Windows.Forms.Form
{
#region UI Variables
private System.Windows.Forms.Button btnPrint;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
#endregion
#region Constructors
public frmTest()
{
InitializeComponent();
}
#endregion
#region Windows Form Designer generated code
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.btnPrint = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// btnPrint
//
this.btnPrint.Location = new System.Drawing.Point(104, 328);
this.btnPrint.Name = "btnPrint";
this.btnPrint.Size = new System.Drawing.Size(120, 40);
this.btnPrint.TabIndex = 1;
this.btnPrint.Text = "Print this form";
this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(88, 32);
this.label1.TabIndex = 2;
this.label1.Text = "Name";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label2
//
this.label2.Location = new System.Drawing.Point(16, 80);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 24);
this.label2.TabIndex = 3;
this.label2.Text = "IC";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// button1
//
this.button1.Location = new System.Drawing.Point(24, 128);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(56, 32);
this.button1.TabIndex = 4;
this.button1.Text = "Receipt";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(128, 32);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(208, 20);
this.textBox1.TabIndex = 5;
this.textBox1.Text = "textBox1";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(128, 80);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(208, 20);
this.textBox2.TabIndex = 6;
this.textBox2.Text = "textBox2";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(128, 136);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(208, 20);
this.textBox3.TabIndex = 7;
this.textBox3.Text = "textBox3";
//
// frmTest
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(360, 390);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnPrint);
this.Name = "frmTest";
this.Text = "Test Form";
this.ResumeLayout(false);
}
#endregion
#region Main
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new frmTest());
}
#endregion
#region UI Event Handlers
private void btnPrint_Click(object sender, System.EventArgs e)
{
try
{
this.Cursor = Cursors.WaitCursor;
PrintForm pf = new PrintForm(this);
pf.Print();
}
catch (Exception ex)
{
MessageBox.Show(this, ex.Message);
}
finally
{
this.Cursor = Cursors.Default;
}
}
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
int counter;
counter = 50;
int i;
Random r = new Random();
for(i =0;i
|
|
|
|
|
Hi,
Can u make ur problem more clearer please. tell me wht u want to do. is it just u want to print a form. or something like that.
Vipin
|
|
|
|
|
hi thanks for all help.. managed to log in only now.. i actually mean i have done a print application..however when i link it to my main application, it cant work as now i have 2 main entry point..how do i go abt doing this??
really appreciate yr help vipin
|
|
|
|
|
ok i got u now. What u have to do is from the print application u have developed remove the code. and paste it in the other form. the code u have to remove is
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
and since u have developed the print application and other application differently. u might have to remove the code only form the print application. there is no need to do anything else on the other form ok. even after doing this if its still not working then u just right click the solution of the project take properties there in the general tab u will see StartUp object there u set the form which u want to run first. ok do let me if it works ok.
Vipin
|
|
|
|
|
hi vipin i have tried doing yr method but it still cant work ... hhmm..think its rather hard to communicate like that.. maybe u can give me yr email and we can contact directly through that.. i really need yr help as my sch proj dateline is coming.. thanks
|
|
|
|
|
vipin1981@gmail.com and what is urs
Vipin
|
|
|
|
|
joyful_neon@hotmail.com
can i add u in instant messenger?
|
|
|
|
|
i dont use msn messenger. if u have yahoo messenger or if u have google account register in orkut.com and let me know. i will add u to my friends list. and by the by where r u from.
Vipin
|
|
|
|
|
hi vikin i have jus sent an email to u.. i dunno if u could actually open the attachment from there.. but like i mentioned in the email, i will add u in yahoo messenger when i get home.. so for now guess i jus keep trying. . thanks man
|
|
|
|
|
actually i cant access mails during my office hours. any way i will check out during our break. till then post ur doubt here. If i know i will surely help u.
Vipin
|
|
|
|
|
I am placing a textBox control in richtext Box.So by default the cursor will come to richtextbox control.How to place the cursor in textbox which is inside richtextbox.
|
|
|
|
|
It sounds something wierd "textbox in richtextbox". But...
if you want the cursor to come first in textbox, then change
the TabIndex property from textbox and richtextbox.
// Cursor go to textbox
this.textbox.TabIndex = 0;
this.richtextbox.TabIndex = 1;
// Cursor go to richtextbox
this.textbox.TabIndex = 1;
this.richtextbox.TabIndex = 1;
|
|
|
|
|
Personally speaking, this sounds like a REALLY stupid design. Why you would put a textbox inside a richtext box is beyond all normal reasoning. However, you need to either change tab order or do a textbox1.Focus() call.
|
|
|
|
|
Hi all!
Sorry for my poor english....
Here my problem, I created WebBrowser,and now I need to disable, "Select_all" and "Copy" fulctions in browser.
I disabled ContextMenu, but keys Ctrl+A, Ctrl+C working.
I tryed to using ProcessCmdKey,ProcessDialogKey,for catching this Keys but "Ctrl+A, Ctrl+C" are not catching....
If somebody knows how do it, please help me...
P.S. Sorry for my mistakes.
|
|
|
|
|
Try this.
var isIE = ( document.all != null );
function initIframe()
{
if ( isIE )
{
//wiring to onkeydown event
editor.attachEvent('onkeydown', editorEvents);
...
}
else
{
editor.addEventListener('keypress', editorEvents, true);
...
}
}
function editorEvents(evt)
{
//this is just old habit
evt = ( evt == null ) ? event; evt;
var keyCode = evt.keyCode ? evt.keyCode : evt.charCode;
var keyCodeChar = String.fromCharCode(keyCode).toLowerCase();
if ( !isIE )//-->If FireFox
{
if (evt.type=='keypress' && evt.ctrlKey)
{
...
}
}
if ( isIE )//-->If IE
{
//changed the type to "keydown" to catch new wiring.
if (evt.type=='keydown' && keyCodeChar=='v' && evt.ctrlKey)
{
//do something.
//setting the returnValue will cause the event to stop bubbling.
evt.returnValue = false;
//no return needed
}
}
return true;
}
Vipin
|
|
|
|
|
Thank's for You help, but how can I use Your sample for axWebBrowser1?
I'm only junior in programming, and very much I don't understand...
|
|
|
|
|
paste this code in the key press event of the textbox or text area where u want to disable the Ctrl+V or Ctrl+C keypress.
Vipin
|
|
|
|
|
Sorry but my WebBrowser was created in Windows Application, VS 2003, FW 1.1, here sample:
private AxSHDocVw.AxWebBrowser axWebBrowser1;
private void Form1_Load(object sender, System.EventArgs e)
{
object oURL = "www.codeproject.com";
object oEmpty = "";
axWebBrowser1.Navigate2(ref oURL, ref oEmpty, ref oEmpty, ref oEmpty, ref oEmpty);
}
//Event which open links in new windows\
private void axWebBrowser1_NewWindow2(object sender, AxSHDocVw.DWebBrowserEvents2_NewWindow2Event e)
{
if (this.axWebBrowser1.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
{
e.ppDisp = null;
e.cancel = true;
return;
}
FEX f1 = new FEX();
f1.Text = "(New window)";
e.ppDisp = f1.axWebBrowser1.Application;
f1.Show();
}
And how I can use Your sample? Sorry but I don't know....
|
|
|
|
|
if ( e.Control && e.KeyCode == Keys.A || e.Control && e.KeyCode == Keys.C )
{
MessageBox.Show( "Control key + A pressed");
}
let me know if this works.
Vipin
|
|
|
|
|
Hi!
Sorry but WebBrowser haven't event KeyDown.... And Your sample doesn't work...
In my sample, some keys work normal...but "Ctrl+A, Ctrl+C" - does'nt work.
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Control | Keys.N))//Normal
{
if (this.axWebBrowser1.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
{
return false;
}
FEX f1 = new FEX ();
f1.Text = "(New window)";
f1.Show();
return true;
}
else if (keyData == (Keys.Control | Keys.Q))//normal
{
MessageBox.Show("Q");
return true;
}
else if (keyData == (Keys.Escape))
{
this.Close();
return true;
}
else if(keyData == (Keys.A | Keys.Control))
{
MessageBox.Show("113"); //Doesn't work
return true;
}
else
{
return base.ProcessCmdKey(ref msg, keyData);
}
}
P.S. Sorry for my mistakes!!!
|
|
|
|
|
Hi folks,
I have a simple question for ya (At least I hope it is!)... How can my app find out what folder it is in? This might change regularly, so it needs to know lol
Cheers, Ben.
|
|
|
|
|
Hi,
try this
System.AppDomain.CurrentDomain.BaseDirectory()
Or
system.Environment.CurrentDirectory
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
Anant Y. Kulkarni
|
|
|
|
|
Thanks, this worked
Environment.CurrentDirectory
|
|
|
|
|
Do not use Environment.CurrentDirectory. It could potentially change between application launch and accessing of the property. If you're writing a WinForms app, use Application.StartupPath[^] instead. If it's a command line app, use the first property suggested by the other poster AppDomain.CurrentDomain.BaseDirectory[^].
|
|
|
|
|
In addition to what Senthil said:
The Environment.CurrentDirectory property contains the current working directory. The startup working directory can be specified in the properties for an application, so even if you don't change the working directory from your program, there is still no guarantee that the application file is in the current working directory.
---
b { font-weight: normal; }
|
|
|
|