Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Method to add in the C# program

Status
Not open for further replies.

Adhyapika

Instructor
Sep 20, 2002
51
US
Hello

Request a kind help.

I need to add a method into my demo C# program. This method is missing that I need to add and test.

The method missing is:

HRESULT CloseAllWindows();

Please help me to get the code then I can implement it to the program.
 
Can you please help me to get the code to implement into my program.
Thanks in advance.
 
?

Did you read the post that I wrote you? Are you looking for the WinAPI call or is this some method you are trying to write on your own that closes all of the windows of your application?
 

Sir, thank you for your info.
I am trying to write a method by my own that closes all the windows of my application.
I am looking for a piece of code to implement then test it.
 
You will want to use the Model-View-Controller design pattern. This way, your controller can fire a Close event and your views can react to it accordingly.

If you have forms scattered and in no way associated to eachother, you will have issues and any solution you put in to close these windows will be a hack.
 
One way would be to loop through the Form objects exposed by the Application.OpenForms collection. But since there are likely to be inter-form dependencies, you might need to either brute-force it by looping through the list until there are no more, or by building a tree structure by following all the parent-child relationships, and then doing a post-fix traversal.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top