|
Hello,
I think you would have to call the Aport method of the thread instance.
All the best,
Martin
|
|
|
|
|
Hi,
In C# 2005 I need a hint how to solve if there is a control on a form and I click or select it in design-time, the Click event is fired in design-time. Important that in design-time! How can I catch the OnClick event or anything else in design-time? Also for Control or any ToolStripItem, like ToolStripButton.
Please help, it's important!
Thanks,
Attila
|
|
|
|
|
if ( this.DesignMode ) {
this.ProcessDesignTimeClick(e);
}
else{
this.ProcessRunTimeClick(e);
}
Geniality is in simplicity.
|
|
|
|
|
Thanks Jakub, but I do not really understand where to put this code, I do not have ProcessDesignTimeClick or ProcessRunTimeClick. How can I link it to a Button? Could you please more specific?
Thanks,
Attila
|
|
|
|
|
Class "System.ComponentModel.Component" has "Site" property typed as "ISite". The ISite interface has "DesignMode" property typed as "bool".
If value of "Site" property is not null, the component propably is in some designer. But if "Site.DesignMode == true", you can be sure.
So following method return true, if specified component is in designer:
bool IsInDesignMode(Component component) {
ISite site = component.Site;
bool ret = ( site != null && site.DesignMode );
return ret;
}
Class "System.Windows.Forms.Control" has "Site" property too and besides protected property "DesignMode" ( which's body is similar to 'IsInDesignMode' method ).
So, if you want to find out, if clicked button is in design mode, you check value of their "Site" property.
Example:
public class MyButton : Button {
protected override void OnClick( EventArgs e ){
if ( this.DesignMode ) {
MessageBox.Show( "This button is in design mode. Raising event 'Click' is verboten." );
}
else {
base.OnClick( e );
}
}
}
Or:
public class MyForm : Form {
private Button button1;
...
...
...
private void button1_Click(object sender, EventArgs e){
ISite site = this.button1.Site;
if ( site != null && site.DesignMode ){
MessageBox.Show("Button was clicked in design mode.");
}
else{
MessageBox.Show("Button was clicked in run-time mode.");
}
}
}
If you compose usercontrols in hierarchy, only the most top control in designer has value of "DesignMode" property set to "true".
You must search in hierarchy for real state of design mode.
Example:
<code>public class MyControl_A : UserControl{
private MyControl_B myCtl_B;
public MyControl_A(){
this.myCtl_B = new MyControl_B();
this.Controls.Add(this.myCtl_B);
}
}
public class MyControl_B : UserControl{
protected bool IsInDesignMode(){
bool ret = false;
Control ctl = this;
while( ctl != null && ret == false ){
ISite site = ctl.Site;
if ( site != null ){
ret = site.DesignMode;
}
ctl = ctl.Parent;
}
return ret;
}
protected override void OnClick(EventArgs e){
if ( this.IsInDesignMode() ){
MessageBox.Show("This control is in design mode.");
}
else{
base.OnClick(e);
}
}
}
Geniality is in simplicity.
|
|
|
|
|
An article that I have wrote here may be able to help you:Targeting Design-Time Events of User Controls[^].
You should be able to catch the click event in the WndProc of the designer of the control.
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[ ^]
|
|
|
|
|
Thanks Thomas, I have downloaded your code and tried it, but I thought there is a simplier way. It's too complicated.
Attila
|
|
|
|
|
I am sure their is a simpler way, but this is the only way that I can think of at this time.
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[ ^]
|
|
|
|
|
Hi,
I want to make macro, which should find some types in assemblies, which are referenced in project. I found documentation for interface VSLangProject.Reference & VSLangProject.Reference2, but I did not found any way how get types of that assembly.
Only way I know, is load assembly with Assembly.LoadFrom(), and then search types with reflection. But I dont find out this way effective.
Anyony can help me?
Thanks.
Geniality is in simplicity.
|
|
|
|
|
Hi everyone, I hope this's not a programming question
Can anyone tell me what do you use in C# to map some parts of an image?? say, to link some event to that part just like in front page?? any tool/way to do that??
Thanks a bunch guys
-- modified at 10:02 Thursday 15th February, 2007
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Sounds like a programming question to me
Either handle the onclick of your image, and work out which bit has been clicked, or put some kind of transparent control over each part of your image, and handle the click on those instead.
|
|
|
|
|
benjymous wrote: work out which bit has been clicked
I guess that was the question
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
At risk of answring a programming question in the lounge, you'd typically break your image into rectangular areas ( conceptually, or physically ), and track which rectangle had been clicked in.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
thank you Chris, though, I really didn't feel like it's a programming question, and I'm sorry it was turned to be one.. I just thought somebody would point out a tool for me and since I know the lounge is very active and since this's a part of a programming forum, even people in the lounge can give us tips or point out some useful tools out of their experience.
I apologize again and thank you for those who tried to help.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
How can i find the length of the text in textbox in the pixel (n pixel )
With thanks
MHF
|
|
|
|
|
|
|
Hi everyone,
Does anyone know if there's a good way to map parts of an image just like how we used to do in front page??
Thanks a bunch
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
What is the code to get the current bandwith speed?
|
|
|
|
|
Use a performance counter control.
Set the following properties:
CategoryName = Network Interface
CounterName = Current Bandwidth
InstanceName = name of the network adapter you want the bandwidth from
Hope this was helpful.
Brad
The secret to creativity is knowing how to hide your sources. - Albert Einstein
|
|
|
|
|
How can i obtain the age of a computer in our network, Is it possible by quering the WMI database
Albert
|
|
|
|
|
Hi,
i have creating a editor using RichTextBox i am not getting how to go to a specific line when i use the goto line number.
Thank you
|
|
|
|
|
If you're using .NET 2.0 you should be able to achieve this by first calling the GetFirstCharIndexFromLine and then assigning the return value to the SelectionStart property.
"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." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thank you
With Regards
Hiremath
|
|
|
|
|
When trying to debug a C# application, I get an erorr message that the debugger cannot start. Reason: "The binding handle is invalid".
Googling reveals that is due to Terminal Services not running.
Service control manager says it cannot start terminal Services because "the system cannot find the file specified".
Any ideas?
[edit]
XP Pro SP2
"Add/Remove Windows Components" does not list Terminal Services at all, and the service is listed only as "TermService" in the service control manager
[/edit]
-- modified at 4:00 Thursday 15th February, 2007
Developers, Developers, Developers, Developers, Developers, Developers, Velopers, Develprs, Developers! We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP Linkify!|Fold With Us!
|
|
|
|