Sign in to follow this  
PumpkinPieman

[.net] comboBox & TreeNode problems [C++]

Recommended Posts

This has been one of the reoccuring problems I've been having, namely when I set the a node in a structure of mine and later gets selected -- it doesn't always select the right value. For example If I open a new file with 2 masks :Default :Mask 1 and 4 frames Frame 0 -> Default Frame 1 -> Mask 1 Frame 2 -> Mask 1 Frame 3 -> Default I'll go through the debugger and it will find and set the right nodes
				frameInfoData->node = NULL;
				for(DWORD k = 0; k < sf.numMasks; k++){
					TreeNode* tnMask = m_mask->Nodes->Item[k];
					if(tnMask->Text->Equals((char*)fi[framesDone].maskName) == true){
						frameInfoData->node = tnMask;
						break;
					}
				}


So frame 0 and 3 will loop once and set their node to the first node in the list. Frame 1 and 2 will loop twice and set their value to the second node in the list. Okay, fine. (I also noticed that the nodes pointers that were set were different, even though there was only two masks.) Now I get to the selection process, so I click on the list which does this
				frameMaskCombo->DataSource = FrameMask->Nodes;
				if(fi->node == NULL || FrameMask->Nodes->Contains(fi->node) == false)
					fi->node = FrameMask->Nodes->Item[0];
				frameMaskCombo->SelectedItem = fi->node;


which sets the current node for that specific frame, but when I load the frames that were just opened. I get completely random output, mostly they all set to the default value (or the highest value in the list) It works otherwise, when I set the value using the combo box
fi->node = __try_cast<TreeNode*>(frameMaskCombo->SelectedItem);


it stays, and when I come back to the frame (clicking on the list) it saves it fine. Same with saving, it saves and loads the output fine.
LSF1ô  ô                                                                                           Default                                         Mask 1                             A   A   A   AAnimation 1                        Animation 2                        Default                           €?  €?  €?  €?  €?  €?    ÿÿÿÿ       Mask 1                            €?  €?  €?  €?  €?  €?  €?ÿÿÿÿ     €?Mask 1                             @   @  €?  €?   @   @   @   ÿ      @Default                            @   @  €?  €?   @   @    ÿÿÿÿ       

(last 4 frames have char[30] values, reading in order (Default, Mask 1, Mask 1, Default) So everything boils down to setting of the nodes in the open method. (First source box). I'm not sure why it acts up, but all I'm guessing it has something to do with Item[k] returning different pointers for the same nodes (Default, Default) (Mask 1, Mask 1) Does anyone see the problem?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this