Compartilhar via


Windows XP Features and Windows Forms Controls

Microsoft® Windows® XP has new features that you can take advantage of when you create Windows Forms:

  • New appearance and behavior (look and feel) in the user interface (UI)

  • New views for the ListView control

  • Fast user switching

User Interface Changes in Windows XP

With its release, Windows XP introduced new appearance and behavior to the Windows user interface . Composed of the same functional controls that were included in Visual Studio .NET the Windows XP UI features an updated look. Two examples of Windows XP enhancements are controls with rounded corners that light up on mouse over and a colorful ProgressBar control.


How a sample form and controls look on Windows XP with "visual styles" turned on

WinXPConAfter screenshot

NoteNote

The features described in this topic only apply to applications running on the Windows XP operating system. When running on other platforms, controls will retain the classic UI look, and any code related to visual styles will have no effect.

The controls available to developers in Visual Studioby contrast, do not share this appearance, even though they are the same controls.


How a sample form and controls look by default when created with Visual Studio

WinXPConBefore screenshot

You can think of a form as having two distinct parts: a client area and a non-client area. All applications running on the Windows XP operating system have a non-client area, which includes the window frame, title bar, and non-client scrollbars. The operating system applies a visual style to the non-client area by default, so that when your Windows form runs on Windows XP, you will see an updated title bar and scroll bars. This topic describes how to make changes to the client area.

Visual Styles

A visual style is the user-modifiable appearance of the user interface of an application or operating system. As already mentioned, the form's scroll bars and title bar will change immediately when run on Windows XP; most Windows Forms controls will automatically adopt the visual style when run on Windows XP if your application calls the EnableVisualStyles method. For more information, see How to: Enable Windows XP Visual Styles.

There are a few Windows Forms controls that will look the same on all operating systems; implementing EnableVisualStyles has no effect on these controls. These include the Label, LinkLabel, DomainUpDown, NumericUpDown, and CheckedListBox controls.

Windows XP ListView Styles

In addition to the new appearance of the UI, Windows XP also introduced two new styles for the ListView control, as evidenced in the right-hand pane of Windows Explorer.

  • Group view

  • Tile view

The grouping features of the ListView control in Windows XP enable you to visually arrange logically related sets of items together. These groups are separated on the screen by a horizontal group header that contains the title.

On platforms older than Windows XP, the groups will simply not appear. All items will be displayed as usual. For more information, see How to: Group Items in a Windows Forms ListView Control.

Insertion marks show users where dragged items will be placed. Insertion marks display when the AutoArrange property of the ListView control is set to false. When a user drags an item to a point between two other items, the insertion mark shows the item's expected new location.

On platforms older than Windows XP, the insertion mark will not appear and calls to insertion mark properties and methods will have no effect. For more information, see How to: Display an Insertion Mark in a Windows Forms ListView Control.

The tile-view feature of the ListView control enables you to provide a visual balance between graphical and textual information. The textual information displayed for an item in tile view is the same as the column information defined for details view. Tile view functions in combination with either the grouping or insertion mark features in the ListView control. The tile view uses a 32 x 32 icon and several lines of text.

Tile view properties and methods enable you to specify which column fields to display for each item, and to collectively control the size and appearance of all items within a tile-view window. For clarity, the first line of text in a tile is always the item's name.

On platforms that precede Windows XP, the ListView will appear in LargeIcon view. For more information, see How to: Enable Tile View in a Windows Forms ListView Control.

Fast User Switching on Windows XP

Windows XP introduced Fast User Switching, which allows multiple users to share a computer and switch between user sessions without closing the programs they are running. The .NET Framework provides a SessionSwitch event that occurs when the current user changes.

NoteNote

The SessionSwitch event only applies to Windows XP, and code in the SessionSwitch event handler will be ignored when running on other platforms.

The following code demonstrates writing data to a log in the SessionSwitch event:

Private Sub SessionSwitch(ByVal sender As System.Object, ByVal e As _
Microsoft.Win32.SessionSwitchEventArgs)
    If e.Reason = SessionSwitchReason.SessionLogon Then
        My.Computer.EventLogs.Application.WriteEntry( _
My.User.Username.ToString & " logged on at " & _
My.Computer.Clock.LocalTime.Now.ToString)
    ElseIf e.Reason = SessionSwitchReason.SessionLogoff Then
        My.Computer.EventLogs.Application.WriteEntry( _
My.User.Username.ToString & " logged off at " & _
My.Computer.Clock.LocalTime.Now.ToString)
    End If
End Sub
private void sessionSwitch(System.Object sender, _
Microsoft.Win32.SessionSwitchEventArgs e)
{
    if (e.Reason == SessionSwitchReason.SessionLogon)
        EventLog.WriteEntry("sessionSwitch", _
SystemInformation.UserName.ToString() + " logged on at " + _
DateTime.Now.TimeOfDay.ToString());
    else if (e.Reason == SessionSwitchReason.SessionLogoff)
        EventLog.WriteEntry("sessionSwitch", _
SystemInformation.UserName.ToString() + " logged off at " + _
DateTime.Now.TimeOfDay.ToString());
}

See Also

Tasks

How to: Group Items in a Windows Forms ListView Control
How to: Enable Tile View in a Windows Forms ListView Control
How to: Display an Insertion Mark in a Windows Forms ListView Control

Reference

FlatStyle
SessionSwitch