metty's blog

Developers? Developers!

July 2004 - Posts

German Version of VS.NET 2003 / .NET Framework 1.1 Documentation is Online

If you're after the German German language docs for Visual Studio 2003 and the respective Microsoft .NET Framework version 1.1, they're now online at

http://msdn.microsoft.com/library/deu/

German language documentation topics also include Visual SourceSafe 6.0, Microsoft Office XP Developer, Visual FoxPro and Technical Articles.

PrintForm replacement for Visual Basic .NET

In a recent one of my regular articles for MSDN Germany, I came up with a PrintForm replacement (remember Visual Basic .NET, or rather Windows Forms, does not offer this method and it was very, very limited in Visual Basic anyway - barely usable, to be honest).

Although it's not a big deal after all, I've polished that code up a bit to include an option to either print only the client area of a form (as VB's PrintForm does) or the entire form (including its title bar and its borders). The latter works nicely only for regularly shaped forms - anyway, I thought I'd share it with you.

I tried to keep this one nice and easy. If you'd like to improve it a bit, you might want to add the PrintDocument object via code instead of adding it as a control. And of course, you could make it more general by passing the form as a parameter instead of needing to put that code into the form module itself.

As a sidenote, I reserve the right to update any code in my blog at any time and of course, usage is at your only risk.

 ' I used http://www.vbcity.com/encoder/default.asp?lang=vb to colorize this code.
 ' Feel free to use any published results of my work in your applications.
 ' Refrain from stealing my work by republishing its results without my consent.


 Imports System.Drawing
 
 ' ...
 
 Private Const SRCCOPY As Integer = &HCC0020
 
 Private Declare Function BitBlt _
     Lib "gdi32.dll" ( _
     ByVal hdcDest As IntPtr, _
     ByVal x As Int32, _
     ByVal y As Int32, _
     ByVal Width As Int32, _
     ByVal Height As Int32, _
     ByVal hdcSrc As IntPtr, _
     ByVal xSrc As Int32, _
     ByVal ySrc As Int32, _
     ByVal dwRop As Int32 _
     ) As Boolean
 
 Private formImage As Bitmap
 
 Public Sub PrintForm(Optional ByVal fullWindow As Boolean = False)
   ' Copyright © 2004 by Mathias Schiffer. Leave this notice in place.
   ' Copies a screenshot of the form this code is being run in
   ' to the active printer. Place this code in a form module.
   ' Set fullWindow to True for including borders and titlebar.
   ' Remember to use an Imports reference to System.Drawing.
   ' Also, add a PrintDocument1 control to the form for printing.
   ' The disadvantage of this code is that it does only capture
   ' those parts of the form that are actually visible (screenshot),
   ' i.e. it must not be hidden and may not even be obscured.
   ' VB's PrintForm method does not require that, so this is not a
   ' perfect replacement. Keep that in mind.
 
   With Me ' This can easily be replaced with a Form parameter
 
     ' Create a Graphics object for the form
     Dim formGraphics As Graphics = .CreateGraphics
 
     ' Create a compatible bitmap and get its Graphics object
     If fullWindow Then
       formImage = New Bitmap(.Width, .Height, formGraphics)
     Else
       formImage = New Bitmap(.ClientRectangle.Width, _
                              .ClientRectangle.Height, _
                              formGraphics)
     End If
     Dim memGraphics As Graphics = Graphics.FromImage(formImage)
 
     ' Get the target and source device context handles (hDC)
     Dim sourceDC As IntPtr = formGraphics.GetHdc
     Dim targetDC As IntPtr = memGraphics.GetHdc
 
     ' Do the screenshot part of the job
     If fullWindow Then
 
       ' Consider the border width and the titlebar height
       Dim widthDelta As Integer = (.Width - _
                                    .ClientRectangle.Width)
       Dim heightDelta As Integer = (.Height - _
                                     .ClientRectangle.Height)
       ' Copy the form including its titlebar and borders
       BitBlt(targetDC, _
              0, 0, _
              .ClientRectangle.Width + widthDelta, _
              .ClientRectangle.Height + heightDelta, _
              sourceDC, _
              0 - widthDelta \ 2, 0 - (heightDelta - widthDelta \ 2), _
              SRCCOPY)

     Else
 
       ' Copy the form's client area
       BitBlt(targetDC, _
              0, 0, .ClientRectangle.Width, .ClientRectangle.Height, _
              sourceDC, _
              .ClientRectangle.X, .ClientRectangle.Y, _
              SRCCOPY)
 
     End If
 
     ' Release DCs and dispose objects
     formGraphics.ReleaseHdc(sourceDC)
     formGraphics.Dispose()
     memGraphics.ReleaseHdc(targetDC)
     memGraphics.Dispose()
 
     ' formImage now has the form's image. Print it before disposing it.
     PrintDocument1.Print() ' Invokes PrintDocument1_PrintPage (below)
 
     ' Finally dispose the image
     formGraphics.Dispose()
 
   End With
 
 End Sub
 
 Private Sub PrintDocument1_PrintPage( _
     ByVal sender As System.Object, _
     ByVal e As System.Drawing.Printing.PrintPageEventArgs _
     ) Handles PrintDocument1.PrintPage
 
   ' Print the screen shot in formImage. Use DrawImage's
   ' parameters to control the position of the printer output.
   e.Graphics.DrawImage(formImage, 100, 200)  ' printing position x=100, y=200
 
 End Sub

Visual Studio 2005 Beta Documentation Library available on the Web

The documentation for Visual Studio 2005 BETA bits is available at http://lab.msdn.microsoft.com/library/.

This should be an interesting URL for anyone who cannot or does not want to, at this point in time, install the beta bits on their machines but still would like to have access to reference type material for the upcoming features of the next version of Visual Studio .NET and the .NET Framework 2.0.

For offline viewing, you might also be interested in downloading the MSDN documentation for the Visual Studio 2005 Express products. It's publicly available as a 162 MB file download at http://download.microsoft.com/download/d/5/f/d5fbf037-59b9-4906-b20b-de5dd544de12/msdnixp.exe

Direct downloads for Visual Studio 2005 Express BETA products now available

Many folks have been having problems downloading the Visual Studio 2005 Express Beta 1 bits due to the nature of their download process (download the installer and have the installer download the software - probably in an effort to reduce the actual download size to what the machine in question actually needs, but scary and malfunctioning stuff in most cases not only for Microsoft software).

Fortunately, you can now download the Visual Studio 2005 Express Beta bits directly from the following download pages:

Visual Basic 2005 Express BETA 1 direct download page:
http://lab.msdn.microsoft.com/express/vbasic/vbasicmaninstall/default.aspx

Visual C# 2005 Express BETA 1 direct download page:
http://lab.msdn.microsoft.com/express/vcsharp/vcsharpmaninstall/default.aspx

Visual C++ 2005 Express BETA 1 direct download page:
http://lab.msdn.microsoft.com/express/visualc/visualcmaninstall/default.aspx

Visual J# 2005 Express BETA 1 direct download page:
http://lab.msdn.microsoft.com/express/vjsharp/vjsharpmaninstall/default.aspx

Visual Web Developer 2005 Express BETA 1 direct download page:
http://lab.msdn.microsoft.com/express/vwd/vwdmaninstall/default.aspx

SQL Server 2005 Express Technical Preview Download: [Now offline. Go here instead.]

Apple's CEO becomes a Microsoft employee! ;-)

Christian Maranitsch
Christian Maranitsch

This guy is Apple Computers' CEO.
Apple Computers Austria, that is.
Oh, and CEO, that actually is a "was" from today onwards.
He is now a Microsoft employee.

From August 2002 to July 2004, Christian Maranitsch headed the Austrian division of Apple Computers, Inc. Don't worry if you didn't know. Austria is a relatively small country (8 million inhabitants). And Apple is a relatively small computer manufacturer (market share below 3%). Actually, this post is going to be the first english language hit that Google finds for Christian's name and Apple. Nonetheless, a lot of companies have a national subsidiary in Austria. So does Apple, and so does Microsoft.

The news, to get back to the lurid title of this post, is that Christian Maranitsch yesterday quit as Apple Autria's CEO to become a department head of the "Enterprise & Partner Group" department of Microsoft Austria (serving approx. 300 enterprise customers). Which still is, in a relatively small country, a relatively small company (with about 200 employees).

Herbert Schweiger
Herbert Schweiger

You may or may not be too surprised to learn that Christian had already been working with his new boss, Microsoft Austria's CEO Herbert Schweiger, who has been with Microsoft since February this year. Christian Maranitsch was a Sales- and Marketing Manager at Compaq Austria, when Herbert Schweiger headed the company between September 1999 and 2003. When Compaq and HP merged, Herbert Schweiger left to lead his first employer IBM Austria's small businesses department, until he joined Microsoft Austria as their CEO shortly afterwards.

After all, Austria is a relatively small country. ;-)

