Click here to Skip to main content
15,867,834 members
Articles / Desktop Programming / Windows Forms

Touch Screen Explorer with Pen Flicks

Rate me:
Please Sign up or sign in to vote.
4.91/5 (28 votes)
31 May 2007CPOL5 min read 100.1K   1.6K   64   12
A Windows Explorer control using the new interface Pen Flicks in Windows Vista™ for Ultra Mobile PC/ Tablet PC.

Screenshot - main.jpg

Introduction

Pen Flicks is the latest methodology in Microsoft Windows Vista™ which is designed specifically for a Ultra Mobile/Tablet PC. They are gestures you can make with your tablet pen to quickly navigate and perform shortcuts.

This article describes a Touch Screen Windows Explorer which will leverage this new technology and will compare it with the traditional Windows Explorer. Here is a screenshot:

Screenshot - screenshot.jpg

The Goal

The goal is to create an efficient Touch Screen Windows Explorer which can be used in the Tablet PC / Ultra Mobile PC environment, where mouse and keyboards are barely available.

  • Big display for ease of use pertaining to small screens in Ultra Mobile PC
  • Browse feature with a pen or fingertips in Touch Screen/Ultra Mobile PC
  • Navigation using the forward, backward Pen Flicks, instead of mouse point and click
  • Scroll the Explorer using Up and Down Pen Flicks without traditional scrollbars

Background

Pen Flicks are quick, linear pen movements associated with scrolling actions and commands. Pen Flicks allow quick pen access to navigation and editing actions.

Pen Flicks in action: standard up and down Flicks.

Screenshot - GetOpenContent.gif

There are two categories of Pen Flicks: navigational and editing. Navigational Pen Flicks include drag up, drag down, move back, and move forward. Editing Pen Flicks include copy, paste, undo, and delete. For example, you can drag up or down on a page, move back or forward in a browser window, or paste an item into a document, all with a flick of your pen.

Pen Flicks settings can be found in the Control Panel of Windows Vista. You can see the details inside Pens and Input Devices. The feature works only with the Tablet PC / Ultra Mobile PC with Microsoft Vista. Click here to see the screenshot.

Windows Vista includes a set of eight basic Pen Flicks. See image below.

  • Scroll up and down
  • Navigate forward and back
  • Copy
  • Paste
  • Delete
  • Undo

Screenshot - GetOpenContent.png

These is the default set for Pen Flicks, and can be customized using the Pen Flicks API. If you don't override the feature, these functions will be called.

You can customize Pen Flicks to perform other functions, which increases your efficiency while making pen use feel more natural. To make pen training easier, Windows Vista includes a tutorial that presents the essentials of using a tablet pen to perform these shortcuts.

How the application talks with Pen Flicks

The Windows Vista operating system uses two approaches to interact with the application when a pen flick occurs, and they are in the following order:

  1. Windows Vista sends a WM_TABLET_FLICK message. The FLICK_DATA structure and FLICK_POINT structure, along with the message, provides all the information about the pen flick, like screen coordinates, action for the pen flick, the direction, and the state of modifier keys such as Ctrl and Shift etc.

  2. Windows Vista sends follow-up notifications WM_APPCOMMAND, WM_VSCROLL, or WM_KEYDOWN etc., depending on which action is associated with the pen flick.

A client application can process the WM_TABLET_FLICK message using the CWnd::WindowProc function, or can offer a response to the pen flick using the fact that Vista will send the action in the form of an APPCOMMAND with the backup keystroke. In this example, we will use the latter to interact with the Pen Flicks.

WM_TABLET_FLICK Message details (unmanaged):

WM_TABLET_FLICK
    WPARAM wParam
    LPARAM lParam

Parameters

  • wParam: A FLICK_DATA structure that contains information about the pen flick that occurred.
  • lParam: The FLICK_POINT structure that specifies where the pen flick occurred.

The FLICK_DATA structure contains information about a pen flick.

typedef struct FLICK_DATA
{
    FLICKACTION_COMMANDCODE iFlickActionCommandCode:5;
    FLICKDIRECTION iFlickDirection:3;
    BOOL fControlModifier:1;
    BOOL fMenuModifier:1;
    BOOL fAltGRModifier:1;
    BOOL fWinModifier:1;
    BOOL fShiftModifier:1;
    INT  iReserved:2;
    BOOL fOnInkingSurface:1;
    INT  iActionArgument:16;
}FLICK_DATA;

