You can add a standard control by creating an instance of a control using CoCreateInstance.
Because Windows CE for the Auto PC supports only InProc servers, the dwClsContext parameter of CoCreateInstance must be CLSCTX_INPROC_SERVER.
The following code example shows how to create a power list box control.
hr = CoCreateInstance(CLSID_ASPOWERLISTBOX, NULL,
CLSCTX_INPROC_SERVER, IID_ASPOWERLISTBOX,
(PVOID *) &pPLB);
if (FAILED(hr)) goto LReturn;
The following code example shows how to size and align an IASControl control.
pPLB->SetBounds(0,18,225,45);
pPLB->put_Alignment(ASFC_ALIGN_CENTER);
This code example uses an IASControl method, SetBounds, to specify the dimensions of the control in relation to its form. The values passed to SetBounds describe a control whose x-coordinate begins at the left edge of the form and whose y-coordinate begins 18 pixels from the top of the form. The control is 225 x 45 pixels. To specify that the power list box should be centered, the code example uses put_Alignment, which is a method in the IASPowerListBox interface.
When an action occurs, such as a keystroke or focus change, the form notifies the active control by calling one of several messages, such as IASClassMsgSink::HandleGotFocus or IASClassMsgSink::HandleKeyPress. These notifications are handled by the control, and are not passed to the application. If your application needs to handle such actions, you must implement a class message sink. To assign a class message sink to a form, use IASControl::put_ClassMsgSink.
The following code example shows how to add a class message sink.
hr = m_pForm->put_ClassMsgSink((IASClassMsgSink *)this);
The following code example shows how to use the Add method.
g_pForm->Add(pPLB, IDC_PLB);