|
Hello !
Can any one please help me on how to detect a windows change?
What I wish to accomplish is detecting when a user changes from one window to another, for example user has 3 programs running, Internet Explorer, Skype and Notepad, user is Browsing in Internet Explorer and then he changes to skype, when this happens I would like my C# program to detect that change. Is this possible? How can i do this?
Thank you very much
|
|
|
|
|
You would have to implement a Windows CBT Hook callback. This will notify you of any changes to the windows, including which one is going to be activated, created, destroyed, ...
Read this...[^]
|
|
|
|
|
|
I have google a lot but i just find Copy Hook Handler (ICopyHook) but didnt know how to use!
i wanna to prevent user from deleting trace.trc file but system can update the info in it.just prevent from deleting it,even if the program is closed soin windows also prevent from deleting .
|
|
|
|
|
This isn't going to work, at least not in a user application.
You can't prevent a file from being deleted unless you modify the security permissions of the file, appropriately. The problem with doing this from a user application is if the user has appropriate permissions to the foler above the file, they add their permissions back to the file itself and reverse whatever you do.
What's the point of preventing the file from being deleted??
|
|
|
|
|
Why are you afraid of the file being deleted? If it's part of your application, then it'll be copied to the application-folder of your application. Users aren't supposed to delete anything there. There's NO WAY of preventing users to delete an item (and there never will be) - you'll have to trust the idea that they won't try to kill your application on purpose.
Look at it this way; if I delete things from the "World of Warcraft"-folder, chances are that my game will no longer work. Is that the fault of Blizzard, or my fault? Obviously my fault
Yes, this sh*t happens often. That's why most installers give the option to "repair" an existing installation, where they re-copy the original installation files. That would be the correct way to restore your missing/corrupted trace-file if it suddenly went missing.
Best option (if the file is readonly) would be to include it in your executable as a resource. But don't lock my files on - it'd feel as if you were hijacking my computer, and that's not a good feelin'.
Bastard Programmer from Hell
|
|
|
|
|
Hi,
Thanks for your reply in both C#,Database Pages.
I want user unable to delete or replace the trace (SQL) file.cause if the trace file delete i cannot get what things the user done wrong in SQL.(cause they know that everything is in trace file of SQL).
Q2)if they delete the .trc file of SQL can i take all trace from SQL (I mean old trace in special database )?
|
|
|
|
|
If the user deletes a file that your app needs, the app is simply broken. What's the use of checking if the file has been deleted, if I can replace it with trace-file that simply shows nothing?
This merely gives someone the impression of security. That's a bad idea by definition.
Bastard Programmer from Hell
|
|
|
|
|
hi,
if this file deleted the app wont broke!
It just take trace on every thing happened in DB.
So,isnt there any way to do that?
|
|
|
|
|
Your app will also break if they delete a DLL from the .NET Framework! Will you "protect" those too? What about those files in the "Windows" folder?
You can only protect files if you're the owner of the machine; an admin can make files write-protected, but if the user is an admin, he can still delete them - which is logical, since they're his files, not yours.
Like a car, if you remove a part - you can expect things to break. No, a regular user will not go to the "Program Files" folder and delete random files. If they do, they're the ones responsible.
Bastard Programmer from Hell
|
|
|
|
|
I know all that!
but when customer make mistake in his accounting app if he delete the .trc file then how can i prove that the mistake is from there side?
cause that i wanna to protect that file from deleting.OR i get the old trace sp_trace_setevent (Transact-SQL) from his/her database.so then if he/she delete that file i can get that back.
|
|
|
|
|
jojoba2011 wrote: but when customer make mistake in his accounting app if he delete the .trc file
then how can i prove that the mistake is from there side?
The same way you can prove that they corrupted the .NET Framework, and the same way you can prove that they deleted a file from the Windows-folder - you don't.
jojoba2011 wrote: cause that i wanna to protect that file from deleting.
Embed is as a resource. That way there will not be a file in the directory, only your application.
Bastard Programmer from Hell
|
|
|
|
|
Wow, what sort of organisation do you work for? It seems either your users are insane idiots who will maliciously try and damage your system or you have a huge dose of paranoia. Either that or a manager has been allowed to dictate your security policy!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
This is a really bad idea. You should never try to stop the user from deleting a file that can grow and grow unrestricted. I am curious as to why you think it's necessary to keep the trace file anyway. If you need to log i/o to the database, you should be logging the actual calls themselves (and you really should only be doing this if you want to cope with application failures).
|
|
|
|
|
thanks for reply!
it wont grow more than 50MB .and will replace fifo system to replace the data.and the resion that i wanna the user dont delete it is:
our customer use our app(accounting) and they do something wrong and they wont accept that they themseleves have done that .for that i wanna to take trace of my DB(sp_trace_setevent (Transact-SQL) OR reading ldf file)
|
|
|
|
|
I was able to create the effect of gradient in the DataGridView control as shown in the image (White & DarkOrange).
But now can not VISUALIZE THE DATA THAT CONTAINS THE DATAGRIDVIEW.
( Pude crear el efecto de degradado en el control DataGridView como se muestra en la imagen ( White & DarkOrange ) .
Pero ahora no se pueden VISUALIZAR LOS DATOS QUE CONTIENE EL DATAGRIDVIEW )
Example Image[^]
|
|
|
|
|
Your question does not explain enough of what's going on.
How are you trying to "visualize" the data? What seems to be going wrong? Do you receive any exceptions?
What are they?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
In the event the datagridview Paint have done the following:
private void dtgData_Paint(object sender, PaintEventArgs e)
{ Graphics g = e.Graphics;
Rectangle rect = new Rectangle(0, 0, Width, Height);
LinearGradientBrush b = new LinearGradientBrush(rect, Color.White, Color.DarkBlue, LinearGradientMode.Vertical);
g.FillRectangle(b, rect);
}
Before creating the gradient showed data from the cube to my database
modified 20-May-12 21:38pm.
|
|
|
|
|
the DGV needs to paint itself through its Paint event; if it does not run at all, or runs before your Paint handler runs, then all it will show is your stuff, and not its native capabilities. Either switch the order of the paint handlers, or better yet override OnPaint() and have its handler call base.OnPaint() when the background is done. The details depend on your current setup.
|
|
|
|
|
Sorry I am very new to c# I could explain with an example, thank you very much for your help.
|
|
|
|
|
In order for this to work, you need to have your own DGV class derived from DataGridView, and implement an OnPaint method, which calls base.OnPaint() AFTER you are done with the background.
Here[^] is the relevant MSDN page; the important sentence is
When creating a new custom control or an inherited control with a different visual appearance, you must provide code to render the control by overriding the OnPaint method. For more information, see Overriding the OnPaint Method and Custom Control Painting and Rendering.
and it contains links to more explanation.
IMO you really should study a book on C# and WinForms before trying all this... And then use Google to locate the detailed documentation and some examples.
|
|
|
|
|
Thank you will investigate much to resolve this and like to share it with others
|
|
|
|
|
hi I am going to apply fuzzy to C #
calculate the linear and triangular membership functions.
http://cdn-u.kaskus.us/72/d162lwot.png[^]
http://cdn-u.kaskus.us/72/7qhhkzn8.png[^]
download an application http://www.4shared.com/rar/wJEK9W45/fuzzy.html[^]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
namespace LATIHAN
{
public partial class fuzzy : DevExpress.XtraEditors.XtraForm
{
Double MU, PA, TU;
public fuzzy()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Double vskor = Convert.ToDouble(textBox1.Text);
if (25 <= vskor && vskor <= 45)
{
MU = (45 - vskor) / (45 - 25);
}
else if( vskor < 25)
{
MU = 1;
}
else
{
MU = 0;
}
if (vskor <= 35 || vskor >= 55)
{
PA = 0;
}
else if (35 <= vskor && vskor <= 45)
{
PA = (vskor - 35) / (45 - 35);
}
else if (45 <= vskor && vskor <= 55)
{
PA = (55 - vskor) / (55 - 45);
}
if (45 <= vskor && vskor <= 65)
{
TU = (vskor - 45) / (65 - 45);
}
else if (vskor <= 45)
{
TU = 0;
}
else
TU = 1;
label1.Text = "MUDA (" + MU + ")";
label2.Text = "PAROBAYA (" + PA + ")";
label3.Text = "TUA (" + TU + ")";
if (TU > MU && TU > PA )
{
hasil.Text = " Ternyata Ahaha anda TUA .. tuaaa tuaaaa :D (" + TU + ")";
}
if (MU > PA && MU > TU)
{
hasil.Text = "Anda termasuk MUDA jadilah anak yang berguna (" + MU + ")";
}
if (PA > MU && PA > TU)
{
hasil.Text = "Anda sudah PAROBAYA jangan salah langkah nanti bisa jadi BAYA (" + PA + ")";
}
}
private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
RamGec_About_Box1 m = new RamGec_About_Box1();
m.Show();
}
}
}
C# fuzzy
|
|
|
|
|
If you're trying to post this for the world to use, write an article on it, don't post it to a forum.
If you're trying to ask a question, you didn't.
|
|
|
|
|
Is there a question you want answered ? Why are you posting this here: what kind of response do you expect to get ?
best, Bill
"Humans are amphibians ... half spirit and half animal ... as spirits they belong to the eternal world, but as animals they inhabit time. This means that while their spirit can be directed to an eternal object, their bodies, passions, and imaginations are in continual change, for to be in time, means to change. Their nearest approach to constancy, therefore, is undulation: the repeated return to a level from which they repeatedly fall back, a series of troughs and peaks.” C.S. Lewis
|
|
|
|