The FLICK_POINT structure provides information about a pen flick.

typedef struct FLICK_POINT
{
    INT x:16;
    INT y:16;
}FLICK_POINT;

The following is a list of application commands that can be assigned to flicks, with the backup keystroke message that might be sent.

CommandBackup keystroke
APPCOMMAND_BROWSER_BACKWARDNone
APPCOMMAND_BROWSER_FORWARDNone
APPCOMMAND_COPYCtrl+C
APPCOMMAND_PASTECtrl+V
APPCOMMAND_UNDOCtrl+Z
APPCOMMAND_DELETEDel
APPCOMMAND_CUTCtrl+X
APPCOMMAND_OPENCtrl+O
APPCOMMAND_PRINTCtrl+P
APPCOMMAND_SAVECtrl+S
APPCOMMAND_REDOCtrl+Y
APPCOMMAND_CLOSENone

Using the code

In this example, I am using the APPCOMMAND_BROWSER_BACKWARD and APPCOMMAND_BROWSER_FORWARD commands to browse up and down a level in the touch screen explorer, by calling Alt + Back Arrow keys for backward and Alt + Forward Arrow keys for the forward command.

C#
// the user control

public TouchScreenExplorer()
{
    InitializeComponent();
}

protected override System.Windows.Forms.CreateParams CreateParams
{
    get
    {
        CreateParams Cp = base.CreateParams;
        Cp.Style = Cp.Style & ~0x200000;
        return Cp;
    }
}

public void ResetFolder()
{
    listBox1.Items.Clear();
    imglpreview.Images.Clear();  

}

public void SetFolder(ListView myView, ImageList imglp)
{
    explorerListItems = myView;
   listBox1.Items.Clear();
   imglpreview.Images.Clear();
    //imglpreview = myImageList;

    int i = 0;    
    ImageCount = 0;
        
    
    for (int j = 0; j < myView.Items.Count; j++)   
    {
        try
        {
            imglpreview.Images.Add(imglp.Images[j] );
            listBox1.Items.Add(new Controls.Development.
            ImageListBoxItem(myView.Items[j].Text, j));
        }
        catch(Exception e1)
        {
            MessageBox.Show(e1.Message + i);   
        }

    }
}

The default Up and Down Flicks can be directly used to scroll up and down in the Touch Screen Windows Explorer. To navigate a level up and down in the Explorer tree, I am explicitly checking if the calling Pen Flick is causing Alt + Left arrow for backward action or Alt + Right arrow for forward action, which is again caused by the default flick left and right action. Here is a portion of the code, see attached file for details:

C#
public void NextImage()
{
    if (listBox1.SelectedIndex < listBox1.Items.Count-1)
    {
        listBox1.SelectedIndex = listBox1.SelectedIndex +1;
        ImageChangedEvent(this,EventArgs.Empty);  
    }
}

public void PreviousImage()
{
    if (listBox1.SelectedIndex >0)
    {
        listBox1.SelectedIndex = listBox1.SelectedIndex - 1;
        ImageChangedEvent(this,EventArgs.Empty);  
    }
}

private void listBox1_MouseUp(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Right ) 
    GoBackEvent(this, EventArgs.Empty);

}

private void listBox1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Alt && (e.KeyCode == Keys.Left) )
        GoBackEvent(this, EventArgs.Empty);

    if (e.KeyCode == Keys.Back)
        GoBackEvent(this, EventArgs.Empty);

    if (e.Alt && (e.KeyCode == Keys.Right))
    {
        ResetFolder(); 
        GoForwardEvent(this, EventArgs.Empty);
    }
    if (e.KeyCode == Keys.Enter)
    {
        ResetFolder();
        GoForwardEvent(this, EventArgs.Empty);
    }

}

Three screens of the Touch Screen Explorer tree

Screenshot - threelevel.jpg

A backward Flick in the second screen will display the first screen, and a forward Flick the third screen.

About the Explorer tree, I have made a Touch Screen Explorer control based on a Windows Explorer control from here and here. The Explorer control DLL can be found along with the source code. Here is a piece of code which shows the TreeNode Selected event of the traditional Explorer tree.

