An MFC ActiveX control to display trays






4.20/5 (2 votes)
An MFC ActiveX control to display trays and samples, with selection and cherry picking properties
Introduction
I recently had need to develop an ActiveX control for displaying trays and samples in a chemistry application used by chemists (surprise there!). The control needed to be able to display trays of any size x*y, have column headings; allow sample insert and cherry picking. The control itself is very easy to use in your own projects once the ActiveX control has been registered. In visual studio you can add the control to your application by using Project->Add to project->Components and controls go to ActiveX controls and look for TrayControl control. Insert it into your project and a wrapper class will be created for you. You should then be able to drag controls onto dialogs and forms in your app from the resource editor.Some of the more interesting functions supported are:
EnableDoubleBuffering()This makes the control use a memory DC (Kieth Rules class, with a very small mod), so the control does not flicker.EnableCherryPicking()Allows the user to select position with the mouse, drag selections etc.SetShowInsertionPoint()Allows the user to see and move the next location insertion point in the control.SetShowCellTitlesThe names of samples in a given cell location will be displayed when the mouse passes over a given cell. The control itself can fire the following events:FireControlClickedWhen the user left clicks on the control. If the user clicked on a specific cell, this location is reported, else -1.FireCherryPickedThe user has performed a cherry picking operation, or changed the cherry picked status of a cell.FireInsertionPointChangedThe insertion point for the next sample was changed using the arrow keys or by double-clicking a cell.FireControlRightClickedThe user right clicked the control. The cell location is given in the user did so on a specific cell, else -1.
Many other features are also available.
I hope you enjoy using the control.
Acknowledgments
Keith Rule - The MemDC class
Ales Krajnc - the ColorNames colours http://www.codeproject.com/gdi/colornames.asp