How to: Create an Expandable Edit Control
You can create an expandable edit control for a Windows Mobile-based Smartphone by using the Windows CE CreateWindow and Windows CE SendMessage functions.
To create an expandable edit control
- Add the CreateWindow function to create the edit control. Specify the control ID using the HMENU parameter and the ES_AUTOHSCROLL, ES_AUTOVSCROLL, and ES_MULTILINE styles. For information about the styles, see Expandable Edit Control.
In the following example, the HMENU parameter specifies
nEditID:hwndList = CreateWindow(TEXT("ExpandableEdit"), NULL, WS_VISIBLE| ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE, x, y, cx, cy, hwndParent, (HMENU)nEditID, hinst, NULL); - Add the CreateWindow function to create the up-down control. You can add styles to modify the control. For more information, see Expandable Edit Control.
In the following example, the UDS_EXPANDABLE style is added to expand the control to a full screen when the user presses the Action key:
hwndUpDown = CreateWindow(TEXT("UpDownClass"), NULL, WS_VISIBLE | UDS_ALIGNRIGHT | UDS_EXPANDABLE | UDS_NOSCROLL, 0, 0, 0, 0, hwndParent, (HMENU)nUpDownID, hinst, NULL); - Add the SendMessage function to send a message to the up-down control. The message specifies the ID of the edit control and sets this control as the buddy window for the up-down control.
In the parameter list, specify the up-down and edit control handles and the Windows CE UDM_SETBUDDY message. In the following example, the handles are
hwndUpDownandhwndEdit:SendMessage(hwndUpDown, UDM_SETBUDDY, (WPARAM)hwndEdit, 0);
Example
BOOL rb;
int rc;
LRESULT lr;
hwndList = CreateWindow(TEXT("ExpandableEdit"), NULL,
WS_VISIBLE| ES_AUTOHSCROLL |
ES_AUTOVSCROLL | ES_MULTILINE,
x, y, cx, cy,
hwndParent, (HMENU)nEditID, hinst, NULL);
if (hwndList == NULL) // CreateWindow failed.
{
rc = MessageBox(NULL, _T("Could not create list box window."),
_T("Error"), MB_OK);
if (rc == 0) // Not enough memory to create MessageBox.
return E_OUTOFMEMORY;
return E_FAIL; // Replace with specific error handling.
}
hwndUpDown = CreateWindow(TEXT("UpDownClass"), NULL,
WS_VISIBLE | UDS_ALIGNRIGHT |
UDS_EXPANDABLE | UDS_NOSCROLL,
0, 0, 0, 0,
hwndParent, (HMENU)nUpDownID, hinst, NULL);
if (hwndUpDown == NULL) // CreateWindow failed.
{
rc = MessageBox(NULL, _T("Could not create Up/Down window."),
_T("Error"), MB_OK);
if (rc == 0) // Not enough memory to create MessageBox.
return E_OUTOFMEMORY;
return E_FAIL; // Replace with specific error handling.
}
lr = SendMessage(hwndUpDown, UDM_SETBUDDY, (WPARAM)hwndEdit, 0);
// lr now contains the handle to the previous buddy window.
See Also
Last updated on Friday, April 22, 2005
© 2005 Microsoft Corporation. All rights reserved.
Send feedback on this topic to the authors.