|
i don't understand please clear how can i pass Cursor to get the mouse position if u have some example pls give it to me
thanx for ur reply
|
|
|
|
|
You don't need to pass anything. As the Position property is static, it can easily be accessed without having an instance.
protected override void WndProc(ref Message m)
{
if(m.Msg == 0xA0 )
{
Point pt = System.Windows.Forms.Cursor.Position;
label1.Text = pt.X.ToString();
label2.Text = pt.Y.ToString();
}
www.troschuetz.de
|
|
|
|
|
Point pt = System.Windows.Forms.Cursor.Position;
it maps the mouse position with respect to the desktop window not with respect to my app. to get the mouse position for my app i must calculate these coordinates with respect to my app position for geting the right mouse position am i right or do u have any idea.
than u very much
|
|
|
|
|
You're rigth. The Position property returns the mouse position in screen coordinates. The get them in client coordinates simply use the PointToClient method of your form.
<br />
Point ptScreen = Cursor.Position;<br />
Point ptClient = PointToClient(pt);
www.troschuetz.de
|
|
|
|
|
thank u very much u really solve this problem before posting this question i spent almost one hour again thank u very much
|
|
|
|
|
wheni'm using this code
private void button1_Click(object sender, System.EventArgse)
{ string strSQL;
strSQL = "INSERT Products VALUES (emp_id(co_emid.Text))";
ocon.Open ();
OracleCommand ad= new OracleCommand(strSQL, ocon) ;
ad.ExecuteNonQuery ();
ocon.Close ();
}
this error raised :
An unhandled exception of type 'System.Data.OracleClient.OracleException' occurred in system.data.oracleclient.dll
Additional information: System error.
|
|
|
|
|
The following is from the help files in visual studio
public void ShowOracleException()
{
OracleConnection myConnection =
new OracleConnection("Data Source=Oracle8i;Integrated Security=yes");
try
{
myConnection.Open();
}
catch (OracleException e)
{
string errorMessage = "Code: " + e.Code + "\n" +
"Message: " + e.Message;
System.Diagnostics.EventLog log = new System.Diagnostics.EventLog();
log.Source = "My Application";
log.WriteEntry(errorMessage);
Console.WriteLine("An exception occurred. Please contact your system administrator.");
}
}
If you catch the exception then you can get more information out of it to hopefully explain what went wrong.
Kev
|
|
|
|
|
hi,
Tell me this , that which version of .NET you are using. Please check whether you have managed.dll for oracle client in your machine. The error is because your machine doesn't have managed .dll for oracle clients.
The error is because of the above reason. Apart from this i need to point one more syntax error in your logic. That is
strSQL = "INSERT Products VALUES (emp_id(co_emid.Text))";
Here please re write you logic like this
strSQL = "INSERT Products VALUES (emp_id('"+co_emid.Text+"'))";
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
No, neither is good. You use parameterized commands using the OracleParameter . Haven't I told you this before, sreejith? Please don't give bad advice.
Using parameterized commands helps avoid SQL injection attacks. If I knew that sreejith designed a Windows or web application using this (which is easy to find out because I can easily disassemble his assembly), I could do just about anything given enough permissions by setting co_emid.Text (through the interface) to the follow:
blah'; drop table Products -- No more products table. I could certainly do a lot worse.
Plus, sreejith, more than likely - judging from "emp_id" - co_emid.Text represents a number. In that case, you need to use int.Parse or Convert.ToInt32(string) or something similar.
But, as far as parameterized queries go, your code should look like so:
OracleCommand cmd = new OracleCommand(conn,
"insert Products values (:emp_id)");
try
{
cmd.Parameters.Add("emp_id", OracleType.Number, 8).Value =
int.Parse(co_emid.Text);
conn.Open();
cmd.ExecuteNonQuery();
}
catch (FormatException)
{
MessageBox.Show("Invalid employee id.");
co_emid.Focus();
}
finally
{
conn.Close();
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi,
Heath, I got same error when i forgot to install managed data client for Sybase database.
'System.Data.AsaClient.AsaException' occurred in system.data.Asaclient.dll. That's why i post my answer ' may a chance of oracle client'. And i nevar specifically said it is because of that.
Anyhow i am really proud that Heath is always with me to help me out and fix my wrong decisions. And one more thing i came to know that you are checking my each and every post. I don't know how i will say thanks for you.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
I'm no Oracle expert but it looks like your SQL statement isn't valid? I don't know, so the first thing I would try is verifying that your SQL statement is formatted correctly. From what you posted, it looks like your trying to set the value of emp_id to the value of the Text property of a control on your form called co_emid . Is this correct?
If so, then you'll have to change your statement around to something like this:
strSQL = "INSERT Products VALUES (emp_id(" + co_emid.Text + "))";
But, I recommend NOT using string concatentation to put any SQL statement together. I would suggest reading up on using stored procedures on the Oracle server and using parameterized queries to execute and pass parameters, like your emp_id value to them.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
At a guess,
ydderf2 wrote:
strSQL = "INSERT Products VALUES (emp_id(co_emid.Text))";
Assuming co_emid is a Form control. Then you aren't adding the value of the control's Text element but adding "co_emid.Text" to the database.
You probably should do something like this.
strSQL = "INSERT Products VALUES (emp_id(" + co_emid.Text + "))";
Michael
CP Blog [^]
|
|
|
|
|
How do we do this in .NET?
public class Hook extends Thread {
public void run() {
System.out.println("shutdown hook!");
}
}
Runtime.getRuntime().addShutdownHook(new Hook());
** this is Java **
Thanks!
Norman Fung
|
|
|
|
|
What exactley are you trying to do, if you explain it then someone who doesn't know much Java may be able to answer the question.
Cheers
Kev
|
|
|
|
|
It simply setup a handler in the event that the application crashes - to do proper cleanup (like logging, releasing resources, network connections and stuff)
Norman Fung
|
|
|
|
|
If you are running a WinForm application, then all you need to do is trap the Form_Closing event. Though even that might get ignored when an unhandled exception occurs that end your application. If you handle your crashes, instead of letting them go unhandled, you can handle cleanup in the Final clause of the Try command.
This signature left intentionally blank
|
|
|
|
|
Yes.. perhaps there is a way to that.
Norman Fung
|
|
|
|
|
hi every one
i have this problem
i have a webpage includes a text field i want to use the leave event on this text field for validating the data that i insert , my supervisore tell me that i have to use the JScript to do that ! any one can help me please ??
|
|
|
|
|
Objection! Asked and answered.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi,
You can use the AtuoPostback of your control and set the value to true. Then write your logic on Textchanged event. This one way and the other one is you can use custom validator control to check your own validation criteria.
If this not serving your purpose better post this on asp.net forum. cause i can't talk much anout asp.net.;)
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
use onblur event of textbox and validate (incase of javascript)
else use custom validators with regular expressions.
or even can be done is server side on text changed event but is not recommended
anand
|
|
|
|
|
An easier question than my previous post (i hope), whats the difference between clicking the Minimize button and setting
form.WindowState = FormWindowState.Minimized;
I am trying to get the form to start in the system tray, i have a notifyIcon in the application and when you click the minimize button the form does not show on the task bar, it only appears in the system tray.
If i set the forms window state property in Form_Load() as above then the icon appears in the system tray but the form also shows on the taskbar.
Any ideas?
Kev
|
|
|
|
|
hi,
This seems that i can help you out. But will you explain little bit more. I mean the excat requirement. and what is your previous post ?
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
To hide the the form (in the sys tray if you have a notify icon) just call the Hide Property of the form.
In your case, like this...
form.Hide();
and then to show it again...
form.Show();
/\ |_ E X E GG
|
|
|
|
|
Hi all, i posted a couple of days ago about closing forms and the problems i was having but i was unable to get the problem solved so here it is again, any ideas are welcome.
I have a scheduler program that runs in the system tray, when double clicked an interface is displayed. This program is to be used on PC's in the backoffices of some of our shops and the users are not IT literate so they can't be trusted to not shut the scheduler down.
To get round this i have encoded a password into the assembly that must be entered when the user shuts the pc down or logs off. This way, the only time the scheduler can be shut down is by end tasking it or if one of our admin guys takes remote control of the pc and inputs the password.
The scheduler is in the startup for the users so if they log of and back on it will start again.
All of the above works fine but...
When the user logs windows off the program asks for the password, there will be times when the users at the ahop need to log off / shut down the pc and they don't know the password so the pc wil just hang or wait for an end task. This is the problem, how can i allow the system to shut the program down when the user logs off but at the same time stop the user from closing the program using alt + F4 or the cross in the corner of the form unless they have the password.
My ideas were to either remove the cross and disable Alt + F4, then implement a button to shut the program down. This would allow me to check the password on the button click and leave the form.Close() function alone so the PC can also shut the app down.
Or, if i could tell the difference between the system shutting the app down and the user then i could just check for the password when the user tries to close the app and not when the system does it.
If anyone has any suggestions about how to make my ideas work or any ideas of their own it would be a great help.
Kev
|
|
|
|