linestyle.cpp

来自「C++案」· C++ 代码 · 共 76 行

CPP
76 行
字号
// LineStyle.cpp : implementation file
//

#include "stdafx.h"
#include "Draw.h"
#include "LineStyle.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CLineStyle dialog


CLineStyle::CLineStyle(CWnd* pParent /*=NULL*/)
	: CDialog(CLineStyle::IDD, pParent)
{
	//{{AFX_DATA_INIT(CLineStyle)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CLineStyle::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CLineStyle)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CLineStyle, CDialog)
	//{{AFX_MSG_MAP(CLineStyle)
	ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLineStyle message handlers

void CLineStyle::OnSelchangeCombo1() 
{
	// TODO: Add your control notification handler code here
	CStatic *pic=(CStatic*)GetDlgItem(IDC_STATIC1);
	CRect rect;
	pic->GetClientRect(rect);
	CDC *dc=pic->GetDC();
	CPen newpen,*oldpen;
	CComboBox *com=(CComboBox*)GetDlgItem(IDC_COMBO1);
	index=com->GetCurSel();
	if (index==0)
	{
		newpen.CreatePen(PS_SOLID,1,RGB(255,0,0));
	}
	if (index==1)
	{
		newpen.CreatePen(PS_DASH,1,RGB(255,0,0));
	}
	if (index==2)
	{
		newpen.CreatePen(PS_DOT,1,RGB(255,0,0));
	}
	if (index==3)
	{
		newpen.CreatePen(4,1,RGB(255,0,0));
	}
	oldpen=dc->SelectObject(&newpen);
    dc->MoveTo(rect.left+3,rect.top+rect.Height()/2);
	dc->LineTo(rect.right-3,rect.top+rect.Height()/2);
	dc->SelectObject(oldpen);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?