|
private void Form_OnClosing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true; //prevents the form from closing
}
This will prevent the form from closing ever!!!!! You do want the user to close the form somehow if not by clicking on the "cross"??
|
|
|
|
|
This is just a sample. I'd assume zecodela would know enough to put some conditional statements in there before setting e.cancel to true .
|
|
|
|
|
I would like to remind you that your users will expect to be able to close their windows this way. It seems to me to be a big violation of good GUI principles to proceed this way. I would suggest that it would be far better to disable (probably difficult) or not show the close box. In this way, your users won't be confused with the lack of function.
α.γεεκ Fortune passes everywhere. Duke Leto Atreides
|
|
|
|
|
I'm having some problems getting the values of some unmanaged enumerations.
For example, calling NetServerEnum returns me a int value of 234 in C#, but I'm not sure which one of the possible enumeration value it is(ie. ERROR_MORE_DATA, or ERROR_NO_BROWSER_SERVERS_FOUND, etc.)
can anyone point me to the direction when I can get the values of any unmanaged enumerations?
|
|
|
|
|
Someone has taken the pain to have a declarations and constants of Win32API for usage in .NET.
You can get them here[^], I think it is in VB but should be useful nevertheless.
- Kannan
|
|
|
|
|
Thanks, that was a cool tool. Unfortunately, It defines only 4 enumerations.
|
|
|
|
|
Ack, sorry. I've found that the values I wanted are under Constants, not Enumerations. So, it is a fantastic tool after all.
Thanks again.
|
|
|
|
|
I was thinking that you should be really unlucky if you are not able to get your enum in that 55k odd available there...
Anyway, its a very handy tool to have when you are doing lot of interop
Regards,
Kannan
|
|
|
|
|
Where i Can get C # API
I need to work on Image Processing
Want to select an Image and change the color of selected region
HELP REQ
Ritesh Dubey
|
|
|
|
|
There is nothing called as a C# API.
You will be using the .net framework classes from whatever .net language(C#,vb.net,j#...) you are working on.
For image processing there are some good articles here in CP written by Christian. Check out the below articles,
GDI+ Articles[^]
Also there is a Managed DirectX SDK[^] available which has some nice samples to get you started.
- Kannan
|
|
|
|
|
I have a number of mdiChildren that are added to a parent. When these children are minimized i want them to Hide. To regain access to these mdiChildren, you have to access them via statusbar. The problem i'm having is unhiding the children. I restore using the panelOnClick and minimized using ReSize.
//Minimize Code
protected override void OnResize(EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
foreach( RichStatusBarPanel panel in serverForm.mainForm.statusBar1.Panels )
{
if( panel.Text.ToLower() == this.channel.ToLower() )
{
panel.BorderStyle = StatusBarPanelBorderStyle.None;
}
}
//this.Hide();
this.Visible = false;
}
base.OnResize(e);
}
//Restore Code
foreach( Form room in this.MdiChildren )
{
if( room.Text.ToLower() == panel.Text.ToLower() )
{
if( room.Visible == false )
room.Focus();
//room.Show();
room.Visible = true;
if( room.WindowState == FormWindowState.Minimized )
room.WindowState = FormWindowState.Normal;
}
}
Before I was having a problem where everytime I went to Show or Visible = true; it would crash the program. I found out you need to add Focus to it before doing this and it will become visible. However, when I do it like that. Altho it shows, I can never really get Focus of it, I think. Basically it stays a light blue color instead of that darkblue when you have mainFocus on it. I've tried everything from Hide....Show...Visible true/false. Refresh...update u name it. No matter what I do it always stay that light blue color. I still can do my normal function on it. but when Maximized it no longer becomes the title of the parent. I just don't understand whats going on. Any help here?
|
|
|
|
|
I want to unregister an assembly from within a csharp app.
Basically all I want to is the exact same thing as:
regasm.exe /unregister (path to assembly)
only from within my app. (The assembly I'm unregistering is not the app running it, it's a different assembly.)
Also, I want to know how to register it again later, same as:
regasm.exe /codebase (pathtoassembly)
(I think what I'm stuck on is creating an "Assembly" class instance, since there's no constructor that just takes a file path as an arg. )
thanks
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Under the System.Diagnostic namespace you will find a class called Process which contains a static method called Start which takes a file name as a parameter and your args as a second parameter. Something like this should do the trick:
Process.Start(@"c:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat",
@"regasm.exe /unregister [path to your file] /silent");
-Nick Parker
|
|
|
|
|
thanks,
Ok, I knew this already actually, but I was hoping I could register an assembly from within dot net, like with the RegistrationServices class?
Are you saying that I need to include regasm.exe in my installer for the application when it's deployed? It's a shame, tha seems kind of hackish..
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Can anybody show me the shortest example on using a delegate? Im just trying to gather ideas on how to program in "keep it short and simple way"
"To teach is to learn twice"
|
|
|
|
|
The shortest example? Well I guess that would be...
class T{delegate void D();static void Main(){D d = new D(Main);d();}} ...but watch out for the stack overflow.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
The shortest example? Well I guess that would be...
class T{delegate void D();static void Main(){new D(Main)();}} ...but watch out for the stack overflow.
I suppose you'd like a useful example?
class Example {
delegate void StatusOutput(string text);
static void Main() {
DoSomeWork(new StatusOutput(System.Console.WriteLine));
DoSomeWork(new StatusOutput(Alert));
}
static void Alert(string text) {
System.Windows.Forms.MessageBox.Show(text, "Status Update");
}
static void DoSomeWork(StatusOutput output) {
output("Working...");
System.Threading.Thread.Sleep(2000);
output("Done");
}
}
That was about the shortest meaningful use I could think of. A delegate is an object that wraps a method. You can then pass this object around and use it later to call the method. There are lots of other more advanced uses, like invoking them asynchronously, but that's a start.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
When would be the best time in your own opinion to use the ref in C#?
"To teach is to learn twice"
|
|
|
|
|
When you need to modify the source variable rather than a copy of it.
Example:
void Test()
{
string str="UnModified";
RefTest(ref str);
}
void RefTest(ref string s)
{
s="Modified!";
}
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
How can I add a type derived from DataGridColumnStyle into the list in the DataGridColumnStyle Collection Editor dialog box (of the Properties dialog box)?
|
|
|
|
|
I have a project downloaded from somewhere (I dont remember from where) that demonstrates how to do this.
If you let me know your email id I can send it to you.
Suhas
|
|
|
|
|
I would like to have a combobox that shows bands of color instead of text. Would the best way to accomplish this be to use the OwnerDrawFixed (they're all the same size) style and draw the color bars in the DrawItem event? I don't want to create a custom combobox I simply want to draw colors instead of text.
- monrobot13
|
|
|
|
|
I'm trying to learn how to do Remoting in .Net and I've read a ton of examples on this site, other sites, and books and all of them have the line:
using System.Runtime.Remoting.Channels.Tcp;
But when I try to compile the code while in VS it fails with the following message:
The type or namespace name 'Tcp' does not exist in the class or namespace 'System.Runtime.Remoting.Channels' (are you missing an assembly reference?)
If I compile the code via the command line CSC filename.cs it compiles without problems and it works properly. I just can't seem to compile it in VS.
Any ideas?
Thanks,
Rick
|
|
|
|
|
You need to add a reference to System.Runtime.Remoting.dll
- monrobot13
|
|
|
|
|
Thank you very much! You solved my problem!
|
|
|
|