Inking Input

The Rich Ink control allows you to capture stylus motions with little effort. It provides a convenient means for applications to accept input from a user without using a keyboard. For a user, taking notes or drawing sketches with the Rich Ink control is very much like writing or drawing on paper.

In addition to capturing images, Rich Ink has powerful editing and formatting capabilities. For example, when the user deletes a word from handwritten notes on the screen, the control automatically closes the resultant word gap. Some examples of how Rich Ink can be used include:

     To embed the Rich Ink control in your application
  1. Call InitCommonControls to load the common control dynamics-link library (DLL).
  2. Call InitInkX to load and initialize Rich Ink control.
  3. Call CreateDialog to instantiate a dialog box with a custom ink control.

    – Or –

  4. Call InitCommonControls to load the common control DLL.
  5. Call InitInkX to load and initialize Rich Ink control.
  6. Call CreateWindow and specify the class name as WC_INKX.

The EReceipt and InkControl sample codes provide two examples of the implementation.

After initialization, the Rich Ink control communicates with the calling application using the standard Windows CE messaging system. It sends the IM_SHOWCMDBAR message to the ink control to show or hide the command bar. It sends the IM_GETDATALEN, IM_GETDATA, and IM_SETDATA messages between the ink control and the application to transmit inking data, such as a notes or sketch. It sends the IM_REINIT message to the ink control to erase all the content from the control. It sends the standard EM_GETMODIFY and EM_SETMODIFY messages to the ink control to determine if its content has been modified and to set the modification flag in the control, respectively.

As an example of using the ink control, consider a calendar application with a Rich Ink control, named as InkX, embedded in a dialog box. The control's command bar can be toggled by using SendDlgItemMessage to send an IM_SHOWCMDBAR message. The state of the command bar is specified in the accompanying wParam:

SendDlgItemMessage(hInk, IM_SHOWCMDBAR, (WPARAM)m_bCmdBar, 0L);

Here hInk is a handle to the InkX control and m_bCmdBar is set to either TRUE or FALSE to specify whether or not the command bar is visible.

To save an edited or a newly created note, you must get the data length by sending:

InkDataLen=SendDlgItemMessage(hInkX, IM_GETDATALEN, 0, 0L);

For each date entry, the application keeps an ink note, pInkData, of the BYTE pointer type. The application should first allocate sufficient memory to store the ink note, and then pass the pInkData pointer to the control through the messages lParam parameter:

InkDatalen=SendDlgItemMessage(hInkX, IM_GETDATA, InkDataLen, (LPARAM)pInkData);

When the user taps a calendar date, the application should retrieve any previously saved ink data and bring up the ink control. It then sends the following message to refresh the document view with the retrieved ink data:

SendDlgItemMessage(hInkX, IM_SETDATA, dwInkDataLen, (LPARAM)pInkData);

The dwInkDataLen parameter gives the length of the ink data; pInkData is a pointer to the data itself. You should release the ink data, pInkData, once it has been passed to the ink control.