snarfblam
Leaders-
Posts
2156 -
Joined
-
Last visited
-
Days Won
2
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by snarfblam
-
I have recently seen some very fascinating games written in QBasic, including games with impressive (for QBasic) vector-based graphics and even games with graphics comparable to those of Wolfenstein 3D (what mechanism used to achieve these graphics and whether such mechanism is QB based, I know not). As soon as I discovered QBasic in my oldmsdos folder on my Win95 CD (this was back in the day), I began to play with it non-stop, learning everything I knew from my existing Applesoft BASIC knowledge and the QB help files. When VB became available to me (it was installed on the computers at school for programming classes) I moved on to "bigger and better" things, becoming a self-taught VB programmer with a keyboard and an Object Browser in hand and QB in my past. Unfortunately, I was never part of the QB programming community. When I discovered QB it was at that point where it was obsolete and before it became a novelty, and now I have .Net as a full-time hobby.
-
How do you manage a buffer overrun in a managed environment?
-
Does this mean that the anonymous method is re-JITted each time it is used?
-
The code snippet you provided uses a feature new to C# 2.0 called anonymous methods. This is basically a nameless method that can be declared within another method. I hilighted the anonymous method below. private void Log( string msg) { rtfTerminal.Invoke(new EventHandler([b][color=red]delegate { rtfTerminal.AppendText(msg); }[/color][/b])); } I am not to keen on the syntax for anonymous methods, but it seems to me that the anonymous method should have been declared with the appropriate signature for an EventHandler, and I don't quite understand how msg is passed to the anonymous method. If we can get past my confusion, the above code listing would be the same (in terms of behavior) as: private void Log( string msg) { rtfTerminal.Invoke(new EventHandler(anotherFunction)); } //anotherFunction calls rtfTerminal.AppendText Once we are at this point, the translation is pretty easy. Private Sub Log(msg As String) rtfTerminal.Invoke(AddressOf anotherFunction) End Sub 'anotherFunction calls rtfTerminal.AppendText In other words, to modify UI elements from another thread, you simply need to call the control's Invoke() method, passing a delegate to the function that will modify the control, and if there are any parameters, there is an overload that allows you to pass them in an array. Maybe someone more C# savvy could clear up my confusion about the anonymous methods, but I hope I helped.
-
Just a quick side note: I recommend using (Year) Mod 100 instead of (Year) - 2000 to get the last two digits of a year... otherwise, 1998 - 2000 will return a year of -2 instead of 98. I guess this would be Nerseus' "smarter" function.
-
Hmm... maybe I do have programmer's OCD. Either way... thanks Diesel, IngisKahn, and Wraith for the info. I'm having quite the difficult time finding much info on MSIL using google as a starting point. Didn't even know that there was info in my SDK. Who would have thought??
-
I would assume that you have the project developed completely before you try to distribute it. Have you tried to create a "Setup Project" yet? (It creates a new project to generate an MSI and Setup.exe for another already existing project).
-
There is a directory tree view control available for free (make sure you read the license, I don't know the details) on MSDN as part of the VBPowerPack. Do a search for VBPowerPack and you will be sure to find it.
-
Can't you use the ListView.SelectedIndecies property on the ListView.SelectedIndexChanged event?
-
Just a note: If, for example, you are trying to perform an action that requires a certain file to exist, you should check first to see is the file exists. You should generally try to avoid causing exceptions as much as possible. Try to use them to handle errors you don't see coming or can not prevent, not as a method to control program flow, because they are designed and intended to be used for "exceptional circumstances," which should be few and far between. If your program is set up only to use exceptions as intended, then chances are that when they occur, the most useful information that you will be able to give a user is that an error occured, or maybe something like "A file access error has occured," because you will be preventing predictable exceptions and the exceptions caught will most likely do little to explain why exactly an operation failed, but instead offer you a chance to recover.
-
Alternatively, you could have a cascading if/elseif/elseif checking the type of the exception, since, from the sounds of things, your exception handling behavior will not vary depending on the exception type. //using the is operator try { //Your code here } catch (System.Exception ex) { if (ex is FileNotFoundException) MessageBox.Show("You must save your files before you can continue."); else if (ex is SecurityException) MessageBox.Show("You lack sufficient permissions to perform the specified action."); else MessageBox.Show("An unexpected error occured. (Don't you hate it when you get a message like this?"); } Excuse me if my C# is less than perfect, I don't really program C#.
-
Create a new deployment project. Click File>New>Project. In the new project window, select the "Setup and Deplotment Projects" folder and click "Setup Project" on the right. The rest is self explanitory. For more information, open up MSDN, and search the index for "Setup", or go to msdn.microsoft.com and search for "Setup."
-
Is there any possibility that you can render your image onto the DirectDraw.Surface rather than the System.Drawing.Bitmap and save yourself a step? (DirectX has functions to draw on a surface, though not as many as GDI+).
-
Do you have a specific question about such a program?
-
Here it is, everyone! Functions to get characters without using either Microsoft.VisualBasic or System.Convert. As a matter of fact, it depends on no other classes than itself (and two attributes). <System.Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Explicit)> _ Public Structure MyChrW <System.Runtime.InteropServices.FieldOffset(0)> _ Private [Char] As Char <System.Runtime.InteropServices.FieldOffset(0)> _ Private [short] As Short <System.Runtime.InteropServices.FieldOffset(0)> _ Private [uShort] As UInt16 Private Shared Inst As MyChrW Public Shared Function FromShort(ByVal [short] As Short) As Char Inst.Short = [short] Return Inst.Char End Function Public Shared Function FromUShort(ByVal [uShort] As UInt16) As Char Inst.UShort = [uShort] Return Inst.Char End Function Public Shared Function ToShort(ByVal [Char] As Char) As Short Inst.Char = [Char] Return Inst.Short End Function Public Shared Function ToUShort(ByVal [Char] As Char) As UInt16 Inst.Char = [Char] Return Inst.UShort End Function End Structure This nifty structure allows you to convert characters to their Unicode value (signed or unsigned) and vice versa. This is done by storing a Char, a Short, and a UInt16 in the same location in memory. When a conversion is made, the value is stored as the type to be converted from and then retrieved from the same memory as the type to be converted to. It is type safe and fast, and best of all, tfowler, no more need to worry about the Microsoft.VisualBasic namespace. As a matter of fact, using a similar structure, you can access different ranges of bytes as different types. I've done this to convert various types to bytes (such as the System.Drawing.Color structure). As another example, I've also used this with the Windows API when two Int16s were passed as a single Int32.
-
Search google or this forum for example of owner drawn listviews/combos. You have to implement the drawing code yourself, but it isn't very difficult once you understand the mechanics. I believe (not sure, it has been a while) that it is done by inheriting the ListView, setting the ListView's OwnerDrawn property to True, and overriding certain protected functions.
-
Here is your complete, comprehensive instruction manual/tutorial on the object browser. (1)Browsing In the tree on the left, expand a library, expand namespaces within that library, and finally, select a class/structure. In the list on the right the members of the class will be listed. Click a member to see detailed information about it on the bottom. (2)Searching Click the search icon, select the search options you would like, enter the name of the class or class member you want to find. Click search. Results are displayed in a new window. Click a result to view it in the object browser. (3)From the code editor When you click "View Definition" in the code editor, if source is not available for the object you selected, the object will be shown in the code editor. If there is still any confusion, then here: Google gave me this.
-
A very common transparency key is Magenta (R=255, G=0, B=255). This is not a particularly unusual color, but it is ugly and useless so it is used very often as a trasnparency key and it is the color of my preference. But any color will do as long as you can ensure that only the areas to be rendered as transparent will be this color. If you are allowing a user to load custom images into a picturebox it is hard to guaruntee that your transparent color won't be loaded and displayed incorrectly. In this case you might want to investigate other methods of non-rectangular controls. You can do this without going through the Windows API. Try creating a System.Drawing.Region and setting it to the System.Windows.Forms.Form.Region property.
-
You can use String.IndexOf to get the character index of the equals sign and String.Substring to get a portion of the string. If you are using VS or #Develop, type in "String." and a list of all sorts of nifty functions and properties comes up.
-
It looks the same to me. Perhaps only the forum skin that you are using has been changed.
-
I'm sorry, are you looking to change the path that the deployment project outputs to or are you looking to get a folder name as a string within your program?
-
As far as why there is no magic Print or Line command (with mysterious specialized syntax), it is because .Net is fully object oriented and consistent. Default instances and output functions that do not even belong to any particular class simply do not make sense in .Net. It might be an bit less convenient, but I think that it is worth losing the somewhat archaic Line method to get a language that can work in the common language system and therefore offer the advantages of the .Net libraries, garbage collection, etc.
-
Also, different libraries can define classes in the same dlls. You can reference System.Windows.Forms.dll but there still may be classes in System.Windows.Forms that you cannot access because they are defined in System.Design.Dll (not sure that that is true, but it is just an example).
-
I should apologize. I kinda... missed the title of the thread and I thought that you were simply asking about embedded images. Sorry for the not very useful answer.