|
Hi.
I'm gonna get an Item on Mouse position during Mouse Double Click.
I've been using this method :
private void listView1_DoubleClick(object sender, EventArgs e)
{
Point mousePoint = new Point(MousePosition.X - this.Location.X, MousePosition.Y - this.Location.Y);
var item = listView1.GetItemAt(MousePosition.X - this.Location.X, MousePosition.Y - this.Location.Y);
if (item != null && item.Tag == null)
{
listView1.Invalidate(item.Bounds);
item.Tag = "tagged";
}
MessageBox.Show(item.Name);
}
Unfortunately it returns null.
Could you guide me how I can resolve it ?
Thanks.
|
|
|
|
|
Mohammad Dayyan wrote: MousePosition.X - this.Location.X, MousePosition.Y - this.Location.Y
What logic is this?
Mohammad Dayyan wrote: Unfortunately it returns null.
Here is what MSDN says,
The GetItemAt method, on the other hand, returns null reference (Nothing in Visual Basic) if there is no item at the specified location.
So it looks like there is no item in the location where you are specifying. I guess you need to handle MouseDown event and use the X and Y from the MouseEventArgs . Get the list item in MouseDown event and use it in the double click event.
Edit,
I found there is a MouseDoubleClick[^] event and that would be the right thing to use.
|
|
|
|
|
Thank a lot. my problem was solved
|
|
|
|
|
Use MouseDoubleClick event. This way:
private void listView1_MouseDoubleClick(object sender, MouseEventArgs e) {
var item = listView1.GetItemAt(e.X, e.Y);
}
|
|
|
|
|
|
|
H! All
I have a problem regarding window service. When I tried to start the service from the Services, it gives me an error, "Error 1053: The service did not respond to the start or control request in a timely fashion"..
The code uses System.Threading not System.Timer..i tried to put an additional code to produce a log file so that i can see what is happening while starting in the services.., it executed the routine..from OnStart it calls a function and inside the function..it loops continuously..then i think it was five loops when the error showed up..it didnt pass to the OnStop method..
Another thing I am confused is that i can run or double click the EXE in the debug folder manually and it is running successfully. It seems that I am running an ordinary EXE not a windows service EXE..
BTW, this was built in C#.NET..
Anyone who knows this problem..Please help this is urgent..
Thanks in advance..Regards
|
|
|
|
|
Don't do operations that take long time on your start method. This error comes usually when the service can't start running in 30 seconds. Do all your long running tasks on a separate thread. What is your service doing on startup? Is it reading some files?
|
|
|
|
|
Thanks for your reply Navaneeth
Yes, the OnStart calls a function..here's the sample code..
public void Start()
{
int intervalEnqueue;
try
{
intervalEnqueue = 600;
timer1 = new Timer(new TimerCallback(LLPlusProcess), null, intervalEnqueue, intervalEnqueue);
}
.....and here are some content of the function.....
public void LLPlusProcess(object state)
GetSMSResult getIncomingSMSResult = new GetSMSResult();
getIncomingSMSResult = null;
service = new Service();
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
// get Incoming SMS with Waiting status
getIncomingSMSResult = service.GetSMS(System.Configuration.ConfigurationManager.AppSettings["clientAppKey"], System.Configuration.ConfigurationManager.AppSettings["enqueueStatus"], "Waiting", Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["enqueueRecord"])); <---- calls a web service function here
string getIncomingSMSResultResponse = getIncomingSMSResult.ResponseMessage;
System.Diagnostics.Debug.Write(getIncomingSMSResultResponse + "\r\n");
GetSMSResultMessage[] getIncomingSMSResultMessage = null;
getIncomingSMSResultMessage = getIncomingSMSResult.Message;
....etc...
If getIncomingSMSResultMessage is NULL then it will go here..else it will save the data in the database..
catch (Exception ex)
{
System.Diagnostics.Debug.Write("ENQUEUE [EX] : " + ex.ToString());
}
System.Threading.Thread.Sleep(100);
enqued = false;
}
else
{
System.Diagnostics.Debug.Write("\r\n ---- ENQUEUE PROCESS ON GOING ----\r\n ");
}
It will loop for how many times (as per my log files) but still it will end to error i mentioned..
But if i double click the exe file from debug folder..it run successfully..is it normal for a web service exe to be manually run? Some says it shouldnt be running that way..because exe file will look for the services for it to run...
Please help..Regards!
|
|
|
|
|
obrix_activex wrote: is it normal for a web service exe to be manually run?
Not usually, but you can write one that does.
What type of Timer are you using? I use a System.Timers.Timer for my Services.
|
|
|
|
|
H! PIEBALDconsult!
The program uses System.Threading...You may refer to my previous messages regarding my problem..
I'm confused to where is really the problem occurs..is it in the code or the way i built the service installer?
Thanks!
Regards
|
|
|
|
|
Hi Obrix!
m also facing the same short of problem to windows service
did u got solution??
please share
|
|
|
|
|
I debugged the program and the entire 'timer1_tick' event is SKIPPED. Here's the link to download the program. If anyone can fix my program, upload the edited program on sendspace and provide the link.
http://www.sendspace.com/file/j0tkw3[^]
I am pretty sure the mistake is in the timer1_click event or in the property of the timer1.
Also on a side note, I am new to the code project and I want to know if uploading a project file here is possible. If so, please tell me how.
|
|
|
|
|
No, you can't upload a project, and we probably won't download it. How about you give us the code that creates the timer ? You're saying you set a breakpoint in the timer and it never fires ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Open Form1 in the editor. Select the timer1 component - it's in the gray area below the form. Right-click on it and select "Properties". There's a list of properties on the right. Above that list is a small icon with an icon that resembles lightning. Click on it, and you'll get a list of events. Click on the Tick event and set it to timer1_Tick . That should hook up the handler.
Alternatively, you could do this from code. Double-click on your form in the editor to create an OnLoad event, and add this code;
private void Form1_Load(object sender, EventArgs e)
{
timer1.Tick += this.timer1_Tick;
} Welcome to CodeProject
I are nuts today
|
|
|
|
|
Wow - you can set timers in the designer ? I've never tried that ( nor am I likely to, but.... )
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
yes, a lot of non-GUI stuff can be designed: timers, BackgroundWorkers, SerialPorts, ...
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Thanks, I didnt put it in the form_load event, instead put it in the start event and now my program works. LOL I can't believe I didn't realize that my tick event was never executed. THANK YOU VERY MUCH!
Edit:
I had to add a timer1.Tick -= this.timer1_Tick; on pause & restart though and I had to disable pressing restart on pause. Oh well, at least the program works. Thx
modified on Monday, June 22, 2009 2:09 AM
|
|
|
|
|
Hi,
do you have a timer1.Start(); statement somewhere, and are you sure it gets executed?
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
I'm sure that there have been a thousand questions on this topic, but here goes...
I have an application that uses the System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces() to retreive each friendly interface name on a machine with multiple adapters. Later, depending on other choices, the application needs to start UDP multicasting. For this I need to be able to find the IP address of the interface chosen. As I said, all I have is the friendly adpter name. How can retreive the IP address(es) of the NIC starting only the adapter name?
Raven
|
|
|
|
|
Hi to all.
Some of programs create thumbnail for its files
like Corel, Adobe reader, AutoCad, and some of weak pictures(like files that have error on download ) that have thumbnail
I want to catch file's windows thumbnail
please help me
|
|
|
|
|
there's a thumbs.db file in the folder, they are in there. Assuming you mean the thumbnail you see in Windows Explorer.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Are they if you set Windows to not cache it? Also there aren't going to be these files created on read-only media, so I guess there muse be some API for that...
Jan
|
|
|
|
|
Do you know how can I get the corresponding project of a custom component at design time?
For example: a custom list box resides in a form which belongs to a project. I need to access that project, from inside of the listbox, at design time.
Thank you.
Bogdan.
|
|
|
|
|
What do you mean, 'access the project' ? The csproj file is not there, nor can you change it's settings in the compiled dll. If you want the name of the project, if it happens to be the name of the main namespace, as is the default, you can get the name via reflection, but, given that it never changes, I assume this is not what you mean ( plus, I can't think of any reason to want to do this )
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|