C#
private void expTree1_ExpTreeNodeSelected (string pathName, CShItem CSI)
{
    ArrayList dirList = new ArrayList();
    ArrayList fileList = new ArrayList();
    int TotalItems;
    LastSelectedCSI = CSI;
    if (CSI.DisplayName.Equals(CShItem.strMyComputer)) {
        dirList = CSI.GetDirectories(true );
        // avoid re-query since only has dirs

    }
    else {
        dirList = CSI.GetDirectories(true);
        fileList = CSI.GetFiles();
    }
            
    SetUpComboBox(CSI);
    TotalItems = (dirList.Count + fileList.Count);
    if ((dirList.Count > 0))
    {
        
        sbr1.Text = "Location: " + pathName + ", "
         + dirList.Count + " Directorie(s) and " + 
         fileList.Count + " File(s)";

        ArrayList combList = new ArrayList(TotalItems);
        combList.AddRange(dirList);
        combList.AddRange(fileList);
        lv1.BeginUpdate();
        lv1.Items.Clear();
        imglpreviewForm.Images.Clear();

        foreach (CShItem item in combList) 
        {
            ListViewItem lvi = new ListViewItem
            (item.DisplayName);

           
            if (item.IsFolder)
            {
                CShItem localitem = item;
                imglpreviewForm.Images.Add(SystemImageListManager
                .GetIcon(localitem.IconIndexNormal, false));
                lvi.ImageIndex = SystemImageListManager
                .GetIconIndex(ref localitem, false, false);
                lvi.Tag = item;
                lv1.Items.Add(lvi);
            }
            
        }

        lv1.EndUpdate();
        myPhotos1.SetFolder(lv1, imglpreviewForm);
        myPhotos1.CaptionText = CSI.DisplayName; 
    }
    else {
        lv1.Items.Clear();

    }
}

In action

Screenshot - Final.jpg

Thoughts

The Touch Screen Windows Explorer uses the latest technology, Pen Flicks, and gives more mobility to the user. It makes a Tablet PC/Ultra Mobile PC efficient by giving it the independence of keyboard and mouse. How different would have been the interface if there were never a keyboard or mouse ? What if scrollbars were never invented? These are some of the questions to get you started on interface interaction, when you develop your application for Tablet PC/Ultra Mobile application. Scrollbars are out, Point & click is out, Keyboard and mouse are out, Pen Flicks is in, Touch Screen in.

References

And thanks

For coming so far! I hope you find this useful, and take care.

Article history

  • Apr 15, 2007: First published
  • May 02, 2007: Added demo video
  • May 31, 2007: Content revised

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder Teamcal AI
United States United States

Comments and Discussions

 
GeneralKeyboard enable / disable Pin
Member 46725631-Mar-08 20:43
Member 46725631-Mar-08 20:43 
QuestionUnzip the Execute File (Failed) Pin
SAW LWIN22-Dec-07 17:53
SAW LWIN22-Dec-07 17:53 
AnswerRe: Unzip the Execute File (Failed) Pin
Raj Lal5-Jan-08 17:10
professionalRaj Lal5-Jan-08 17:10 
GeneralVista Mobile PC competition winner Pin
Dr.Luiji3-Jul-07 10:56
professionalDr.Luiji3-Jul-07 10:56 
GeneralRe: Vista Mobile PC competition winner Pin
Raj Lal3-Jul-07 11:20
professionalRaj Lal3-Jul-07 11:20 
GeneralCool Pin
Dr.Luiji16-May-07 2:12
professionalDr.Luiji16-May-07 2:12 
GeneralRe: Cool Pin
Raj Lal16-May-07 8:29
professionalRaj Lal16-May-07 8:29 
QuestionSuggestions .. Pin
Raj Lal14-May-07 8:03
professionalRaj Lal14-May-07 8:03 
GeneralA few comments Pin
Joe Sonderegger15-Apr-07 20:56
Joe Sonderegger15-Apr-07 20:56 
AnswerRe: A few comments Pin
Raj Lal16-Apr-07 7:29
professionalRaj Lal16-Apr-07 7:29 
GeneralRe: A few comments Pin
Joe Sonderegger16-Apr-07 20:31
Joe Sonderegger16-Apr-07 20:31 
GeneralRe: A few comments Pin
Raj Lal16-Apr-07 20:52
professionalRaj Lal16-Apr-07 20:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.