⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linewid.cpp

📁 C++案
💻 CPP
字号:
// LineWid.cpp : implementation file
//

#include "stdafx.h"
#include "Draw.h"
#include "LineWid.h"

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

/////////////////////////////////////////////////////////////////////////////
// CLineWid dialog


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


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


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

/////////////////////////////////////////////////////////////////////////////
// CLineWid message handlers

void CLineWid::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);
	int index=com->GetCurSel();
	if (index==0)
	{
		newpen.CreatePen(PS_SOLID,1,RGB(255,0,0));
		width=1;
	}
	if (index==1)
	{
		newpen.CreatePen(PS_SOLID,2,RGB(255,0,0));
		width=2;
	}
	if (index==2)
	{
		newpen.CreatePen(PS_SOLID,3,RGB(255,0,0));
		width=3;
	}
	if (index==3)
	{
		newpen.CreatePen(PS_SOLID,4,RGB(255,0,0));
		width=4;
	}
	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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -