Windows API Guide: CreateFontIndirect Function


Platforms

  • Windows 95: Supported.
  • Windows 98: Supported.
  • Windows NT: Requires Windows NT 3.1 or later.
  • Windows 2000: Supported.
  • Windows CE: Requires Windows CE 1.0 or later.

Description & Usage

Sending the EM_CANUNDO message to an edit control determines if the last operation can be undone. If an undo is allowed, the user can select "Undo" from the control's context menu, and the EM_UNDO message can also be sent to perform an undo.

Return Value

If an undo operation is valid, the function returns a nonzero value. If no undo is possible, the function returns 0.

Visual Basic-Specific Issues

None.

Parameters

wParam
Not used -- set to 0.
lParam
Not used -- set to 0.

Constant Definitions

Const EM_CANUNDO = &HC6

Example

Demonstrate undo operations for an edit control. Place three controls on a form window: an edit control (text box) named txtBox, a command button named cmdUndo, and another command button named cmdSet. Pressing cmdSet sets the contents of txtBox to a predetermined string, a change that cannot be undone. Pressing cmdUndo, naturally, undoes the last change made by the user to txtBox. Whenever the contents of txtBox change, the enabled status of cmdUndo is changed so that the button is enabled if and only if an undo is possible.

' This code is licensed according to the terms and conditions listed here. ' Declarations and such needed for the example: ' (Copy them to the (declarations) section of a module.) Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As Long, ByVal _ Msg As Long, wParam As Any, lParam As Any) As Long Public Const EM_CANUNDO = &HC6 Public Const EM_UNDO = &HC7 ' *** Place the following code inside a form window. *** Private Sub Form_Load() ' Make sure cmdUndo is initially disabled. cmdUndo.Enabled = False End Sub Private Sub txtBox_Change() ' Whenever the contents of txtBox change, see if an undo is possible. Dim possible As Long  ' is it possible? possible = SendMessage(txtBox.hWnd, EM_CANUNDO, ByVal CLng(0), ByVal CLng(0)) ' Since 0 = False and anything else = True, we can do this: cmdUndo.Enabled = possible End Sub Private Sub cmdUndo_Click() ' Undo the last change the user made to the contents of txtBox. Dim retval As Long  ' return value retval = SendMessage(txtBox.hWnd, EM_UNDO, ByVal CLng(0), ByVal CLng(0)) ' Since undo operations can themselves be undone, there's no ' reason to send the EM_CANUNDO message here.  cmdUndo is already enabled. End Sub Private Sub cmdSet_Click() ' Set the contents of txtBox to a predetermined string.  This can't be undone ' using the Undo command or the EM_UNDO message. txtBox.Text = "You can't use Undo until you change this text!" End Sub

See Also

EM_UNDO

Category

Edit Controls

Back to the Message list.
Back to the Reference section.


Last Modified: August 26, 2000
This page is copyright © 2000 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/e/em_canundo.html



Windows API Guide
Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
ISBN: B001V0KQIY
EAN: N/A
Year: 1998
Pages: 610

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net