|
Hi...,
I want to close my AboutForm by clicking somewhere, not only on the Form. Is there a general MouseEventHandler?
Thank you,
Michael
|
|
|
|
|
One simple way to achieve this behavior is to use Click event and LostFocus event of the Form. Such as –
---------------------------
Private Sub Form2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
Me.Close()
End Sub
---------------------------
Private Sub Form2_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LostFocus
Me.Close()
End Sub
----------------------------
I hope this helps.
-Dave.
------------------------------------
http://www.componentone.com
------------------------------------
|
|
|
|
|
Hi Dave,
thank you for this idea. This only works, when the focus goes to another application window. When the focus loses to the parent windows, nothing happens.
I think I still need a more bulletproof solution.
Thank anyway,
Michael
|
|
|
|
|
Hi Everyone I'm doing something where I want to draw multiple controls, without redrawing every time I e.g. resize. The Problem is that I don't want the user to see all the buttons redrawn, every time they e.g. resize the form - any suggestions?...I've tried with double buffering but can't seem to get the hang of it...
Here's an example of how to genereate my problem, then try to resize the form:
public void createButtons()
{
int xlen = 40;
int ylen = 50;
int xpos = 23;
int ypos = 12;
Button[,] buttons = new Button[xlen,ylen];
for (int i = 0; i < xlen; i++)
{
for (int k = 0; k < ylen; k++)
{
buttons[i, k] = new Button();
buttons[i, k].Location = new System.Drawing.Point(xpos, ypos);
buttons[i, k].Size = new System.Drawing.Size(26, 23);
ypos += 20;
this.Controls.Add(buttons[i, k]);
}
xpos += 30;
ypos = 12;
}
}
|
|
|
|
|
CoolAL wrote: int xlen = 40;
int ylen = 50;
2000 buttons? Are you kidding me?
led mike
|
|
|
|
|
Mabye he's building a system for George Jetson to use...gotta make sure that button pushin finger stays strong.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Use the following:
this.SuspendLayout();
this.ResumeLayout();
The SuspendLayout() method Suspends the drawing of the control until the ResumeLayout() method is called. So, call the SuspendLayout() method on the form and add the controls. After adding them, call the ResumeLayout() method on the form.
See the msdn page for SuspendLayout() method for a complete example!
|
|
|
|
|
|
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
It's working fine in Intenet explorer but it is not working in Mozilla firefox.If anybody knows this solution, Please help me.
function runApp(tel)
{
var shell = new ActiveXObject("WScript.shell");
shell.run("C:\call.exe "+tel, 1);
}
Now I need to do the same from out Firefox 2.0 ( Call call.exe file from javascript )
How do I get it done.
|
|
|
|
|
Hey
I am using a windows form in an XNA Game application. The form is displayed when the user clicks on buildings or people within the game world.
However, the game stutter's when the form is been displayed. What I mean by stutter is that it pauses for a brief moment. This is ok if the camera isn't moving, but is very noticeable when it is moving. It seems to only occur when setting the form to visible (i.e. it doesn't stutter when refreshing the form).
The way I display the forms is this. When the game is first loaded, the forms are created and set to be hidden. When the user clicks on an object, the form is set to be visible. Closing the form is in fact just hiding it. I have it this way as it would be faster then creating a new form and destroying it everytime the user clicks on an object.
So, is there anyway to get rid of this stutter or is the method in which I display the form causing the issue.
Any help is much appreciated, Thanks!
|
|
|
|
|
I can't tell you anything definitively so keep in mind that everything I am about to say is a pure guess.
Benzino wrote: or is the method in which I display the form causing the issue.
I doubt that is the cause. It is likely that DirectX rendering is maximizing use of the graphics system so when you attempt to also execute the .NET framework graphics system there is contention for the limited resources that a PC has.
I have spent zero time looking at XNA and not much more with DirectX. However I would guess that to avoid your scenario the DirectX/XNA systems have there own Window/Dialog mechanisms that you should use rather than a .NET Windows Form.
led mike
|
|
|
|
|
thanks for the help. I haven't seen anything other mechanism within xna but i'm sure there most be. thanks.
|
|
|
|
|
Hi, I have a project with 2 groups of buttons and I need assign to event on click to 1 group same piece of code and to 2 group another code. Solving it some component like GroupBox or someone?
|
|
|
|
|
Hi,
you can use the same Click handler for more than one Control.
And if need be, cast sender to the right Control type to find out which Control fired the Click event.
|
|
|
|
|
Can you write that in code please? I need something like this to more powerful code:
NOW:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
}
...
Future something like this:
button 1-10_Click
|
|
|
|
|
replace button2_Click by button1_Click everywhere;
replace button3_Click by button1_Click everywhere;
replace button4_Click by button1_Click everywhere;
replace button5_Click by button1_Click everywhere;
replace button6_Click by button1_Click everywhere;
replace button7_Click by button1_Click everywhere;
replace button8_Click by button1_Click everywhere;
replace button9_Click by button1_Click everywhere;
replace button10_Click by button1_Click everywhere;
everywhere also includes code autogenerated by Visual Studio.
|
|
|
|
|
Thank you, it works. But I have got still one little problem.
I need take Button1->Text, ..., Button10->Text so I have something like that
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
textBox1->AppendText(buttonX ->Text);
}
How to change X?
|
|
|
|
|
Hi,
as I told you before, you can
cast sender to the right Control type to find out which Control fired the Click event.
In your case, cast to Button, then use its Text property.
|
|
|
|
|
can you write it in code please?
|
|
|
|
|
if you show your code, and specify its symptoms, CP members will help and pinpoint the problem(s).
|
|
|
|
|
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
textBox1->AppendText(System::Windows::Forms::ButtonBase::Text);
}
I do this code, but it still needs System::Windows::Forms::ButtonBase::Text as a static.
I think I follow your definition - you can say that in values sender and e is everything what can we need.
|
|
|
|
|
you still need to take "sender", cast it to a Button and take its Text.
|
|
|
|
|
textBox1->AppendText(this->ActiveControl->Text);
Yipee! Fairness still exists Thank you so much
modified on Sunday, July 6, 2008 4:40 PM
|
|
|
|
|
The other answer posted to this thread will work perfectly. Another option would be to create a new usercontrol for the groupbox control collection.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|