Click here to Skip to main content
13,295,409 members (63,137 online)
Click here to Skip to main content
Add your own
alternative version


17 bookmarked
Posted 15 Nov 2001

An MFC ActiveX control to display trays

, 15 Nov 2001
Rate this:
Please Sign up or sign in to vote.
An MFC ActiveX control to display trays and samples, with selection and cherry picking properties

Sample Image


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:

This makes the control use a memory DC (Kieth Rules class, with a very small mod), so the control does not flicker.
Allows the user to select position with the mouse, drag selections etc.
Allows the user to see and move the next location insertion point in the control.
The 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:
When the user left clicks on the control. If the user clicked on a specific cell, this location is reported, else -1.
The user has performed a cherry picking operation, or changed the cherry picked status of a cell.
The insertion point for the next sample was changed using the arrow keys or by double-clicking a cell.
The 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.


Keith Rule - The MemDC class
Ales Krajnc - the ColorNames colours


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Roger Allen
Software Developer (Senior) Sirius Analytical Instruments
United Kingdom United Kingdom
A research and development programmer working for a pharmaceutical instrument company for the past 17 years.

I am one of those lucky people who enjoys his work and spends more time than he should either doing work or reseaching new stuff. I can also be found on playing DDO on the Cannith server (Send a tell to "Maetrim" who is my current main)

I am also a keep fit fanatic, doing cross country running and am seriously into [url][/url] Karate at this time of my life, training from 4-6 times a week and recently achieved my 1st Dan after 6 years.

You may also be interested in...


Comments and Discussions

GeneralActiveX Control Pin
Vaibhav8831523-Mar-09 20:41
memberVaibhav8831523-Mar-09 20:41 
GeneralVisual Studio 2005 Pin
AndyUk0620-Jun-07 5:32
memberAndyUk0620-Jun-07 5:32 
GeneralSample Image doesn't display in Firefox Pin
jrem24-Nov-05 12:40
memberjrem24-Nov-05 12:40 
GeneralRepost the code Pin
gdom28-Mar-05 19:25
membergdom28-Mar-05 19:25 
Generalnice, but ... Pin
Markus Sicheneder5-Dec-01 2:30
memberMarkus Sicheneder5-Dec-01 2:30 
... some hazles in building. But you can though test the ocx with some changes

(1) help.rtf is missing -> OK, no real problem

(2) some other *.odl file (cannot remember the name Frown | :( ) is present in the project tree (source files). Remove it, if you want to build the OCX.

(3) dont use a unicode configuration: the code uses "strcpy" for unicode resources which definitely doesnt work ...

(4) resources are missing: copy any bmp into the source directory and name it "TrayControlCtl.bmp"

OK, now at least you can compile and use the OCX in an application. But I still have some questions:

(1) I get a "debug assertion" in the resource editor when i am trying to include the OCX! What is the problem?

(2) what about scrolling? Is it possible, e.g. for a 200x100 grid?

(3) how to use the events? I admit that this might be a beginners OCX question.

(4) whats the license situation? It seems to be copyrighted for your company ...

Some further documentation would be nice though I know it is a hazle Wink | ;)

All in all it looks nice but it would be nicer if we could use it more smoothley Poke tongue | ;-P

Cheers Markus
GeneralRe: nice, but ... Pin
WREY30-Nov-03 11:23
memberWREY30-Nov-03 11:23 
GeneralMissing resource files Pin
codehound16-Nov-01 17:06
membercodehound16-Nov-01 17:06 
GeneralRe: Missing resource files Pin
Roger Allen19-Nov-01 7:00
memberRoger Allen19-Nov-01 7:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171207.1 | Last Updated 16 Nov 2001
Article Copyright 2001 by Roger Allen
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid