Wednesday, January 11, 2006

If you're in the mood for a little nerd humor, these links should help you out (via Don Box's Spoulet):

Wednesday, January 11, 2006 4:06:29 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [2]  | 
 Monday, January 09, 2006

I've been wondering why VS 2005 uses it's *.vshost.exe binary to debug projects... I've seen several problems that it has caused posted in the newsgroups, but I assumed that there were actually benefits that came from it.  Today I came across a blog post outlining those reasons:
http://blogs.msdn.com/dtemp/archive/2004/09/09/215764.aspx

Here's the summary of reasons from the above post:

  • Improved performance
  • Partial trust debugging
  • Design time expression evaluation (using the "immediate window")
Monday, January 09, 2006 6:37:35 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  | 
 Friday, January 06, 2006
Sometimes, it is useful to be able to track windows events even when your application doesn't have focus. In order to accomplish this, you can use the function SetWindowsHookEx. Below is an example of using this API in .NET and then wrapping the events with managed mouse and keyboard events. The code is not production strength, but hopefully, it will give you a good start. Let me know if you have suggestions for improvements, and I'll update the post.
Friday, January 06, 2006 7:48:39 PM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [13]  | 
 Thursday, January 05, 2006

I always assumed that when the documentation for the JavaScript window.open said that the "height" argument "Specifies the height of the window, in pixels" that it meant the height of entire parent window (the one with the "X" in the upper-right corner) not the client-size of the browser control window!  The same is true of the "width" argument. (at least we're consistent!) 

So, if you're worried about the positioning and sizing of a popup window be sure to account for the size of your status bar, toolbar, and outer border of your window.  They all 3 affect how window.open is (or should be) handled.

Friday, January 06, 2006 1:18:21 AM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  | 
 Wednesday, January 04, 2006

I've been wondering for a while if the System.Drawing.Rectangle structure could be used for PInvoke in place of the Win32 RECT structure, so I thought I would write a little application to verify my guess (overkill, I know... but fun none the less.)  The output: 1,2,3,4 and 1,2,2,2.  If they were compatible they would have been the same, therefore you cannot use the Rectangle structure interchangeably with the RECT structure for PInvoke.

using System;

using System.Drawing;

using System.Runtime.InteropServices;

 

namespace RECTvsRectangle

{

    [StructLayout(LayoutKind.Sequential)]

    public struct RECT

    {

        public int Left;

        public int Top;

        public int Right;

        public int Bottom;

    }

 

    static class Program

    {

 

        static void Main()

        {

            int intSize = Marshal.SizeOf(typeof(int));

            int rectangleSize = Marshal.SizeOf(typeof(Rectangle));

            int rectSize = Marshal.SizeOf(typeof(RECT));

 

            RECT r1;

            r1.Left = 1;

            r1.Top = 2;

            r1.Right = 3; //width = 2

            r1.Bottom = 4; //height = 2

 

            Rectangle r2 = Rectangle.Empty;

            r2.X = 1;

            r2.Y = 2;

            r2.Width = 2;

            r2.Height = 2;

 

            IntPtr p1 = Marshal.AllocCoTaskMem(rectSize);

            Marshal.StructureToPtr(r1, p1, true);

 

            IntPtr p2 = Marshal.AllocCoTaskMem(rectangleSize);

            Marshal.StructureToPtr(r2, p2, true);

 

            for (int i = 0; i < rectSize; i += intSize)

            {

                Console.WriteLine("Value: " + Marshal.ReadInt32(p1, i).ToString());

            }

 

            Console.WriteLine("---");

 

            for (int i = 0; i < rectangleSize; i += intSize)

            {

                Console.WriteLine("Value: " + Marshal.ReadInt32(p2, i).ToString());

            }

 

            Marshal.FreeCoTaskMem(p1);

            Marshal.FreeCoTaskMem(p2);

        }

    }

}

Thursday, January 05, 2006 2:38:43 AM (Central Standard Time, UTC-06:00)  #    Disclaimer  |  Comments [0]  |