www.pudn.com > Image_Manage.rar > DlgHist.cpp
// DlgHist.cpp : implementation file
//
#include "stdafx.h"
#include "Image_Manage.h"
#include "DlgHist.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgHist dialog
CDlgHist::CDlgHist(CWnd* pParent /*=NULL*/)
: CDialog(CDlgHist::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgHist)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
for(int i=0;i<256;i++)
hist[i]=0;
}
void CDlgHist::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgHist)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgHist, CDialog)
//{{AFX_MSG_MAP(CDlgHist)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgHist message handlers
void CDlgHist::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
void CDlgHist::OnPaint()
{
CPaintDC dc(this); // device context for painting
// 定义刷子
CBrush brush;
// 定义画笔
CPen pen;
// 定义一个矩形
CRect rect;
int i;
CString txt;
// 得到客户区的大小
GetClientRect(&rect);
brush.CreateSolidBrush(RGB(255,255,255));
dc.SelectObject(&brush);
// 刷背景为白色
dc.Rectangle(rect);
brush.DeleteObject();
// 画坐标
pen.CreatePen(PS_SOLID,1,RGB(0,0,0));
dc.SelectObject(&pen);
//dc.MoveTo(80,274);
//dc.LineTo(80,20);
dc.MoveTo(76,270);
dc.LineTo(350,270);
dc.TextOut(75,280,"0");
dc.TextOut(40,264,"0 %");
for(i=0;i<10;i++)
{
dc.MoveTo(105+i*25,270);
dc.LineTo(105+i*25,274);
if((i+1)%2==0)
{
txt.Format("%d",(i+1)*25);
dc.TextOut(96+i*25,280,txt);
}
}
/*
for(i=0;i<50;i++)
{
dc.MoveTo(78,270-i*5);
dc.LineTo(80,270-i*5);
}
*/
for(i=0;i<256;i++)
{
dc.MoveTo(80+i,270);
dc.LineTo(80+i,270-hist[i]);
}
pen.DeleteObject();
// 画背景虚线
pen.CreatePen(PS_DASH,1,RGB(0,0,0));
dc.SelectObject(&pen);
for(i=0;i<5;i++)
{
dc.MoveTo(76,220-i*50);
dc.LineTo(350,220-i*50);
txt.Format("%d",i+1);
dc.TextOut(40,212-i*50,txt);
}
pen.DeleteObject();
}
BOOL CDlgHist::OnInitDialog()
{
CDialog::OnInitDialog();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}