Sonntag, 3. Februar 2008

Zooming in the old COM Webbrowser Control

You may use the traditional COM Webbrowser Control for cetain reasons. How is the zoom changed in this Control?

It is NOT like in the managed Version of the HTMLDocument.

Dim Zoomlevel As Integer = 100



Private Sub WebBrowser_PreviewKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles WebBrowser.PreviewKeyDown
If e.Control = True AndAlso e.KeyCode = Keys.Subtract Then
Zoomlevel *= 0.95
Me.Browserinfoobj.HTMLDocument.body.style.setAttribute("zoom", Zoomlevel & "%")
ElseIf e.Control = True AndAlso e.KeyCode = Keys.Add Then
Zoomlevel /= 0.95
Me.Browserinfoobj.HTMLDocument.body.style.setAttribute("zoom", Zoomlevel & "%")
ElseIf e.Control = True AndAlso e.KeyCode = Keys.NumPad0 Then
Zoomlevel = 100
Me.Browserinfoobj.HTMLDocument.body.style.setAttribute("zoom", Zoomlevel & "%")
End If
End Sub


 



 



 

How to zoom inside an System.Windows.Forms.Webbrowser Control?

If I talk about zooming webseite I think of the way IE 7 zoomes them. So we are talking about a real zoom NOT about chaning the fontzises. This optical webseite zoom is unique to IE 7. The question is: How does it work?

The answer is quite simple. You have to manipulate the DOM of the Website. So everything is made by the use of a System.Windows.Forms.HTMLDocument.

In this example it is required to have 3 keydowns registered. One for "+", another for "-" and the 3rd for "0". All 3 should onlny fired if the control key is also pressed. Thing about that: Writing inside a webform and then the zoom of the site changes all the time. That would not be the effect you want to have. ;)

First we need a Variable where we save the zoom size.

Dim Zoomlevel As Integer = 100


   Private Sub Webbrowser_PreviewKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles Webbrowser.PreviewKeyDown
If e.Control = True AndAlso e.KeyCode = Keys.Subtract Then
Zoomlevel *= 0.95
Me.Webbrowser.Document.Body.Style = "zoom: " + Zoomlevel.ToString + "%"
ElseIf e.Control = True AndAlso e.KeyCode = Keys.Add Then
Zoomlevel /= 0.95
Me.Webbrowser.Document.Body.Style = "zoom: " + Zoomlevel.ToString + "%"
ElseIf e.Control = True AndAlso e.KeyCode = Keys.NumPad0 Then
Zoomlevel = 100
Me.Webbrowser.Document.Body.Style = "zoom: " + Zoomlevel.ToString + "%"
End If
End Sub


So what is this Code doing?



First the keys are detected. That is nothing special to an KeyDown Event. The Sizing is a bit special in this Vesion since it does not just add a Value. We use a multiplication *.95 for reducing the dize and a division for making things bigger. The Combination of Control an NumPad0 just setzt the size to the normal value.



So why is there a muliplication or a division? It is just my idea. You can do it with a fixed value. But thing of this: By zooming out with every zoom the difference between the last size and the new size will be smaller. By zooming in the difference will be bigger with each zoom. As I think here the user gets faster the size he wants. And you do not use high steps for changing since the factor is just .95. 

Montag, 28. Januar 2008

.net Sources are available

Since a few days Microsoft allows access on the .net Framework sources. Visual Studio 2008 was announced with the feature of stepping into the .net source. This is not possible by default so you have to configure your version first. Here you find how to do this. The bad news is: No Express Edition supports stepping into the .net sources - poor for all hobbyists out there.

Donnerstag, 3. Januar 2008

Visual C# 2008 Express Edition

Since last review was on VB 2008 Express we will now look a bit closer on Visual C# 2008 Express Edition.

The part called "Evolution of GUI" of our last review fits exactly also to the C# Express Edition - and also to the professional Editions (but there are more changes).

Also the project types are similar to VB Express.

The new WPF Designer Features fit to VB and C#.

So looking what's new in the Application Properties Tab.

Application Properties

Tab Application

There is a little surprise. The VB Version does not support changing the target Framework. If you expect that also for the C# Version you are wrong. Visual C# Express can do it!

But there is another surprise: No View 'UAC Settings button'. Since the UAC Settings are stored inside the application.manifest file I think you can easily get this functionality by using a text editor.

image

Except this there are no major changes in the application projects which are not in the VB Version. As the VB Version C# support now modifiers for resources and settings.

 

 

So you might ask: What is with .net's, c#'s and VB's new cool functionalities? You have not mentioned them in one word?

