Click here to Skip to main content
15,884,298 members
Articles / Desktop Programming / MFC

A color picker dialog with a color dropper like Photoshop and Frontpage 2000

Rate me:
Please Sign up or sign in to vote.
4.83/5 (10 votes)
23 Jan 20022 min read 94.8K   4.3K   29  
A color picker and dropper that extends the standard Windows dialogs to behave like Photoshop or Frontpage 2000
// Copyright UCanCode Software Technology Inc, All Rights Reserved
// You can contact us.
// Support@UCanCode.net
// http://www.ucancode.net
/********************************************************************/
#if !defined(AFX_FOIMAGESTATIC_H__02063CA3_04B5_11D6_A4F2_525400EA266C__INCLUDED_)
#define AFX_FOIMAGESTATIC_H__02063CA3_04B5_11D6_A4F2_525400EA266C__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// FOImageStatic.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CFOImageStatic window

#include "FOCustomStatic.h"

class CFOImageStatic : public CFOCustomStatic
{
	DECLARE_DYNAMIC(CFOImageStatic)

// Construction
public:
	//  Constructs a <c CFOImageStatic> control object.
	CFOImageStatic();

	virtual BOOL AttachStatic(int nCtlID,CWnd* pParentWnd);

// Operations
public:
	//  Adds an image or a set of images to this control.
	int InsertImage(UINT nBitmapID, int cx = -1,COLORREF crMask = RGB(192,192,192));

	// Adds an image or a set of images to this control.
	int InsertImage(LPCTSTR lpszBitmapID, int cx = -1,	COLORREF crMask = RGB(192,192,192));

	// Adds an image or a set of images to this control.
	int InsertImage(CBitmap* pBitmap,COLORREF crMask = RGB(192,192,192));

	//  Returns the caption alignment.
	UINT GetCaptionAlign() const;

	//  Returns the image alignment.
	UINT GetImageAlign() const;

	//  Sets the caption alignment.
	void SetCaptionAlign(UINT nAlign);

	//  Sets the image alignment.
	void SetImageAlign(UINT nAlign);

	//  Sets the image border.
	void SetImageBorder(int cx);

	//  Sets the image spacing.
	void SetImageSpacing(int cx);
	
	//  Returns the number of images the control has.
	int GetImageCount() const;

	//  Determines if the control has any images.
	BOOL HasImages() const;

	//  Removes an image from this control.
	BOOL RemoveImage(int nImage);

// Overrides
public:
	//{{AFX_VIRTUAL(CFOImageStatic)
	//}}AFX_VIRTUAL
	virtual void OnDrawFace(CDC& dc, const CRect& rc, UINT uState);

	//  Called to position the image and caption.
	virtual void GetImageRect(CDC& dc, CRect rcButton,CRect& rcImage, CRect& rcCaption);

	// Get focus position.
	virtual void GetFaceRect(CDC& dc, CRect rcButton, CRect& rc,BOOL bSizeToContent);
	
	// Adjust size of control.
	virtual void AdjustSize(CDC& dc, CRect rc,CRect& rcImage, CRect& rcCaption);

	// Adjust size of control.
	virtual void AdjustSizeCentered(CDC& dc, CRect rc,CRect& rcImage, CRect& rcCaption);

// Implementation
public:
	virtual ~CFOImageStatic();

#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

// Generated message map functions
protected:
	//{{AFX_MSG(CFOImageStatic)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()


protected:
	// Space between images.
	int m_cxImageSpacing; 

	// Extra margin around image.
	int m_cxImageBorder; 

	UINT m_uImageAlign;

	UINT m_uCaptionAlign;

	CImageList m_images;

};
/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_FOIMAGESTATIC_H__02063CA3_04B5_11D6_A4F2_525400EA266C__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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
jack Mesic is the president of UCanCode Software Technology,Inc..

Comments and Discussions