You are requesting some specific functions. It looks like you are creating a planning application or trying to display a log of events that occurred in the past. This is called a Gantt chart . You can buy Gannt Chart controls for MFC online. Google for some.
There is more to your question than just drawing it; You cannot and should not use CListCtrl as your data structure. It seems you have an array of objects that start and end. For instance:
struct Range {
int startTime;
int endTime;
};
std::vector<Range> events;
After you have placed your events in this simple vector, you have to iterate over all the elements and compare the start and end times to see if they overlap the range that you are considering:
typedef std::vector<Range> RangeVec;
typedef RangeVec::iterator RangeIter;
void is_between(int time, const Range& r)
{
return time >= r.start && time <= r.end;
}
void findRanges(RangeVec *matches, const RangeVec& input, const Range& query)
{
for (RangeIter it = input.begin(); it != input.end(); ++it) {
if (is_between(it.start, query) || is_between(it.end, query) ||
(it.start <= query.start && it.end >= query.end))
{
matches->push_back(*it);
}
}
, . , CWnd:: OnPaint(), , .