Click here to Skip to main content
15,885,985 members
Home / Discussions / C#
   

C#

 
QuestionClosing DialogBox from other application Pin
Papi83dm24-Apr-09 7:47
Papi83dm24-Apr-09 7:47 
QuestionRemoving bytes from an exe file..... is it possible? Pin
Rajdeep.NET is BACK24-Apr-09 6:15
Rajdeep.NET is BACK24-Apr-09 6:15 
AnswerRe: Removing bytes from an exe file..... is it possible? Pin
musefan24-Apr-09 6:36
musefan24-Apr-09 6:36 
GeneralRe: Removing bytes from an exe file..... is it possible? Pin
Rolando CC24-Apr-09 7:40
professionalRolando CC24-Apr-09 7:40 
AnswerRe: Removing bytes from an exe file..... is it possible? Pin
Ben Fair24-Apr-09 8:38
Ben Fair24-Apr-09 8:38 
AnswerRe: Removing bytes from an exe file..... is it possible? Pin
Skymir24-Apr-09 10:16
Skymir24-Apr-09 10:16 
AnswerRe: Removing bytes from an exe file..... is it possible? Pin
OriginalGriff24-Apr-09 23:23
mveOriginalGriff24-Apr-09 23:23 
QuestionWeird Collection Thing [modified] Pin
#realJSOP24-Apr-09 5:55
mve#realJSOP24-Apr-09 5:55 
I have the following collection:

public class PopupWindowItem
{
	public Object WindowObject { get; set; } // wpf window object
	public UDPWindowType WindowType { get; set; } // wpf tabitem object
	public bool AllowMultipleInstances { get; set; }

	public PopupWindowItem(Object window, UDPWindowType windowType, bool allowMultiple)
	{
		this.WindowObject           = window;
		this.WindowType             = windowType;
		this.AllowMultipleInstances = allowMultiple;
	}
}

public class PopupWindowManager : List<PopupWindowItem>
{
	public PopupWindowManager()
	{
		this.Clear();
	}
}


When the user clicks a button to open a window, a new PopupWindowItem is created and populated with the indicated objects. This part woerks fine. Here's the code:

WindowAccountManager accountManager = new WindowAccountManager();
accountManager.Closed += new EventHandler(accountManager_Closed);
m_popupWindowMgr.Add(new PopupWindowItem(accountManager, UDPWindowType.AccountManager, false));
accountManager.Show();


When the application is closed, I traverse the PopupWindowManager collection and close the windows indicated therein. This is where it gets interesting. Here's the code I'm using:

while (m_popupWindowMgr.Count > 0)
{
	switch (m_popupWindowMgr[0].WindowType)
	{
		case UDPWindowType.AccountManager :
			{
				// When you close the Window object inside the PopupWindowItem object, 
				// the PopupWindowItem object is removed from the collection, and the 
				// collection's count is reduced by 1.
				((WindowAccountManager)(m_popupWindowMgr[0].WindowObject)).Close();
			}
			break;
	}
}


When I call close on the window object inside the PopupWindowItem object, the whole PopupWindowObject is removed from the collection. As you might guess this is unexpected behavior. Why is it doing this?


"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001


modified on Friday, April 24, 2009 12:15 PM

AnswerRe: Weird Collection Thing Pin
Gideon Engelberth24-Apr-09 7:21
Gideon Engelberth24-Apr-09 7:21 
GeneralRe: Weird Collection Thing Pin
Rolando CC24-Apr-09 7:43
professionalRolando CC24-Apr-09 7:43 
GeneralRe: Weird Collection Thing Pin
#realJSOP24-Apr-09 8:15
mve#realJSOP24-Apr-09 8:15 
Questionwatch video live stream on pda (broadcast from pc) Pin
b_emsi24-Apr-09 5:50
b_emsi24-Apr-09 5:50 
Questiondatasets over class objects to store data Pin
Tina P24-Apr-09 5:35
Tina P24-Apr-09 5:35 
AnswerRe: datasets over class objects to store data Pin
Yusuf24-Apr-09 5:55
Yusuf24-Apr-09 5:55 
GeneralRe: datasets over class objects to store data Pin
Tina P24-Apr-09 6:14
Tina P24-Apr-09 6:14 
GeneralRe: datasets over class objects to store data Pin
Yusuf24-Apr-09 6:20
Yusuf24-Apr-09 6:20 
QuestionRegular Expressions Pin
jas0n2324-Apr-09 4:54
jas0n2324-Apr-09 4:54 
AnswerRe: Regular Expressions Pin
musefan24-Apr-09 5:28
musefan24-Apr-09 5:28 
AnswerRe: Regular Expressions Pin
Yusuf24-Apr-09 5:56
Yusuf24-Apr-09 5:56 
QuestionMultiple Forms Open --- Toolstrip Pin
nagendra.vk24-Apr-09 4:17
nagendra.vk24-Apr-09 4:17 
AnswerRe: Multiple Forms Open --- Toolstrip Pin
musefan24-Apr-09 4:24
musefan24-Apr-09 4:24 
GeneralRe: Multiple Forms Open --- Toolstrip Pin
nagendra.vk24-Apr-09 4:45
nagendra.vk24-Apr-09 4:45 
GeneralRe: Multiple Forms Open --- Toolstrip Pin
Nagy Vilmos24-Apr-09 4:47
professionalNagy Vilmos24-Apr-09 4:47 
GeneralRe: Multiple Forms Open --- Toolstrip Pin
musefan24-Apr-09 5:06
musefan24-Apr-09 5:06 
AnswerRe: Multiple Forms Open --- Toolstrip Pin
Pete O'Hanlon24-Apr-09 4:50
mvePete O'Hanlon24-Apr-09 4:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.