Prepare for backwards incompatibilities in .NET Framework 2.0

Today's fatal error:
You started using a Microsoft product prior to its version 3.0.

These changes in the .NET Framework might break your current apps in the future:
http://www.gotdotnet.com/team/changeinfo/Backwards1.1to2.0/default.aspx

MSDN article on Operator Overloading with Visual Basic 2005

Does anybody remember the very first official web page that Microsoft ever released to announce Visual Basic .NET? For about a week, it said Visual Basic .NET would include operator overloading.

Visual Basic 2005 will finally support this technique, and Matthew Gertz (Dev Lead for the VB Compiler, Editor & Debugger team) has published an MSDN article on how to use it.

Critical Update for Internet Explorer with ADODB.Stream (KB870669)

They're late. Not a year, but 8 months. In the long version, they call it: "Critical Update for Microsoft Data Access Components - Disable ADODB.Stream object from Internet Explorer (KB870669)".

Anyway, here (or on Windows Update) is a fix to an important problem with Internet Explorer and local storage access. More information is available at http://support.microsoft.com/?kbid=870669 (this Knowledge Base article also describes the actions the fix performs for you automatically).

Download Visual Studio 2005 Beta 1

As of today, you can download Beta 1 of VS [.NET] 2005 from MSDN Subcriber Downloads.

Visual Studio 2005 Express Edition products have a blog of their own

Recently, Microsoft teams seem to be establishing blogs for products, ideas and whatever. That's cool (for now). In this case, the folks in charge of the "Express Editions"  I wrote about on Sunday established one at http://blogs.msdn.com/express/, allowing to provide direct feedback to them.

Do use these ways of direct interaction with the product teams now - if you have something interesting, useful or charming to tell them, that is. Once this kind of stuff gets public attention (and that usually won't take too long), everybody will simply need to pull (or leave in place and ignore) those interaction channels due to abuse and inacceptable signal-to-noise ratio. So do take your chances early enough.

More Posts Next page »