|
I need to detect when "windows + D" click or "show desktop" occurs. Which event occurs when this happenned?
karanba
|
|
|
|
|
The Windows message that is generated is not sent to every application, so you need to implement a Winodws hook. Read Using Hooks from C#[^] for more detail.
Specifically, you need to install a keyboard hook using WH_KEYBOARD (0x2). Your callback would be defined like so:
delegate IntPtr KeyboardProc(IntPtr code, IntPtr wParam, IntPtr lParam); The specific constants you want to check for are VK_LWIN (0x5b) and VK_RWIN (0x5c), as well as VK_D (0x44). Read KeyboardProc[^] for more information.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Is it a proper to design the business logic layer & Data access layer as a web service in a n-tier application. What are the pros and cons of using this. when should i use it and when i should not. My UI may be a windows or web application does webservice affect it by any way.
Another Query:
What the typical functions required in dblibrary.?
How can i optimize database access in a dblibrary?
What are the things to be kept in mind when designing a dblibrary?
How can i make my dblibrary also database independent i.e. tommorow i should be able to change the database without changing code just change the configuration settings in some resource file)?
I am sorry if its unclear .
Thanks to all who has answered my previous queries.
Thanks in advance for any reply?
I would like hear the answer of these queries with reason ie. why something is better or not?
with regards
anand
|
|
|
|
|
It is typically dependent on the client’s wish. Some clients do not prefer to business logic sitting on the IIS machine and for Web Services you require the IIS machine. In such situation, the solution is to use .NET remoting to access services secured inside the firewall while your IIS Web Service sits outside the firewall in the DMZ and just serves requests.
The question you have raised is really important from the point of view of the *trust* users are going to put over IIS/.NET basde Web Services, while the recent IIS exploit memories are still fresh. I expect some interesting advice from the Microsoft guys and the pattern gurus.
Your database questions are irrelevant for this forum, please use the ADO forum. Lets me tackle the only forum relevant question:
Database independent programming: OBBC technology has been around for years to solve this problem. .NET has OLEDB and ODBC Adaptors, which you can read on and use to achieve the same purpose. The documentation clearly stating which one among these two is suited for which purpose, is a bit rare to find, but some experts will soon throw light on this. Lets wait a while…
|
|
|
|
|
thanks, how to use .net remoting to access services in secure mode.
also let me know other ways of building web services.
Thanks again for the reply.
anand
|
|
|
|
|
If you are using Web Services, or using .NET Remoting over an HTTP channel, then simply buy yourself an SSL certificate from VeriSign[^], Thawte[^], or some other company and install it on IIS. These companies will have instructions, and please don't ask here because it's not a C#-related question.
If you want more granularity with what in your body gets encrypted, read about the Microsoft Web Service Enhancements[^], and implementation of industry standard specifications to encrypt, sign, route, and do more with SOAP (what Web Services use, and what .NET Remoting can use for a formatting channel).
If you want more information about how to build Web Services, I recommend you read some of the many articles on this site, or visit http://msdn.microsoft.com/webservices[^]. There is a lot of information available so this is not really a suitable subject for the forum, which is geared more toward specific questions.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi,
I have a webform, which changes the cssclass of a textbox and displays and error marker if the fields were left blank, or wrong data inputted etc.
For the reset button I would like to rack through the textboxes images within the form, and if the image is visible, turn it off etc.
I could do this by hard coding each instance of the image, but was hoping there would be a tidier way of doing this.
Here is what i have got already ...
foreach(object myControl in Page.Controls)
{
if(myControl is System.Web.UI.WebControls.Image)
{
System.Web.UI.WebControls.Image errImage = (System.Web.UI.WebControls.Image)myControl;
if(errImage.Visible == true)
{
errImage.Visible = false;
}
}
However all i am getting is the Html form itself and 2 literals.
I know im missing someting silly, but not sure what.
Any help would be appreciated.
Thanks
I first realised I was dyslexic when I went to a Toga party dressed as a goat.
|
|
|
|
|
hi,
Try this,
foreach(Control ctl in page.Controls)
{
Image Img= ctl as WebControls.Image;
if(Img!=null)
{
//do your operations
}
}
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
I am sorry if i am wrong how can i know that its a Image control or image in a datagrid or some thing else.
anand
|
|
|
|
|
Hi S r e e j i t h N a i r
Thanks but that didnt work either, I still only get the literals and the actual html form.
I first knew I was dyslexic when I went to a Toga party as a goat.
|
|
|
|
|
hello everybody
i am facing a problem to get the mouse position from the non client area in C#
i am using this technique but it is not working
protected override void WndProc(ref Message m)
{
if(m.Msg == 0xA0 ) //mouse move on NC area
{
try
{
Point pt = new Point();
Type t = pt.GetType();
pt = (Point)m.GetLParam(t);//pt = (Point)m.GetLParam(typeof(t)));
label1.Text = pt.X.ToString();
label2.Text = pt.Y.ToString();
}
catch(Exception e){Console.WriteLine(e);}
}
}
please help me
thanx
|
|
|
|
|
Use the static Position property of Cursor class to retrieve the mouse position.
Or what exactly isn't working?
www.troschuetz.de
|
|
|
|
|
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
|
|
|
|