Jump to content
Xtreme .Net Talk

divil

*Gurus*
  • Posts

    3026
  • Joined

  • Last visited

Everything posted by divil

  1. Ok, I'll bite. Jabe, your code is not demonstrating how objects are passed per se, it's merely demonstrating out parameters. You can change the original class passed in in the latter procedure because you're passing byref, but either way you're creating a new instance so it doesn't prove much. Take the code below, which is a cut down version of your. No matter whether the instance is passed byval or byref, it's a class so you're only passing a reference and the number will always be changed. Public Class Tester Public Shared Sub Main() Dim t As New Tester, referenceType As New MyRefType referenceType.RefTypeProp = 1 MessageBox.Show("Starting Value: " & referenceType.RefTypeProp.ToString()) t.PassByVal(referenceType) MessageBox.Show("After being passed by value: " & referenceType.RefTypeProp.ToString()) t.PassByRef(referenceType) MessageBox.Show("After being passed by reference: " & referenceType.RefTypeProp.ToString()) MessageBox.Show("It's always being changed because you're only passing a reference of the same object, NOT a copy of the object. Q.E.D.") End Sub Public Sub PassByVal(ByVal refType As MyRefType) refType.RefTypeProp = 1000 End Sub Public Sub PassByRef(ByRef reftype As MyRefType) reftype.RefTypeProp = 9999 End Sub End Class Public Class MyRefType Private m_intRefTypeProp As Integer Public Property RefTypeProp() As Integer Get Return m_intRefTypeProp End Get Set(ByVal Value As Integer) m_intRefTypeProp = Value End Set End Property End Class
  2. Here's the correct way of doing it, making sure everything used is cleaned up properly. public static void DrawBitBlt(Graphics g, Bitmap bmp, ref Rectangle destRec) { // Get DC handle and create a compatible one IntPtr hDC= g.GetHdc(); IntPtr offscreenDC= a.Api.CreateCompatibleDC(hDC); // Select our bitmap in to DC, recording what was there before IntPtr hBitmap = bmp.GetHbitmap(); IntPtr oldObject = a.Api.SelectObject(offscreenDC, hBitmap); // Perform blt if(bmp.Size.Equals(destRec.Size)) a.Api.BitBlt(hDC, destRec.X, destRec.Y, destRec.Width, destRec.Height, offscreenDC, 0, 0, SrcCopy); else a.Api.StretchBlt(hDC, destRec.X, destRec.Y, destRec.Width, destRec.Height, offscreenDC, 0, 0, bmp.Width, bmp.Height, SrcCopy); // Select our bitmap object back out of the DC a.Api.SelectObject(offscreenDC, oldObject); // Delete our bitmap a.Api.DeleteObject(hBitmap); // Delete memory DC and release our DC handle a.Api.DeleteDC(offscreenDC); g.ReleaseHdc(hDC); }
  3. If you want the TableStyles property it sounds like you want the Windows Forms datagrid rather than the Web Forms datagrid you're trying to use at the moment.
  4. Yes, but that member will still just point to the same object.
  5. I think you have to override the control's IsInputKey function to determine whether the keys should be treated like normal keys. Theit default behaviour is to tab through groups of options on the form so they're not processed in the normal way.
  6. 640k of RAM!? :P Seriously, for me vs.net 2003 outperforms 2002 so I don't know what's wrong there.
  7. The reason .NET programs are generally slower than their C++ counterparts is not because of slow executing code, but because a lot of .NET is still a wrapper to win32 functions. This won't always be the case though.
  8. .NET code can beat C++ code when it comes to raw number crunching because of JIT optimizations performed on the code for the specific processor the code is running on. To satisfy my conscience for saying this, I just created two tests - one with C++ and one with C#. In the test I run a loop 2 billion times, each iteration increasing another integer's value by one. I turn off optimizations (which would stop such a pointless loop from running at all) and these are the results: C++: 10.405 seconds C#: 10.044 seconds And they say JIT compiled code is slow.
  9. Are you using the setup and deployment project in Visual Studio? If so, you can highlight your project in the solution explorer and click the Custom Actions editor button at the top of the treeview to open the editor where you can specify executables to be run at various install stages.
  10. There is a known issue in Windows Forms; if you are adding and removing controls dynamically at runtime, and you remove one which contains the focus, your close button will cease to work. I'm betting that if you force the focus to some control that's always there just before you remove any controls, your close button problem will go away.
  11. Everything except the primitive data types and structures is passed by reference whether you like it or not. Primitive data types and structures are passed by value unless you specify otherwise (ByRef in vb, ref in C#).
  12. Borland released C# Builder a couple of days ago.
  13. You'll want to use one of the Bitmap constructors. There is one that accepts the dimensions of the image, the stride, pixel format and the address of the bitmap data.
  14. Calm down marble_eater, we're all friends here.
  15. Are you adding and removing controls dynamically at runtime?
  16. http://www.xtremedotnettalk.com/showthread.php?s=&threadid=73510
  17. GDI+ uses grid fitting to draw text at sub-pixel accuracy, I wouldn't want to compare results from GDI+ and non GDI+ functions.
  18. If you're not drawing the text using GDI+, I'm not at all surprised you get different results.
  19. Are you actually using the same Font object to draw with as you are to measure with?
  20. I think forms automatically increase in size when the system is set to display large fonts (i.e., the DPI is higher).
  21. For small projects it's common to just place everything in one namespace, the name of the company or even the name of the product.
  22. Like I said, there aren't anywhere near enough questions to warrant setting aside a separate forum here.
  23. I would certainly call *my* code art :P
×
×
  • Create New...