The answer is: This was a review of the IDE. .net Features are features of .net - nor of visual Studio. And also the language features are not depending on Visual Studio.

All three cases are worth for getting special reviews.

Dienstag, 1. Januar 2008

Opening Visual Studio 2008 Express Projects in Visual Studio 2008

1) Single projects (vbproj)

Here are no problems - open it in Visual Basic 2008 Express and then in Visual Studio 2005 (e. g. Standard Edition ) . Everything works.

2) Complete Visual Studio Solutions

If you open a Visual Studio 2005 Solution in Visual Basic 2008 Express Edition a conversion wizard is shown.

Im most cases only the solution file will be changed.

Here is an example of a converted file:

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Basic Express 2008
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Souvergin - RSS Reader", "Souvergin - RSS Reader\Souvergin - RSS Reader.vbproj", "{9EF163F6-8BFB-40A8-90ED-99DE4EA6A17C}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Any CPU = Debug|Any CPU
        Release|Any CPU = Release|Any CPU
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {9EF163F6-8BFB-40A8-90ED-99DE4EA6A17C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {9EF163F6-8BFB-40A8-90ED-99DE4EA6A17C}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {9EF163F6-8BFB-40A8-90ED-99DE4EA6A17C}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {9EF163F6-8BFB-40A8-90ED-99DE4EA6A17C}.Release|Any CPU.Build.0 = Release|Any CPU
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
    EndGlobalSection
EndGlobal

This file can not be opened by Visual Studio 2005. But if you have also one of the full versions of Visual Studio like standard or professional you might want to work with them instead of an express edition.

So what is to change?

Only the first two lines:

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005

Save your edited file and then you can work with Visual Studio 2005. Maybe in some cases it would be useful to save your backported Version as a separate file e. g. if you often switch between both IDE's.

Sonntag, 30. Dezember 2007

Visual Studio Basic 2008 Express Edition

The first start

As in the past the first Visual Studio start requires some post setup configurations. I do not know why they are writing 'This might take a few minutes', but okay they will know what they do. In fact it need only a few seconds on my computer.

image 

After configuration you will see the VS window with opened start page.

The evolution of GUI

image

On the first look you will see a few UI changes. The rounds are edges. While the old start page was filled with rounder edged - the new more modern looking design is more edged. The main areas in the start page are as before: MSDN feed, recent projects, getting started and Visual Basic Express Headlines.

The Menu has also redesigned.  The selected item is not only shown in a different background colour it gets a 3D Effekt

image

The active Tab gets a other back colour so if you have many files opened you can easier see where you are.

image

Creating a new Project

The formally included project types : Windows Forms Application, Class Libary and Console Application are extended by WPF Application and WPF Browser Application to meet the new features of .NET 3.5. The express Editions are limited to the .net Framework 3.5 - the can not build projects for .NET 2 and 3.0 like the full Visual Studio 2008 Versions. But such a feature is more interesting for professional Developers than hobbyists which the express editions are made for. If you want to develop .net 2 with Express Editions you have to Download the 2005 ones. But in most cases the .net 3.5 framework will be a good choose since it implement as far as I know all features of .net 2. 

image

Windows Forms Application

Business as usual  - everything is there where I was before. No real amazing changes except the 'Element Host'  for Windows Presentation Foundation Controls. This feature will as far as I think become important, since WPF will get more and more important. So a Control for hosting WPF inside a Windows Form is a good invention.

WPF Application / WPF Browser Application

Here you can not really speak of changes since the project type is completely new. Okay there was an Plug-in for allowing VS 2005 building WPF Projects but I was not as good as the real support in VS 2008.

image

The designer layout reminds me to the Visual Studio layout for web projects. You can view the visual designer in the top of the window and at the button the XAML Code. Other possibilities are: Only view XAML or only view the visual Designer. The right part with solution explorer and properties are like in other projects. But in XAML windows and for XAML Controls you are able so search after special properties.

image 

Application Properties

Here are many changes compared to the past. This changes are not related to special project types.

image

Tab Application
"View UAC Setting"

Since Windows Vista introduced the User Account Protection (UAC) applications must be programmed in mind of this feature. So now you are able to configure easily the UAC requirements for your applications.

image 
Tab Resources

Access Modifier for Resources. Now it is possible to select the public or friend modifier for all your Resources

image

Tab Settings

Access Modifier for Settings. Now it is possible to select the public or friend modifier for all your Settings.

Tab My Extensions

With this complete new feature you can easily add, view, or remove extensions to the My namespace.

image

Will be continued soon.