Welcome to MSDN Blogs Sign in | Join | Help

Watcher of the skies

Channel 9, Astrobiology, Operating Systems, and other unrelated things

Syndication

Windows and .NET: We're making it simpler

Let's create a new Window in Win32:

HWND hwndMain = CreateWindowEx( 
     0, "MainWClass", "Main Window",
     WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
     CW_USEDEFAULT, CW_USEDEFAULT,
     CW_USEDEFAULT, CW_USEDEFAULT, 
     (HWND)NULL, (HMENU)NULL, hInstance, NULL );

ShowWindow( hwndMain, SW_SHOWDEFAULT );

UpdateWindow( hwndMain );


Now let's do the same thing in “.NET“:

Window w = new Window();
w.Text = "Main Window";
w.Show();

Managed code and the .NET Framework is about elegance in simplicity. We are trying to make our future managed Windows APIs hold true to the notion of enabling you to solve complex problems simply. That's the future.

Charles

Published Wednesday, February 04, 2004 7:13 PM by LifeOnTitan

Comments

# re: Windows and .NET: We're making it simpler @ Wednesday, February 04, 2004 9:03 PM

The code does not produce the same result (Window class is different). Of course it looks simpler if you exclude things that are difficult to do. And once you start creating windows that do not use all defaults Win32 is going to start a lot simpler (a single command as opposed to a lot of commands in .Net).

Jerry Pisk

# re: Windows and .NET: We're making it simpler @ Wednesday, February 04, 2004 9:29 PM

You are technically correct of course... CreateWindowEx returns a handle to the created window. The .NET example returns a Window object, which, yes, is not an HWND. The point is that is takes very little code to create a Window in the new Windows API. The pattern is much more elegant.

Note that each of the above code fragments creates and shows a window with default settings. You are going to be surprised how easy we are making Windows programming in Longhorn.

Charles

Charles

# re: Windows and .NET: We're making it simpler @ Thursday, February 05, 2004 8:56 AM

.NET and the WinFX always make things shorter if you want to create a default object. The issue is when you want to tweak the fine settings.

Yes Win32 is much more clumsy and nasty to look at. But it does make it easy to get rid of WS_HSCROLL and WS_VSCROLL. I must say that when creating _real_ applications I end up customizing windows much more often than using the default settings.

Yes it's nasty, but it is powerful. It also didn't help that some (alot) functionality that is available in Win32 isn't accessible from .NET without using Interop.

Michael Malinak

# re: Windows and .NET: We're making it simpler @ Thursday, February 05, 2004 1:59 PM

Michael, one of our goals as we proceed with with the evolution of the .NET Framework is to limit the amount of pInvokes required by you while writing a managed Windows application. Of course, this means that the Framework will take care of interoping with COM internally. We are many years a away from a fully managed operating system. Do you have specific feedback regarding your experience with WinFX and Longhorn? What do you think? Do you like what we are doing in Longhorn? I'd love to get your feedback on our new Windows technologies as presented in the PDC build of Longhorn.

Charles

Charles

# Windows and .NET: We're making it simpler @ Wednesday, November 28, 2007 12:54 AM

PingBack from http://feeds.maxblog.eu/item_505685.html

Windows and .NET: We're making it simpler

Anonymous comments are disabled
Page view tracker