Jump to content
Xtreme .Net Talk

snarfblam

Leaders
  • Posts

    2156
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by snarfblam

  1. Generally, an application closes when the form on which the message loop is being run is closed. VB.Net has introduced a few features in version 8 to make it behave more like VB6, including the "Application Framework." Like VB6, this allows the message loop to be run outside the UI windows so that no one particular window must stay open for the program to continue to run. This feature is specific to VB. One possibility is to inherit the ApplicationContext class and pass an instance of your custom ApplicationContext to the Application.Run method. Here is an example, but I've never done this before, and I'm not sure that it is 100% kosher. It appears to work, but I'm not sure if the way I've done it can cause threading issues. public class MC: ApplicationContext{ frmMain MainFrm = new frmMain(); frmAbout AboutFrm = new frmAbout(); public MC() { MainFrm.Closed += OnFormClosed; AboutFrm.Closed += OnFormClosed; MainFrm.Show(); AboutFrm.Show(); } void OnFormClosed(object sender, EventArgs e) { // The form that triggers the event will not be disposed yet, so we check each // form to see if it is either closed (IsDisposed) or is closing (== sender) if((MainFrm.IsDisposed || MainFrm == sender) && (AboutFrm.IsDisposed || AboutFrm == sender)) { // The last form must be disposed before we can end the application if(!((Form)sender).IsDisposed) { ((Form)sender).Dispose(); } this.ExitThreadCore(); } } }
  2. Also, if you consumer the keypress for the enter key (the control reacts to it), make sure that you set e.Handled to true to avoid giving the user an error beep.
  3. The double data type also supports TryParse in .Net 1.x. The difference is that in 1.x, double is the only data type that supports TryParse, whereas in .Net 2.0, most native types support it.
  4. I am not sure, but ILMerge may be able to convert the version of a DLL or EXE. Just don't quote me on that. Search microsoft.com for ILMerge.
  5. Using the hypothetical Collection and CollectedObject classes, why not just add a field/property to store the parent Collection of the CollectedObject (for example CollectedObject.Parent). On the Collection.Add and Collection.Remove methods, update CollectedObject.Parent.
  6. You are probably right, Cags. A while back I started a movie maker project. The graphics engine implementation I was currently using was GDI+ based, rather than GDI or DirectX, and at resolutions of 640x480 I was able to get 60 fps. Of course, it also depends on the computer.
  7. The problem is that you dispose of the bitmap... System.Drawing.Bitmap final = bm; bm.Dispose(); then you try to display it... graphMostPlayed.Image = final; Although you are Disposing() one variable and assigning a different variable to the PictureBox, they both reference the same object.
  8. System.Drawing.Bitmap is a System.Drawing.Image. Bitmap and Metafile both inherit from the Image property. Anything that asks for an Image will accept a Bitmap or Metafile. Perhaps you should post the code where this exception is being thrown.
  9. First of all, instead of using + or & to join files, use System.IO.Path.Join. The Join function ensures that there is no confusion with doubled or missing path separators. // (using System.IO) Path.Join("C:\\Windows", "Microsoft.Net"); Path.Join("C:\\Windows\\", "Microsoft.Net"); Path.Join("C:\\Windows\\", "\\Microsoft.Net"); Path.Join("C:\\Windows", "\\Microsoft.Net"); // all four return "C:\\Windows\\Microsoft.Net" Also, you will need to create and release the BackBuffers hDC each time you render. This is because of the way that a GDI+ hDC works. When you call GetHDC, it makes a buffer full of 100% transparent pixels and returns the hDC to which you can render your graphics, and when you release it, it drawns the buffer over the original image, hence you won't see your graphics until you release the DC.
  10. The random class uses the time as a seed. You are probably creating the random objects so quickly that the computer clock does not advance throughout the process, meaning that you get the same seed every time. What you most likely will want to do is create one random object and re-use it so that this will never be a problem. static Random randomclr = new Random(); public static Color GetRandomColor() { return Color.FromArgb(randomclr.Next(256), randomclr.Next(256), randomclr.Next(256)); }
  11. I don't understand how that helps. Are you trying to save the image? Or show it in a PictureBox? To put it in a picture box, you don't need to save it. Just Do something like this: SomePictureBox.Image = SomePieChartObject.Final;
  12. For an object to be enumerable (meaning you can use for each), you need to create an enumerator class that implements IEnumerator, and the enumerable class needs to implement the IEnumerable interface to return the enumerator. That probably sounds like a headache, but I believe that the CollectionBase has already implemented the IEnumerable interface. Have you tried using your Tags class in a For Each loop?
  13. Are you drawing the chart? Or are you using a third party library? Is the output in the form of an in-memory bitmap? A .bmp file?
  14. Do you want to see if they are the same object? If so, use Object.ReferenceEquals, or cast the objects to the Object type and use the == (or = in VB) operator. If you want to see if they have the same value, create your own Equals function or overload the Equals operator.
  15. GDI tends to execute a little faster than GDI+. GDI+ 2.0 is faster than 1.x, but still not as fast as GDI. I'm not sure if this applies to TransparentBlt, since this is actuall not part of GDI32.dll. Also, Maloric, will the image be the same every time? Are you re-using the ImageType objects? If so, perhaps it would be best to move the Bitmap object into the ImageType object so that you may load it once when you create the ImageType, instead of re-loading it each time the image is drawn in the Draw sub.
  16. Also, unless I'm missing something, the arrays are declared, but never created, yet you are accessing elements of the array. In other words: int[] MyArray = new int[10]; // The new statement creates an array MyArray[1] = SomeValue; // Versus int[] MyArray; //or int[] MyArray = null; MyArray[1] = SomeValue; // Raises a null reference exception because we // havent created an array.
  17. There are memory leak issues associated with TransparentBlt, although whether or not these are specific to certain versions of Windows, I'm not sure. It also looks like you will be creating a lot of Bitmap objects that could be recycled which make extra work for the GC as well as extra CPU for disposal.
  18. VS can do it, but it does it through the runtime environment, which your code can't directly manipulate. The Exception class has a private variable named _stackTrace which contains raw binary data, but I couldn't decipher it or find any info about it. From the look of things, this probably isn't a very simple task, to say the least.
  19. With lengthy equations, the round-off errors are bound to build up and multiply, which is understandably a big issue with very precise math. I do know that doubles have increased in precision (either in storage, computation, or both, not sure) between .Net 1.x and 2.0. I'm not sure if the .Net and Win32 implementation of doubles are the same, but on the off chance that Win32 doubles are more precise, even if you interop with Double data types, somewhere in the marshalling you are sure to lose the extra precision. You might want to try searching for a 128-bit or arbitrary precision math library, but the big issue is, again, marshalling (unless, perhaps, that library has built in support for parsing values and converting them into strings).
  20. The funny thing is how big a deal the two of us made out of something that'll most likely never be a big deal.
  21. I have had this problem before. There is a bug (I don't know if it is documented) that sometimes causes the sizable description area at the bottom of the properties window to become too short to be seen, and although a sizing cursor appears when you move the mouse over the separator, when you click, the sizing cursor disappears and you can't resize it. I don't know a way to fix this, except that it seemed to fix itself after a while each time it happened to me.
  22. As far as trigonometric functions, in the .Net framework, you are stuck with double precision. I couldn't find any Decimal mathematics libraries on the net. Sorry, I wish I could tell what you could use instead of what you can't.
  23. In VB7, there was no operator overloading. = Did not call the Equals method, even when overridden, yet you could use = on strings to test for equal value. In VB7, = is translated internally as a VB string comparison function (which happens to use String.Equals), hence, my irregular behavior for a "Magic" type. In .Net 2, the string class actually has operator overloads. Perhaps on a simple class which more represents a value than an object (for instance, a string), operator overloads may be appropriate, provided that the people using the code are aware. I'm just worried about the guy who downloads sample code or a .dll to use, misses the line where you mention that == is overridden, and pulls his hair out trying to figure out why his program is broken. I just code with the convention that overloading == is bad. But, hey, what it always come down to is do what works for you.
  24. You could also create a Char array. The string class has a ToChars function which returns the string in the form of a Char array, and a char array can be cast to a string (at least in VB). A Char array will have less overhead, but the StringBuilder is probably easier.
  25. Is FAXCOMLib a .Net library? ActiveX? How do you render the data to the fax? Do you have drawing functions? Do you pass an image? Depending on these details, the exact method differs. For instance, I doubt that an ActiveX dll can deal with a System.Drawing.Bitmap, while it might be able to deal with a Windows device context or bitmap (assuming that .Net has no special marshalling for these, which I believe to be the case).
×
×
  • Create New...