MATHS

The MATHS, MATHS1, MATHS2, and MATHS3 samples demonstrate how you can create ActiveX controls and embed them in an MFC ActiveX container.

The main dialog class in this application, CMathsDlg, has two controls, a check box, labeled "Opposite," and a control of the class CMathsCtl, which is derived from CWnd.

CMathsDlg's override of OnInitDialog displays a query dialog with a list box that presents three options.

When you select a control from the list box and dismiss the query dialog, the main dialog retrieves the index of the control you selected. It then creates a CMathsCtl object below the check box.

CMathsDlg assigns the index of the control you selected to it's CMathsCtrl member's m_idControl member. The CMathsCtl object uses this identifier to determine which CLSID to pass to its CreateControl function. This CLSID determines which of the three ActiveX controls will be instantiated.

The three controls, MATHS1, MATHS2, and MATHS3 are very similar. MATHS1 draws a horizontal line and a vertical line. If the "Opposite" check box is checked, it only draws the horizontal line. When you tap one of the lines with the stylus, the control fires an "Inside" event to its container. When you tap any other part of the control, it fires an "Outside" event.

When the control's container, the CMathsDlg object, receives an "Inside" event, it reverses the foreground and background colors of its CMathCtl object. When it receives an "Outside" event, it toggles the check state of the "Opposite" check box. Whenever the state changes, the ActiveX control redraws itself.

The MATHS2 and MATHS3 controls behave the same way as MATHS1, except that MATHS2 draws diagonal lines, instead of horizontal and vertical, and MATHS3 draws a vertical line if "Opposite" is not checked, or a circle, if it is.

These samples demonstrate the following keywords:

MATHS MATHS1, MATHS2, MATHS3
CButton::GetCheck CBrush::CreateSolidBrush
CButton::SetCheck CDC::Ellipse
CDialog::OnInitDialog CDC::FillRect
CListBox::AddString CDC::LineTo
CListBox::GetCurSel CDC::MoveTo
CString::LoadString CDC::SelectObject
CWinApp::LoadIcon COleControl::GetClientRect
CWnd::Create COleControl::InitializeIIDs
CWnd::CreateControl COleControl::InvalidateControl
CWnd::GetDlgItem COleControl::TranslateColor
CWnd::GetProperty COlePropertyPage
CWnd::InvokeHelper CWnd::OnLButtonDown
CWnd::OnSysCommand AfxOleRegisterPropertyPageClass
CWnd::SetIcon AfxOleUnregisterClass
CWnd::SetProperty DDP_PostProcessing
CWnd::ShowWindow  
CWnd::UpdateWindow  
AfxGetApp  
GetSystemMenu  

You can find the MATHS project files in the Wce\Samples\Mfc\MATHS directory.

The MATHS1 project files are in the Wce\Samples\Mfc\MATHS1 directory.

The MATHS2 project files are in the Wce\Samples\Mfc\MATHS2 directory

The MATHS3 project files are in the Wce\Samples\Mfc\MATHS3 directory.

For information on the Windows CE platforms that support this sample, see MFC for Windows CE Samples.