|
a quick and dirty way:
<br />
using System;<br />
using System.Runtime.InteropServices;<br />
using System.Windows.Forms;<br />
<br />
public class GetFormsCollection {<br />
<br />
private delegate bool WndEnumProc(System.IntPtr hWnd , int lParam);<br />
<br />
[DllImport("user32.dll", CharSet=CharSet.Auto)]<br />
private static extern bool EnumWindows (WndEnumProc lpEnumFunc, int lParam);<br />
<br />
public readonly System.Collections.ArrayList Forms;<br />
<br />
public GetFormsCollection() {<br />
Forms = new System.Collections.ArrayList();<br />
EnumWindows(new WndEnumProc(EnumCallback), 0);<br />
}<br />
<br />
private bool EnumCallback(System.IntPtr hWnd, int lParam) {<br />
<br />
Control hForm = System.Windows.Forms.Control.FromHandle(hWnd);<br />
if (hForm != null) this.Forms.Add(hForm);<br />
return true;<br />
}<br />
<br />
public static void SetVisiblity(bool fVisible) {<br />
<br />
foreach (System.Windows.Forms.Form objForm in new GetFormsCollection().Forms) {<br />
objForm.Visible = fVisible;<br />
}<br />
}<br />
}<br />
Martin
|
|
|
|
|
Thanks a lot, but I got an error:
Unable to cast object of type 'System.Windows.Forms.ToolStripDropDownMenu' to type 'System.Windows.Forms.Form'.
On this line:
foreach (System.Windows.Forms.Form objForm in new GetFormsCollection().Forms)
I'm using .NET 2.0
What wrong?
Thanks.
|
|
|
|
|
oops, I'm using VS 2003 so I can't check that... As I said, it's a quick & dirty way;).
Creating a Forms.Control object from a handle seems to work for some other UI controls (i.e. ToolStripDropDownMenu) that respond to EnumWindows().
However, try to replace the line
Control hForm = System.Windows.Forms.Control.FromHandle(hWnd);
with this one:
System.Windows.Forms.Form hForm = System.Windows.Forms.Control.FromHandle(hWnd) as System.Windows.Forms.Form;
in order to get forms only.
hope that helps
Martin
|
|
|
|
|
Thanks a lot, it worked!
But...
It doesn't hide the print preview dialog of my internal WebBrowser control!
WebBrowser1.ShowPageSetupDialog();
Is there any way to hide that as well?
|
|
|
|
|
ouh... this becomes really complicated. To solve this particular issue, I would suggest to add an eventhandler in your form.
this.VisibleChanged += new EventHandler(Form1_VisibleChanged);
Here you can show/hide the dialog according to the actual form's Visible state.
My solution is a sledgehammer method to get all running form objects - without having any idea of your application logic. Maybe you will run run into similar issues with other forms/controls.
At this point you might consider implementing Stefan's solution and storing your forms references in a central list?
btw: if *all* app's windows (incl. dialogs) were hidden... how to bring them back?
regards
Martin
|
|
|
|
|
Please help me.
Tell me what is the common name of dialog like yahoo (it allow you type and format characters)?
How can I get dialog like that. I need a dialog allow you type and format characters..
I want to add dialog(Richtextbox) to myApplication form. Thx.
ngh
|
|
|
|
|
Thank you all guys. I have found it at http://www.codeproject.com/cs/miscctrl/richtextboxextended.asp
Thank you author a lot...
ngh
|
|
|
|
|
hello,
I have a little question: Does C# 3 gets delivered together with .net framework 3.0 ? Because I installed .net framework 3.0 RC1 and Orcas but I don't get
C# 3 snippets compiled. If it's not in the .net framework 3.0 package can I download the compiler somewhere else, is it already available?
Thank you.
|
|
|
|
|
|
thank you for the clarification.
|
|
|
|
|
VS 2003
C#: Windows Application - OLEDB Connection -->MS Access
Customer Table --> C Dataset
Product Table --> P Dataset
Customer Product Table --> CP Dataset --> Display Datagrid
----------------------------------------
Hi, I have a form that have textfields from Customer Dataset and Product Dataset. How do I update both data into the CP Dataset and display into Datagrid?
|
|
|
|
|
I have a very simple and short application, which is copy/pasted below. Serialization goes perfectly nice. The XML file is being created and it looks correct.
The problem starts when trying to deserialize -> I get an error:
Code:
There is an error in XML document (1, 1).
---------------------------------
This is the programme:
[Serializable]<br />
<br />
publicclassData<br />
<br />
{<br />
<br />
[XmlArrayItem(typeof(string))]<br />
<br />
publicArrayList Pol = newArrayList();<br />
<br />
[XmlArrayItem(typeof(string))]<br />
<br />
publicArrayList Eng = newArrayList();<br />
<br />
[XmlArrayItem(typeof(string))]<br />
<br />
publicArrayList Ger = newArrayList();<br />
<br />
}
<br />
<br />
[Serializable]<br />
<br />
publicclassStoreHouse<br />
<br />
{<br />
<br />
[XmlArrayItem(typeof(Data))]<br />
<br />
publicArrayList DataList = newArrayList();<br />
<br />
}
Serialization part:
Data d = newData();<br />
<br />
d.Eng.Add("1");<br />
<br />
d.Eng.Add("2");<br />
<br />
d.Ger.Add("dadas");<br />
<br />
d.Ger.Add("dsadsadAS");<br />
<br />
d.Pol.Add("dasd");<br />
<br />
d.Pol.Add("etrre");<br />
<br />
d.Pol.Add("trtre");<br />
<br />
sh.DataList.Add(d);<br />
<br />
Data d1 = newData();<br />
<br />
d1.Eng.Add("1321");<br />
<br />
d1.Eng.Add("2ds");<br />
<br />
d1.Ger.Add("ddadadas");<br />
<br />
d1.Ger.Add("dsa123123dsadAS");<br />
<br />
d1.Pol.Add("das31231dasd");<br />
<br />
d1.Pol.Add("et3213rre");<br />
<br />
d1.Pol.Add("t131rtre");<br />
<br />
sh.DataList.Add(d1);<br />
<br />
XmlSerializer s = newXmlSerializer(typeof(StoreHouse));<br />
<br />
s.Serialize(new System.IO.StreamWriter(@"c:\a.xml"), sh);
Deserialization part:
XmlSerializer s = newXmlSerializer(typeof(StoreHouse));<br />
<br />
sh = ((StoreHouse)s.Deserialize(new System.IO.StringReader(@"c:\a.xml")));
What do you think may be wrong?
thank you very much in advance
|
|
|
|
|
GOOGLE: MSDN C# XmlSerializer "error in XML document"
led mike
|
|
|
|
|
I read many MSDN articles regarding serialization issue. I still can`t see mistake. Can you?
|
|
|
|
|
-Yoyosh- wrote: I read many MSDN articles
I don't care how many you read did you read the "one" that I pointed you to? The first one in the search results using my search? Did you read the section titled "Problems Deserializing XML"?
If you did all that why have you not posted the contents of the InnerException so we can help you?
led mike
|
|
|
|
|
I'd like to use an Async. HttpWebRequest for my application (because, i have a long loop and my GUI seem to freeze) but i have to pass a CookieContainer and retrieve it from each request, how can i do? someone can do an example? i can't find anything on the net with Cookies, thank you
|
|
|
|
|
How to get all processes that comunicate via port 80?
thank you for any help
|
|
|
|
|
|
Is it possible to clear the CurrentCell property so that it doesn't point to anything in the grid at all? I've tried CurrentCell = new DataGridCell(-1,-1) as an analog to the SelectedIndex = -1 used in comboboxes, listboxes, and listviews, but CurrentCell is instead assigned to the existing cell 0,0.
|
|
|
|
|
Can you override inherited delegates? If so, how?
I have a control that inherits from GridView (i.e. myGridView). It has a deleglate to handle some custom stuff.
public PBGridView()
{
RowUpdating += new GridViewUpdateEventHandler( PreUpdate );
}
I have another control that inherits from myGridView (i.e. myMultiGridView). I want to have it's own RowUpdating and skip the inherited one. How do I override it or "remove" it from myMultiGridView?? or do I have to edit myGridView to handle where it's getting called from? I would like to take care of it in myMultiGridView (lowest inherited level).
Thanks, Jessica
|
|
|
|
|
lsugirljte wrote: Can you override inherited delegates? If so, how?
They hide that information in the documentation[^]
The OnRowUpdating method also allows derived classes to handle the event without
attaching a delegate. This is the preferred technique for handling the event in a derived class.
led mike
|
|
|
|
|
Thanks for the help but I'm worried about this part.
"Notes to Inheritors When overriding OnRowUpdating in a derived class, be sure to call the base class's OnRowUpdating method so that registered delegates receive the event. "
I don't want to call the base class's OnRowUpdating method because it has code that won't work with my inherited class.
Thanks, Jessica
|
|
|
|
|
You could try using the new keyword and redefine the event in your myMultiGridView class. For example
class GridView
{
public event RowUpdatingDelegate RowUpdating;
}
class MyMultiGridView : GridView
{
public new event RowUpdatingDelegate RowUpdating;
}
Now clients who subscribe to MyMultiGridView's RowUpdating event will not get notified when the base class fires the event, so you get your own RowUpdating event. Unfortunately, this only works if the client uses your class to subscribe to events. For example
GridView g = new GridView();
g.RowUpdating += ...
MyMultiGridView g = new MyMultiGridView();
g.RowUpdating += ...
|
|
|
|
|
I found that this worked fine.
base.RowUpdating -= new GridViewUpdateEventHandler(base.PreUpdate);
Thanks, Jessica
|
|
|
|
|
I'm converting a 1.1 application to 2.0. There is some heavy use of Hashtable as well as two Hashtable = Hashtable.Synch(new HashTable); Is there a Generics equivalent??? I've not been able to find one.
|
|
|
|