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(UPDOWN_CLASS, 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
hwndUpDown
andhwndEdit
:SendMessage(hwndUpDown, UDM_SETBUDDY, (WPARAM)hwndEdit, 0);
Code Example
The following code example demonstrates how to create an expandable edit control.
Note To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.
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(UPDOWN_CLASS, 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
Creating Windows Mobile Controls | Expandable Edit Control
Send Feedback on this topic to the authors