|
|
hi all, i just want to ask for suggestion
i create a windows form program mainform.cs, and in this mainform i created instance of all classes that will be used.
then i have another form that will only be created when user click a button on mainform.
the second form itself have some functionality, when user click on button, it will call a function.
I found doin this(multiple forms) slow down my program 100% instead of just using one mainform and call the function when user click on the button of the mainform directly.
If this is true that C# windows form very slow when i did this, it's very bad right?
i used to program with multiple java frame(window) and it doesn't matter at all.
Is there something wrong i did?
|
|
|
|
|
vcorn wrote:
Is there something wrong i did?
It sounds like it because I've never had any slow down in speed when dealing with one, two or more forms.
Can you describe more accrurately what you are trying to do, because I can't work out what you're doing to get it to slow down.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
i feel weird too,
it's basically just call a function of an object when user click on a button.
indeed this function deal with active directory(creating user in active directory).
when i switch to call this function from mainform button, it execute just well.
but when i change it to call this function from the second form(show as dialog with mainform as parent), it slow down, i have to wait 2-3 minutes to get it finish executing creating a user.
so i think there is nothing wrong in the code that slow down the performance,am i right?
|
|
|
|
|
Hi.
I search to add descriptions into the "intellisense" when i wrote a class or functon etc...
Thanks a lot
Alex
|
|
|
|
|
Check the following lines before class definition and chage it to meet your needs:
public class Info ..........
|
|
|
|
|
Use the various XML documentation tags to document your source code.
See the help for "XML documentation" for more information on this topic.
www.troschuetz.de
|
|
|
|
|
thanks to all
it's exactly what i search
|
|
|
|
|
How kan I make a button without borders that popups?
I kan make popup button but when the mouse isn't
over, the button still have border.
|
|
|
|
|
|
Thank you very much!
Is it not possible to be made directly in C#
without a class in C++?
|
|
|
|
|
Yes, but the concepts are usually the same. Almost every Windows Forms control (including the Button ) merely encapsulates the Windows Common Controls, so what's possible when handling messages is the way it's typically done in .NET (taking into account, of course, that much functionality is already exposed in methods, properties, and events - so don't redo what's already been done).
If you search CodeProject for buttons in the C# and .NET categories, you're bound to find a better example of this.
Also, read about the Button.FlatStyle property (inheritted from ButtonBase ) in the .NET Framework SDK to see if that will do what you need.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you very much ))
|
|
|
|
|
I would like to switch off with code the autorun function
when I put a new CD in the CD drive. I have to read
information from my programme for the files on the CD
without interupting from the autorun function.
How can I do this?
|
|
|
|
|
I don't understand. You want to write a program to switch off the autorun feature so you can insert a CD without it auto running? Why not just press the shift key while inserting the CD?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
This would be an option if it was only one cd; but the program that I'm building is for cataloging several cd's and it is not so practical to hold down the shift key for several seconds every time i want to add a cd. Keep in mind also that not all of my users will be aware of this option so i prefere to "temporary" disable the autorun function while using the program
|
|
|
|
|
As the Microsoft Powertoy TweakUI allows you to disable the Autorun function of drives, I think this can be done by manipulating the registry.
Don't know a concrete key for this, but maybe you could get this info in some forum which deals with Windows and stuff like that
www.troschuetz.de
|
|
|
|
|
Thank you very much.
The problem is that if I do this with windows registry
I have to restart my computer and I would want to do
this without restarting the computer.
Have you other idea?
|
|
|
|
|
Uuh, you're right. Didn't considered that.
Maybe you can somehow simulate the holding of the Shift-Key, which Colin proposed, programmatically. It isn't quite elegant, but maybe it works.
www.troschuetz.de
|
|
|
|
|
|
There is a programmatic way, and many installers (including the Windows Installer runtime) will do this when prompting for CDs.
In order to do this, you must P/Invoke the RegisterWindowsMessage API to register a windows message that should be handled in your Forms override to the WndProc method. I would recommend defining a property to easily enable or disable autorun:
public class MyForm : Form
{
internal static uint QueryCancelAutoPlayMsg;
private bool enableAutoPlay = true;
public bool EnableAutoPlay
{
get { return enableAutoPlay ; }
set { enableAutoPlay = value; }
}
[DllImport("user32.dll", CharSet=CharSet.Auto)]
private static extern uint RegisterWindowMessage(string msg);
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (QueryCancelAutoPlayMsg == 0)
QueryCancelAutoPlayMsg = RegisterWindows=Message("QueryCancelAutoPlay");
if (m.Msg == QueryCancelAutoPlayMsg)
m.Result = new IntPtr((int)enableAutoPlay);
}
} Please note that this is only a sample. I recommend you read more about canceling autoplay on MSDN in Enabling and Disabling AutoPlay[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you very much!!!! ))
You are super! You have always
a answer for a difficult question!
Thank you very much once again! ))
|
|
|
|
|
I am a moderately-skilled VB.NET guy who has (very) recently moved to C#. Where I seem to be having trouble is whenever I expect the same sort of forgiveness that VB seemed to give.
It seems that enums in C# are not as flexible as they were in VB. I am not sure if this true, but I am struggling where I did not expect to.
I have an enum that has int values. Basically, it is like this:
public enum Things<br />
{thing0 = 0, thing1 = 1, thing2 = 2}
... and so forth. What I can't do is this:
int numericThing = 1;<br />
Things aThing;<br />
aThing = numericThing;
This throws a CS0029 error about how it cannot implicitly convert type int to type Things.
What am I missing? I mean, if it doesn't work this way? What's the point?
I do not want to curl into the fetal position and crawl back to VB...
|
|
|
|
|
You need to cast it to Things:
Things aThing = (Things)numericThing;
|
|
|
|
|
Wingnut74 wrote:
What am I missing? I mean, if it doesn't work this way? What's the point?
I do not want to curl into the fetal position and crawl back to VB...
As mentioned, you need to cast it to int.
And, IMO, this is one of the C# strenghts over VB. Notice, VB allows you to do things that may cause hard to find runtime bugs, while C# will stop them at the moment you're compiling. This is called a "strongly-typed language".
notice this code:
int numericThing = 1;
Things aThing;
aThing = (Things)numericThing;
Now, it compiles, but does it work? Not always. What if numericThing has a value that is an invalid Thing? You should validate it before assigning.
And that's why the C# compiler stopped you.
Yes, even I am blogging now!
|
|
|
|