|
You mean Form.ShowDialog ? Yes, but you must dispose the Form when you don't need it anymore. Modal dialogs need to be disposed explicitly or you'll gradually consume more and more memory that won't be reclaimed because of native resources:
using (MyForm form = new MyForm())
{
form.ShowDialog();
} Using using this way ensures that even if an exception is thrown your modal form is disposed. See the .NET Framework SDK for the Form.ShowDialog method for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you for ask,
Sorry, but,
I need to know Who can i use "window.showmodal" in web appl.
|
|
|
|
|
Then you should be more specific about what you need. This question doesn't belong in this forum. Ask in the Web Development[^] forum.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thanks for your amiability and your time.
|
|
|
|
|
Hi all,
im having a small problem using an imagelist with a treeview. the problem is basically as follows. I add an imagelist and populate it with images (16x16 32bit) and i bind the imagelist to a treeview. so far so good, now if i add nodes to the treeview in code/designer time for a short while its ok, but after a while (a few compiles) the imagelist seems to break and the treeview nodes appear to have "blank" image.
The only way i can fix this is to manually delete the treeview and add it again with the imagelist.
Has anyone got a more practical solution to my problem?
many thanks,
Will
|
|
|
|
|
When you use the designer to add an ImageList , that ImageList is serialized to your .ResX file, which VS.NET uses by default (it's hidden; click Project-<Show All Files). There is a known issue where this can get corrupted. The solution is to remove the .ResX file - not your TreeView component - and re-add a .ResX file and then your ImageList . Your image indexes for the TreeNode s will still be correct so adding the new ImageList with images in the same indices will save you a lot of work.
This should be fixed in VS.NET 2005.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ive been asked to create a profile tool that interfaces with msn. It uses the events generated by msn to build up a users profile. What language would people recommend I use, and reasoning. Ive seen this dotMSN libary in C#. would people say this is the best way to go about this task??
any suggestions greatly appreciated.
mikey
|
|
|
|
|
"Best way" is a matter of opinion. If you like the dotMSN code and don't mind installing the .NET Framework on whatever machine(s) need to build profiles, go for it.
Accessing the Windows Messenger/MSN Messenger APIs is done through COM, so any language that can server a COM client (and there's many!) can do it. If you don't want to worry about the 20+ MB .NET Framework installation, you could use VB6 which would be pretty easy as well.
Keep in mind that the Messenger APIs change quite a bit from major version to major version. That alone can make what you want to do a pain. Perhaps they have finally settled on an object model and will only version new interfaces from here on out. One can only hope.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
OK. I'm working on my first C# windows app. It has a couple of forms as well as a LOGIN FORM. The LOGIN FORM pops up at Application.Run() and requires the user to select a SQL Server in which to connect and enter a userid and password.
Where/How would be the best place to store this dynamic connection information so that I may reuse it later on for subsuquent database connections. An important note is that the app needs to be able to perform different tasks on different databases on that sql server once the user is connected.
MITA
|
|
|
|
|
One common method is to have a static collection property on some class that all your code can access like so:
public sealed class DB
{
private static SqlConnection connection;
private static object syncRoot = new object();
public static SqlConnection Connection
{
get
{
if (connection == null)
lock (syncRoot)
if (connection == null)
connection = new SqlConnection(
ConfigurationSettings.AppSettings["ConnectionString"]);
return connection;
}
}
} The caller is still responsible for opening and closing the connection, but you should leave it that way so you don't leave connections open longer than you have to. This can degrade performance (and limit connections too much) on your database server. Also note that I use SqlConnection only as an example. You could use any connection class, or even the ADO.NET interface IDbConnection if you wanted to. The latter idea would fit nicely with using a provider pattern.
I also used an example where the connection string is placed in the appSettings section of your app's .config file, which is also another good idea.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I try sending a message to a queue and AppSpecific contains the type of my message, the body is object of a class (Order). and i set formater for the queue.
_mq.Formatter = new XmlMessageFormatter(
new Type[] { typeof(Order) });
When I receive a message from the queue, I just got the body, not the info in AppSpecific field.
I tried to set
DefaultPropertiesToSend.AppSpecific
but don't know which info should i give to it.
If i send AppSpecific along with the message body do i have to change the formater to receive AppSpecific or just leave
it the same as above.
Could anyone here show me how to solve this problem.
Thanks,
Huy
|
|
|
|
|
Hello,
Can anybody tell me how to use serial communications rs232 and rs485 in the .net compact framework. I found some commercial links, but is there not a cheaper solution?
Thanks,
Jelle
|
|
|
|
|
|
Can anybody tell me how to hide the taskbar (with windows icon on the left down corner) in the .Net compact Framework?
Please help.
Jelle
|
|
|
|
|
I've never written for Windows CE or using the .NET CF, but I think you might want to check into P/Invoking this[^] API call.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello,
This is a C++ function. How can I access it in C#?
Jelle
|
|
|
|
|
Use P/Invoke (platform invoke). Please see the PInvoke.net wiki[^] for more info.
#include "witty_sig.h"
|
|
|
|
|
Hello,
I am using c#. How can I include this in c#?
Jelle
|
|
|
|
|
One more time... P/Invoke the function call.
See this[^] MSDN document for a little primer on P/Invoke.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello Dave,
I found:
[DllImport("aygshell.dll")]
static extern uint SHFullScreen(???? hwndRequester, ??? dwState);
I do not know how to call this function with what parameters.
I found on msdn: SHFullScreen(HWND hwndRequester, DWORD dwState);
DWORD should match Int32, but HWND? InPtr is a good guess?
Finally, how can I find out what the dwstates are? I found on MSDN SHFS_SHOWTASKBAR, but what is the value of this state?
Please help.
Jelle
|
|
|
|
|
HWND and DWORD will both translate to an Int32 in this case. It really depends on the function your calling.
To get the hWnd of your form, just use Me.Handle. The dwState constants can be found in the Aygshell.h file. Just do a search on your hard drive to find it. The constants will be written in C++ so you'll have to translate them into C# code so you can use them in your project.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I found the constants on my harddrive. However, I cannot get the handle with me.handle. Also this.Handle does not work in .NET compact framework.
Please help.
///SHFS_SHOWTASKBAR 0x0001
///SHFS_HIDETASKBAR 0x0002
///SHFS_SHOWSIPBUTTON 0x0004
///SHFS_HIDESIPBUTTON 0x0008
///SHFS_SHOWSTARTICON 0x0010
///SHFS_HIDESTARTICON 0x0020
|
|
|
|
|
Hi,
I am getting an InvalidOperationException with the message:
"Cannot call Invoke or InvokeAsync on a control until
the windows handle has been created."
This message occurs only at design time (so far) when we build and run the
project no errors related to this occur. Has anyone found the cause of this?
Thanks in Advance
|
|
|
|
|
What is your control doing when it is created that requires the Invoke call?
You really shouldn't be calling Invoke in Design mode...
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Actually, an instance of the control exists even at design-time but you must still make sure the handle exists (IsHandleCreated ) before invoking anything that requires a valid window handle.
Microsoft MVP, Visual C#
My Articles
|
|
|
|