|
for some reason this doesnt resolve my issue.
if i click on search really quickly it still searches in series instead of ignoring the extra clicks.
|
|
|
|
|
If this is your problem simply add
if(busy)
return;
at the beginning of the click event handler (ie. Button1_clicked) or the Search() method
Ragards
|
|
|
|
|
i inserted that code before the actual searching method.
still didnt work.
does it matter if the event is from a menu?
or would any other events throw it off?
edit 1: right now the only solution i can find is to pop up
another form that says there is something being processed.
it wouldnt have any buttons and would lock the user out
until the process succeeds or fails.
edit 2: just tested it and was unsuccessful. the parent
form seems unable to do anything while the child form has
focus.
the problem has expanded slightly to include any action that
requires a period of time from the network.
still hoping for ideas.
-- modified at 1:07 Thursday 13th July, 2006
|
|
|
|
|
Hello
There are many ways of dealing with this problem -lengthy operations- and each programmer chooses what suits him. Just at a glance I can think of some:
1- Put the operation on a separate thread and never stop dealing with the user
2- Disable all child controls using foreach loop in the parent
3- Override click event handlers in all child controls to display a gentle message explaining why the form is not responding
4- Displaying a modal form that captures the focus with a ProgressBar, Statusbar, and a cancel button.
PS.
I've tested the code I gave you, and it works fine. The problem must be in your implementation.
Regards
|
|
|
|
|
do i need to link the control to anything?
like, there are several buttons and menus that need to lock out the user while it is doing it's thing.
1 is a menu. another is a picturebox that simulates a button.
do i need to somehow add them to the control? or will just having the control work?
edit:
i put in debug comments for the LostFocus method. i didnt see any of the comments come out.
private void m_Control_LostFocus(object sender, EventArgs e)
{
if(this.m_BusySearching)
{
Debug.WriteLine("control_lostfocus: busy");
this.m_Control.Capture = true;
}
else
{
Debug.WriteLine("control_lostfocus: not busy");
}
}
-- modified at 7:04 Thursday 13th July, 2006
|
|
|
|
|
Hello
Your problem is that your dummy control doesn't get focus at all. That is why it doesn't lose focus when the user clicks anywhere else.
Before the
dummy.Capture = true;
line insert this:
dummy.Select();
Well, the Focus() method is only present in the .Net 2.0, but try this, maybe it'll work.
Regards
|
|
|
|
|
i tried both of the following:
myControl.Select();
myControl.Capture = true;
and also
myControl.Focus();
myControl.Capture = true;
.net 1.1 has focus() as well as select. neither call it up though.
by the way, the way i'm testing this is by doing the following:
1. start up the program.
2. click on search once.
3. wait until it's done searching.
4. click on search 3 times.
my program has a timer to auto search again, but it's every 10 minutes.
each time it does a search it does a debug line.
again, thanks for the help. i'm pretty sure this is a small error somewhere ...
|
|
|
|
|
Hello
I wish I could help you more, but I must see the whole code and test it.
Good luck, and I hope you make it.
Regards
|
|
|
|
|
maybe you can suggest a Control tutorial...
something else i tried was before i go into the search method, i do a
SearchButton.Enable = false;
however this doesnt work either.
|
|
|
|
|
could i have done something to this form to accidentally make it always listen?
how is your Control solution different from Form.Controls?
i'm not able to add MainMenu items to Form.Controls.
however, there is a this.Capture field. can i use that somehow?
-- modified at 4:41 Monday 17th July, 2006
|
|
|
|
|
Hello
In another post you said:
lushgrass wrote: however this doesnt work either.
What's wrong with it?
lushgrass wrote: how is your Control solution different from Form.Controls?
What do you mean?? Different in what exactly?
lushgrass wrote: i'm not able to add MainMenu items to Form.Controls
What does this have to do with your isuue?
lushgrass wrote: however, there is a this.Capture field. can i use that somehow?
It doesn't matter. Just set the capture of the mouse somewhere.
If you still can't get it to work, try this:
public partial class Form1 : Form
{
private delegate void React();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Thread MyThread = new Thread(new ThreadStart(MySearchMethod));
foreach (Control C in this.Controls)
C.Enabled = false;
MyThread.Start();
}
private void Reactivate()
{
foreach (Control C in this.Controls)
C.Enabled = true;
}
private void MySearchMethod()
{
int temp = 0;
while(temp < long.MaxValue)
temp++;
Invoke(new React(Reactivate));
}
}
I had to reactivate using another method because the code falls directly after the thread start, and it would reactivate everything even if the thread hasn't finished yet -and maybe that was one of your mistakes in the previous approach-.
Also you have to cal the reactivation method by Invoke(), because cross thread access to form controls is denied.
Regards
|
|
|
|
|
I have an application with several controls but one (checkbox)is disable. I want to send a CTL+M to anable the control.
Any help is greatly appreciated
|
|
|
|
|
Catch the KeyDown event and put this :
if(e.Modifiers == Keys.Control && e.KeyCode == Keys.M)
{
}
|
|
|
|
|
Hello,
I have an MS Access database that has the following structure:
# Category #
- CAT_ID
- PARENT_CAT_ID
- TITLE
I need to populate a treeView control from the table recursively.
Can you please tell how can I do that?
Your help would be greatly appreciated.
|
|
|
|
|
Hello
How about this psuedocode:
foreach(DataRow r in MyTable.Rows)
{
if (MyTreeView.Nodes.Find(PARENT_CAT_ID, true).Length == 0)
MyTreeView.Nodes.Add(CAT_ID);
else
{
foreach (TreeNode MyNode in MyTreeView.Nodes.Find(PARENT_CAT_ID, true))
MyNode.Nodes.Add(CAT_ID);
}
}
Regards
|
|
|
|
|
Hi,
how can i possibly display graphics object? i created it from a picturebox and i added something to the picture but i have no idea on how to display it as i could not convert it to image or bitmap object to display. Can anyone help?
Thanks
|
|
|
|
|
Hello
ah_jiang_9 wrote: how can i possibly display graphics object?
There is a Paint event -or a similar event- that you have to handle in your control to draw whatever you want. In it's PaintEventArg.Graphics you can draw your image as you like. Some controls don't fire this event as they draw there own interface. Yet you can inherit from them or customly draw them. This depends on where you want to draw your graphics object
ah_jiang_9 wrote: i created it from a picturebox and i added something to the picture but i have no idea on how to display it
Why? It's as simple as these three lines:
pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height); //Make a new image in the box
Graphics g = Graphics.FromImage(pictureBox1.Image); //Make graphics
g.DrawLine(Pens.Black, new Point(5, 5), new Point(30, 30)); //Draw
Regards
|
|
|
|
|
Hello,
I have this project in mind that includes RS-232 input from a two axis accelerometer. I would like to create a graphical representation of the amount of tilt that the accelerometer measures yet have not a clue how to set up the graphics. I have already created the code to read the accelerometer and translate this into an angle. I wanted to display a line within a circle that represents this angle. I know the math required to find the X,Y components of this line yet dont know how to do this in C#. Any insight would be appreciated. Thanks in advance
cwkoehler
-- modified at 22:55 Thursday 6th July, 2006
|
|
|
|
|
Hello
Create a form, in which create a PictureBox. Use a bitmap of your accelerometer -analog of course- with its grading -careful here;)- as the PictureBox.Image
Now Create a graphics object from that image & draw the line like this:
Point BasePoint = new Point(BaseX, BaseY);
Point GradePoint = new Point(X, Y);
pictureBox1.Image = new Bitmap("MyAccImg.bmp");
Graphics g = Graphics.FromImage(picturebox1.Image);
g.DrawLine(Pens.Black, BasePoint, GradePoint);
Regards
|
|
|
|
|
I have a simple WinForms application developed on .net2.0 and VS2005. I am able to publish the application as a ClickOnce SmartClient to a specific directory located on my machine: C:\apps\publish. Now I am trying to publish the same application from command line using msbuild with the following command...
msbuild /t:publish Solution3.sln
The problem is that the application is published to the project bin\Debug directory, not the C:\apps\publish folder. I set the publish, install, and update URL in VS publish settings to 'C:\apps\publish', but it makes no difference, it msbuild still publishes the files to bin\Debug.
Am I missing something? Changing the OutputPath created issues when attempting to install the application for the first time, so I left it alone for now.
Thanks,
Raffi
|
|
|
|
|
I am trying to consume a Java Web Service through C# client. The soap body when I pass as string, the < > get encoded as <, > and that causes problem for the Webservice. Is there a way to prevent it? I tried using XmlElement but the problem is that the XmlElement already has the root element and then I get two root elements in the soap body. If I try to remove the root then it becomes invalid xml as there are two child nodes and the root is missing. Any help is appreciated.
Thanks,
Vishy
|
|
|
|
|
what is the shutdown command in c# ?
erfan
|
|
|
|
|
|
System.Diagnostics.Process.Start(@"C:\WINDOWS\system32\shutdown.exe", "/f /t 00");<br />
|
|
|
|
|
i want to execute media player in my program .
how i can run a specified application from a dialog based program in C#.
erfan
|
|
|
|