|
Don't use a string, use a parameter.
|
|
|
|
|
hi friends..
How to set mouse move(cursor movement) with some equal distances (like Autocad)...
|
|
|
|
|
Windows Form have a event MouseMove
The event gives you X and Y pos. After that it is all up to calculation
|
|
|
|
|
Hi friend..
can u send some sample code
|
|
|
|
|
private void Form1_MouseMove(object sender, MouseEventArgs e)<br />
{<br />
label2.Text = "Pos X: " + (e.X - posX).ToString();<br />
label3.Text = "Pos Y: " + (e.Y - posY).ToString();<br />
int a1 = (e.X - posX) * (e.X - posX);<br />
int a2 = (e.Y - posY) * (e.Y - posY);<br />
int a3 = a1 + a2;<br />
Double a4 = System.Math.Sqrt(a3);<br />
label4.Text = "Relative: " + a4.ToString();<br />
}<br />
private int posX;<br />
private int posY;<br />
<br />
private void Form1_MouseClick(object sender, MouseEventArgs e)<br />
{<br />
posX = e.X;<br />
posY = e.Y;<br />
label1.Text = "Selected: X=" + e.X + " Y=" + e.Y;<br />
<br />
<br />
}<br />
<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
posX = 0;<br />
posY = 0;<br />
}<br />
On windows form override the following events and place four labels. This is a simple math operation.
Edit: This is in pixel. If you write such programs and have zoom level you have to convert to mm ir inchecs.
|
|
|
|
|
Hi friend..
i need the cursor will move equal distance..
for example.. the cursor position e.x is 100 and e.y is 50 means... the cursor is in 120,60(e.x,e.y)...How to set manual values as cursor position...
|
|
|
|
|
Have the container for yours value. Check my sample as having click event. The current position mouse becomes 0,0 and then you can move.
But if you want to prgramaticly move mouse then i dont know. I will try look into MSDN Library
|
|
|
|
|
|
Hello!
I have a class with a bunch of properties. Sometimes I only have a string for which property I should set. Is there some smart way to copy how datatable["NameofDataColumn"] works? So I can call my class´s property as I´ve done in subject-text?
/regards
|
|
|
|
|
|
|
I was reading this article[^]
And is it possible to use additional modifier "fn" that laptop has?
And how to detect diffrance betwen left and right modifier?
And yes i am using Net Framework 3.5 with C#. I am using Interops services to wrap native dll calls.
|
|
|
|
|
Hi all I'm trying to get my app to read in all contacts in the contact folder of Outlook.
code
-----------------------------------------------------------------------------------------------
Outlook.ContactItem item = (Outlook.ContactItem)objOutlook.CreateItem(OlItemType.olContactItem);
DataTable dt = new DataTable();
dt.Columns.Add("FirstName");
dt.Columns.Add("LastName");
dt.Columns.Add("CompanyName");
dt.Columns.Add("Email");
dt.Columns.Add("HomePhone");
dt.Columns.Add("WorkPhone");
try
{
objFolder = objNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
Debug.WriteLine(objFolder.Items.Count + " Contacts found.");
for (int i=0; i < objFolder.Items.Count; i++)
{
item = (Outlook.ContactItem) objFolder.Items.GetNext();
dt.Rows.Add(new object[] {
item.FirstName,
item.LastName,
item.CompanyName,
item.Email1Address,
item.HomeTelephoneNumber,
item.BusinessTelephoneNumber
});
}
Debug.WriteLine(dt.Rows.Count + " Contacts exported.");
}
catch (System.Exception e)
{
MessageBox.Show(e.ToString());
}
----------------------------------------------------------------------------------------------------
m getting an error system.nullreferenceException for "item".
what to do?
thanks in advance.
|
|
|
|
|
i need the equivalent to System.Windows.Forms.Application.Restart() for console app.
any hint?
thanks
|
|
|
|
|
buchstaben wrote: i need the equivalent to System.Windows.Forms.Application.Restart() for console app.
any hint?
There isn't one. You'll have to write it yourself. All restart does is to start a new instance of the application with the same set of conditions as the original was started within then shut down the current instance.
|
|
|
|
|
hm..in this case, the "new" instance is startet before the old is killed.
i'm not sure right now if this can be a problem, but i'd prefer to avoid this..
|
|
|
|
|
buchstaben wrote: hm..in this case, the "new" instance is startet before the old is killed.
Yes - Which is also how Application.Restart works too. (I naturally assume that you know this already)
buchstaben wrote: i'm not sure right now if this can be a problem, but i'd prefer to avoid this..
Why? You were happy to use Application.Restart if it were available to you.
|
|
|
|
|
Colin Angus Mackay wrote: Why? You were happy to use Application.Restart if it were available to you.
I were happy because I didn't know the behaviour
However, it works now.
|
|
|
|
|
Call Main again - but don't forget to include an exit condition somewhere otherwise you'll end up in an infinite loop.
|
|
|
|
|
calling main again would result in two running applications.
there are some background activities running in my app. in the main thread somewhere i'm waiting until all backgound processes finished. but if a certain time elapsed, i dont want to wait anymore and restart application, since there might be a hangup in any background process.
|
|
|
|
|
buchstaben wrote: calling main again would result in two running applications.
No it wouldn't. It would be the same application but the starting point is called for a second time.
buchstaben wrote: there are some background activities running in my app. in the main thread somewhere i'm waiting until all backgound processes finished. but if a certain time elapsed, i dont want to wait anymore and restart application, since there might be a hangup in any background process.
I'm not sure you are using the word process correctly here. Do you mean process as in a ancillary application (which would be the correct use of the word) or process as in another thread?
If you mean process as in other processes (ancillary applications) then just kill the processes.
If you mean process as in another thread then kill the threads.
|
|
|
|
|
i meant process in the thread context.
so i'm gonna kill all running background threads and return to main.
thanks.
|
|
|
|
|
buchstaben wrote: calling main again would result in two running applications.
No it wouldn't. You're not actually going to create a new process here - why do you think Main would behave differently to any other method, none of which results in a new process?
buchstaben wrote: there are some background activities running in my app. in the main thread somewhere i'm waiting until all backgound processes finished. but if a certain time elapsed, i dont want to wait anymore and restart application, since there might be a hangup in any background process.
This sounds like you are getting a bit confused architecturally. Don't restart the application - just kill the threads (be aware that this is really frowned upon though).
|
|
|
|
|
Pete O'Hanlon wrote: This sounds like you are getting a bit confused architecturally. Don't restart the application - just kill the threads (be aware that this is really frowned upon though).
just killing the threads wouldn't help, since i must ensure each background thread runs every main run.
a main run simply covers invoking all registered background threads, starting a timer and wait for the timer's and threads' ready-events. if both, timer and all threads are ready, start a new main run.
if timer is ready since x seconds, (assuming non-expected exception) the app should ignore the background threads' states and stop current main run. now all background threads have to be killed and invoked again. that's actually what my goal is.
architecturally this should be ok, shouldn't?
|
|
|
|
|
It's me again,
I have two check box. I want to decide on of it enable/disable state depend on other.
Say first one is enable, then the second also enable. If the first disable then the second also disable.
I try to use state change of the first, as follows.
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
checkBox2.Enabled = true;
}
In form load I disable the second checkbox. Say I check the first one and un-check it again. At that time the second checkbox is not disable again. What should I do
Thanks
I appreciate your help all the time...
Eranga
|
|
|
|