snarfblam
Leaders-
Posts
2156 -
Joined
-
Last visited
-
Days Won
2
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by snarfblam
-
-
Sounds like you could get the same functionality out of a docked panel
-
The inner working of the structures is a little more complicated than that of a normal struct. The properties do not directly modify private members of the struct, but rather an array which the struct references, as a means of exposing raw binary data in an object oriented structure. (This means that if I re-retrieve another struct using the same Level.StartPoint property, the change will be reflected, just as you would normally expect with a class.) Anyways... Level.StartPoint is an l-value (it can be a _set). But when I use Level.Startpoint.X, Level.StartPoint becomes an r-value (in this case it can only be a _get). I understand that much, and I understand that normally it does not make sense to modify a property on a normal struct with syntax like I used above; the changes would be made the the struct returned, and then discarded because the struct does not get stored anywhere. Regardless, I don't understand exactly why a property of an r-value struct can not be an l-value. It is quite possible for this property assignment to have an effect on objects other than the struct. It's just a small annoyance. Not a big deal, and I suppose that I should expect syntactical oddities like this when I am using structs in the manner that I am, but it doesn't seem too unreasonable (to me) to anticipate that a struct's property could act on a gc object. P.S. I suppose that the technical reason is that since you do not have the struct's data stored, it can't be passed to the member function or property you are calling; it exists only on the stack.
-
The following line of code is giving me a compiler error: _Level.StartPoint.X = 15 (Expression if a value and therefor can not be the target of an assignment.) _Level is a struct. StartPoint is a readonly property which returns a struct. X is a read/write property which is an integer. Why would this cause an error instead of assigning the value of 15 to the property .X? Note that the folloing code does work: Dim Start As Rom.MapCoord = _Level.StartPoint Start.X = 15
-
The control would need to be hidden not only when the user clicks on the form, but when he clicks on any other control, even those that can't accept focus, as well as when the user clicks anywhere outside the form. I wanted my control to act very much like a context menu, in that when you click a button, it is displayed, allows him to make a selection (from a grid, thought, rather than a list of menuitems), then the control would disappear. And, like a menu, if the user clicks anywhere else on the screen, I want to hide the control and get it out of his way. What I did is show a context menu with a single, owner drawn item. I do my drawing to the menuitem instead of a control, and when the user clicks, I take the mouse coordinates, and calculate where in the menu the user clicked. This method, however, gives me less control with respect to mouse events, and is less reliable.
-
I've used some sort of tab control in VB6 (don't know if it was SSTAB). I remember having to use pictureboxes (because VB6 lacked panels) to contain my tab pages, and when the user changed tabs I showed and hid the appropriate pictureboxes. This should also be doable with the SSTAB in VB.NET.
-
Well... that's what I tried. The problem is that my form is full of pictureboxes, which react to mouse events, but don't take focus.
-
I have a control that I want to be hidden when the user clicks outside of it. How can I detect such a mouse click?
-
PWNettle, you make it sound like I'm calling RegEx the devil (or making a personal attack on you).
-
I wouldn't jump into RegEx. RegEx is certainly useful, but sometimes it is overkill. It might even produce less code, but the runtime cost can be much much greater. If you have a whole lot of strings, you should probably use RegEx, but it doesn't sound like you have that many strings. If you have a single or only a few strings, I would recommend doing something like the follwing: Public Structure SplitString Text As String Number As Integer 'Make this a double / long if you need to End Structure Public Function SplitMyString(Text As String) As SplitString Dim Result As SplitString Dim FirstNumericChar As Integer Dim Chars() As Char = Text.ToCharArray() ' Do While Chars(FirstNumericChar -1).IsNumeric And FirstNumericChar > 0 FirstNumericChar -= 1 Loop Result.Number = Integer.Parse(Text.SubString(FirstNumericChar)) Result.Text = Text.SubString(0, FirstNumericChar - 1) Return Result End Function I haven't tested it, but you get the idea.
-
If the text is not formatted then you can use the Graphics.MeasureString to find the size of the text. If it is formatted, I think that there is some kind of API that can measure it, but I'm not sure.
-
CFileDialog? Are you using Windows Forms or MFC?
-
I'm designing an object model where nested classes are very appropriate. The nested classes should only ever be used in conjuntion with the class in which it is nested in, just like the ListView class, which nests ListViewItems, ListViewItemCollection, CheckedIndexCollection, CheckedListViewItemCollection, ColumnHeaderCollection, SelectedIndexCollection, and SelectedListViewItemCollection. I think it might give me more of a headache to have so many classes all in the same namespace. Imagine if Windows Forms did not use nested classes. Using nested classes is far from cumbersome, but I can't say the same for their implementation in VB.
-
Class definitions are collapsable anyways. The problem is that I am editing all of the classes at the same time because they all relate so closeley to eachother, so I can't collapse them. If I could click a tab to open a different .vb file it wouldn't be so confusing, but as it is now, I have many functions between the different classes with similar names and the massive amount of functions is hurting my head.
-
Certainly true, however, that isn't much of an option for me seeing as I am very rusty on what little (unmanaged) C++ I know. And I'm betting that the answer to my question is "no," but I am hoping that I'm wrong because my code is starting to give me a headache.
-
No, that is not a nested class. That's simply class instantiated within another class. Class A Public Member As Integer ' Private Class B Public Member As Integer End Class End Class In such a case, class B can only be instantiated by class A. Were class B declared publicly, anyone could instantiate class B, but would have to use the syntax [New A.B] as opposed to [New B]. I need to use nested classes to provide private classes and organize object models. But when my classes get large and complex, nested classes cause clutter.
-
Is there a way to declare a nested class without actually putting it within the declaration of the outer class in your code? This is leading to really cluttered code for me.
-
This is when intellisense, the object browser, or MSDN could come in handy. YourListItem.BackColor = Color.Red 'OR YourListItem.ForeColor = Color.Red
-
-
That is something I should have pointed out. Suppose you want to present the user (or recieving function) a filtered list, where they can simply select certain items. Or If you wanted to use the collection in a read-only manner. There is no disadvantage to having a shallow copy here. There can even be an advantage to having shallow copies of collections. Suppose you want to present a filtered collection, allow the recipient to modifty the filterd collection, and have those changes reflected back in the original collection. Easiest done with a shallow copy of the collection. I have done this with listviews in the past: create a shallow copy, filter the list by removing items, and when the user wants to remove the filter, clear the list and add the copied list back. That way, when the filter is removed, since the copy of the list was shallow, any changes they made wont be undone. And of course there are the things you need to watch out for. You can not add a listview item to more than one listview at a time, so you would need to create a deep copy in such a case (same applies to many windows forms collections). And if you don't want the original collection to be modified, you would need to create a deep copy.
-
I have already. Several times. Release and debug as well as the original setup downloaded from microsoft.
-
This is my recommendation: Create an array (of whatever type of object the collection holds) and use the collections CopyTo method to create a copy of the collection in an array. When you need to restore the collection, call the collections Clear method, the call the collections AddRange method, passing your array. When you pass any reference type (i.e. any class) as a parameter, you are passing a pointer: a memory address. When you pass it ByVal you are passing a copy of the pointer. When you pass it ByRef, you are passing the actual reference. Either way, the function being called gets the address of the object and can modify it. The only difference is if you pass the object as ByRef, since you are passing the actual reference the funtion being called can change what the original reference points to. My point is, you need to create a copy of a class (or copy of the data it represents) if you want to pass it to a function.
-
I'm downloading the newest update right now, but I've already installed the SDK, and it is not listed when I try to add references. I opened an existing DirectX projects and it couldn't load the references either.
-
Well... I do. And although appearently it isn't getting much use now, If I remember correctly, when I started programming VB I got quite a bit of use in the VB Syntax Specific forum. I'm not saying that it most certainly should be removed, but not without a second thought.