|
If you've got a shortcut or the actual executable on the desktop and you drop a file on it, the filename will automatically be passed by the shell to the executable (you can get it through the Main function).
e.g.
private static void Main(string[] args)
{
Console.WriteLine("Dropped File: {0}", args[0]);
}
|
|
|
|
|
That's the answer! Thanks!
I had to modify this Main Function:
from:
static void Main(string[] args)
{
Application.Run(new Form1());
}
to:
static void Main(string[] args)
{
foreach (string s in args)
{
MessageBox.Show(s);
}
}
works nicely! and applied this to my intepreter executable... works perfectly as I was hoping for!
|
|
|
|
|
How to create drag and drop controls in win app. ? I want to create tool like Visual Studio( no need auto generate functionality, just drag and drop functionality is enough) please give some basic idea about that drag'n'drop controls.
C# feaver
|
|
|
|
|
Funny, this was posted shortly before mine... I'm not sure if we're on the same boat!
|
|
|
|
|
i want a source code windows explorer program if u do not mind >>>
pleaze
pop
|
|
|
|
|
ask from microsoft to provide it to you.
sAqIb
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|
Why not just ask for the code for Vista while you're speaking to Balmer.
|
|
|
|
|
Hi
Take a look at sourceforge.net there are a lot of open source project over there and maybe you can find one that suits your needs .
Good Luck
|
|
|
|
|
hi...
In my application , i'm using a thread to check for Queue contents. If i have any data then i have to transmit/receive that data. But my application is taking maximum CPU time if i'm using infinite for loop in this thread & because of this my CPU is using maximum time for my application(around 95%). & if i'm not using this for loop i am not able to transmit/receive whatever data is there in queue.
private void ComportThread()
{
for (; ; )
{
//Check for queue contains, if data is there then trnasmit/receive
}
}
What is the problem...?
Thanking you,
Vinay
|
|
|
|
|
Within your for loop, place a Thread.Sleep
|
|
|
|
|
See in a method which is working with thread if we have a loop we must use some code to stop the loop. for example i wrote the following code which passes to ThreadStart:
for(;;) {<br />
bytesRcvd = client.Receive(rcvBuffer, 0, rcvBuffer.Length,<br />
SocketFlags.None);<br />
msg1 = Encoding.UTF8.GetString(rcvBuffer);<br />
msg3 = "\0";<br />
msg1 = msg1.Trim(msg3.ToCharArray());<br />
<br />
Array.Clear(rcvBuffer, 0, rcvBuffer.Length);<br />
}
the thread is await until the data received if we wrote a code in loop that has no stopping, CPU will be busy by 100%.
Bahman
|
|
|
|
|
You can use a synchronizer, like semaphore to avoid the CPU usage of the ComportThread().
The ComportThread will wait on a semaphore. The producer will signal the semaphore when an object is queued.
This way the ComportThread will wake up only when it is needed.
Ami
|
|
|
|
|
How do you do the checking of the queue to find if data is available? I'd suggest that you use some synchoronization mechanism like Monitor[^]. This would result in the thread not getting scheduled until there is data available in the queue.
|
|
|
|
|
Using a ManualResetEvent will be good for these kind of problems.
in ur looop call WaitOne() on ManulResetEvent object before check or getting data from queue. And in the thread where you add the Data to queue you must Set the ManulResetEvent object.
<br />
Queue processing thread...<br />
while(true)<br />
{<br />
newDataAdded.WaitOne();
<br />
<br />
if (queue.Count == 0)<br />
{<br />
newDataAdded.Reset();<br />
}<br />
}<br />
And in the code where you add Data items to queue write code to set the ManualResetEvent object like this,
<br />
public void AddData()<br />
{<br />
newDataAdded.Set();<br />
}<br />
|
|
|
|
|
Hi...
Here is complete code what i am doing...
private void ComportThread()
{
for (; ; )
{
if (MsgQueue.Count > 0)
{
string firstItem = (string)MsgQueue.Peek();
comport.Write(firstItem);
MsgQueue.Dequeue();
}
}
comport is object of serialport class & MsgQueue is object of Queue...
can u tell me now what is the probelm exactly...
Regards,
Vinay
|
|
|
|
|
The problem with ur Thread is repeatedly polling for Data in the queue.
We can reduce the CPU utilization as far as possible by making ur thread work only when there is something in the queue and the way to do is explained in my previous post. USE A ManualResetEvent there in ur loop.
|
|
|
|
|
I'm developing Windows Applications under Visual Studio 2005. I've noticed that when radio buttons, check boxes or command buttons have the focus on a form, all I need to do is press the letter assigned as a shortcut key for another control for that other control to receive the focus. I really do not want that behavior, I want the user to always have to press Alt-letter for a control with a shortcut key to get the focus (when a text box has the focus, the user does have to press Alt-letter for focus to change to another control). Can anyone tell me what I need to do to ensure that the user has to press Alt-letter to set focus to a new control when a radio button, check box or command button has the focus?
Thank you...
|
|
|
|
|
use the & sign for the letter (in the text of that control) you want to use as a shortcut, and it will work with the Alt key. e.g
btn1.Text = "&button"
so the shortcut for btn1 will be 'Alt+b'
regards
sAqIb
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|
I'm afraid I either posted my original question very poorly, or you misunderstood. I know how to create a shortcut key, my problem is that when a control other than a text box control has the focus, the user does not have to press the Alt key to go to another control that has a shortcut (or accelerator) key. For example, assume the command buttons below where btn1 has the shortcut set to "b", and btn2 has the shortcut set to "u"
btn1.Text = "&button1"
btn2.Text = "b&utton2"
If btn2 currently has the focus, the user only has to press the letter "b" for btn1 to get the focus. I would prefer if the user always had to press the "Alt" key before any shortcut is activated but as long as the focus is not on a textbox, the "Alt" keys is apparently now unnecessary.
I know I can tackle this issue by ensuring the Alt key is pressed in the KeyDown event of non-textbox controls, but I'm hoping there is some global setting in Tools-Options that I do not know about that will quickly tackle this issue for any apps I may develop.
Thank you...
|
|
|
|
|
hi,
how can i get the current logged in user (on the computer) from the active directory.
Best regards
jamil abou khalil
|
|
|
|
|
using System.Security.Principal;
WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());
Console.WriteLine(wp.Identity.Name);
|
|
|
|
|
Here's another method:
string user = System.Environment.UserName;<br />
Console.WriteLine(user);
Ashish
|
|
|
|
|
I am trying to get the the btnEat button to be able to access the methods for the dog object I have created but it does not exist outside of the btnCreate event. Please advise, I think its something fundamental but I can not find anywhere which answers my question, or I do not know the correct terminology for it, thanks.
************************ EVENTS on button ************************
private void btnCreate_Click(object sender, EventArgs e)
{
Animal dog = new Animal();
dog.Name = txtName.Text;
lstAnimals.Items.Add(dog.Name);
lblAnimalCount.Text = "Animal Count " + Animal.Animals.ToString();
MessageBox.Show("There is currently " + Animal.foodstock.ToString() + " units of food left");
dog.eat(); //Dog Can eat here
MessageBox.Show(dog.Name + " has eaten 1 unit of food, there are now " + Animal.foodstock.ToString() + " units left");
}
private void btnEat_Click(object sender, EventArgs e)
{
// I want to make dog eat here but not sure how.
}
************************ ANIMAL CLASS ************************
class Animal
{
public Animal()
{
Animals += 1;
}
public static int foodstock = 15;
public static int Animals;
string AnimalsName;
public string Name
{
set
{
AnimalsName = value;
}
get
{
return AnimalsName;
}
}
public void eat()
{
foodstock -= 1;
}
}
******************************************************************
Thanks a million, this is a real stumbling block for me at the moment in learning
|
|
|
|
|
i think u should define Animal dog; otside the event and in event section
private void btnCreate_Click(object sender, EventArgs e)
{
dog = new Animal();
dog.Name = txtName.Text;
lstAnimals.Items.Add(dog.Name);
lblAnimalCount.Text = "Animal Count " + Animal.Animals.ToString();
MessageBox.Show("There is currently " + Animal.foodstock.ToString() + " units of food left");
MessageBox.Show(dog.Name + " has eaten 1 unit of food, there are now " + Animal.foodstock.ToString() + " units left");
}
private void btnEat_Click(object sender, EventArgs e)
{
if(dog!=null)
{
dog.eat();
}
}
rahul
|
|
|
|
|
I have declared the object here and it works as I hoped:
namespace WindowsApplication1
{
public partial class frmAnimal : Form
{
public frmAnimal()
{
InitializeComponent();
}
Animal dog = new Animal();
....
}
Is this an acceptable place to put it or is there a standard? Do you have any advice on where I can learn about this syntax? Thanks
*-Edit-*
I also would like to add another animal, i.e a cat would I need to declare where I have put "Animal dog = new Animal();" another one for cat or could I use a variable instead of 'dog' and dynamically name the object (I really hope this makes sense!!)
Phill
|
|
|
|