Click here to Skip to main content
15,886,110 members
Articles / Desktop Programming / WTL

Form Designer

26 Jul 2021CPOL24 min read 351.2K   82.5K   230  
Component for adding scriptable forms capabilities to an application.
// Fixes.h
//
// Author : David Shepherd
//			Copyright (c) 2002, DaeDoe-Software
//
/////////////////////////////////////////////////////////////////////////////
//
// this file fixes the following bugs
//
// CDC::DrawDragRect()
//
// std::list::sort() when sorting using a predicate
//
// in most cases the source code was blindly copied and the bug fixes
// applied with as little modification to the original as possible
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_FIXES_H__BB6D96C1_22FD_11D6_B6A6_9AD11DB62245__INCLUDED_)
#define AFX_FIXES_H__BB6D96C1_22FD_11D6_B6A6_9AD11DB62245__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

void DrawDragRect(CDC &dc, LPCRECT lpRect, SIZE size, LPCRECT lpRectLast, SIZE sizeLast, HBRUSH hBrush = NULL, HBRUSH hBrushLast = NULL);

// sorts a list using a predicate
template <class T, class Pr>
void SortListUsingPredicate(std::list<T> &List,Pr Predicate)
{
	// copy the list to a temporary vector
	std::vector<T> Vector;
	std::copy(List.begin(),List.end(),
		std::back_insert_iterator<std::vector<T> >(Vector));
	// sort the vector using the predicate
	std::sort(Vector.begin(),Vector.end(),Predicate);
	// copy the vector to the list
	List.clear();
	std::copy(Vector.begin(),Vector.end(),
		std::back_insert_iterator<std::list<T> >(List));
}

#endif // !defined(AFX_FIXES_H__BB6D96C1_22FD_11D6_B6A6_9AD11DB62245__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Web Developer
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions