#include <afxwin.h>
#include "Ruler.h"
CMyApp myApp;
/////////////////////////////////////////////////////////////////////////
// CMyApp member functions
BOOL CMyApp::InitInstance ()
{
m_pMainWnd = new CMainWindow;
m_pMainWnd->ShowWindow (m_nCmdShow);
m_pMainWnd->UpdateWindow ();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////
// CMainWindow message map and member functions
BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd)
ON_WM_PAINT ()
END_MESSAGE_MAP ()
CMainWindow::CMainWindow ()
{
Create (NULL, _T ("Ruler"));
}
void CMainWindow::OnPaint ()
{
CPaintDC dc (this);
//
// Initialize the device context.
//
dc.SetMapMode (MM_LOENGLISH);
dc.SetTextAlign (TA_CENTER | TA_BOTTOM);
dc.SetBkMode (TRANSPARENT);
//
// Draw the body of the ruler.
//
CBrush brush (RGB (255, 255, 0));
CBrush* pOldBrush = dc.SelectObject (&brush);
dc.Rectangle (100, -100, 1300, -200);
dc.SelectObject (pOldBrush);
//
// Draw the tick marks and labels.
//
for (int i=125; i<1300; i+=25) {
dc.MoveTo (i, -192);
dc.LineTo (i, -200);
}
for (i=150; i<1300; i+=50) {
dc.MoveTo (i, -184);
dc.LineTo (i, -200);
}
for (i=200; i<1300; i+=100) {
dc.MoveTo (i, -175);
dc.LineTo (i, -200);
CString string;
string.Format (_T ("%d"), (i / 100) - 1);
dc.TextOut (i, -175, string);
}
}
MFC Windows 程序设计绘制尺子Ruler
版权申诉
147 浏览量
2022-02-16
19:51:51
上传
评论
收藏 51KB ZIP 举报
五一编程
- 粉丝: 1w+
- 资源: 882
最新资源
- 基于python的机械设计实用计算器,可计算电动机,传动装置,V带轮,齿轮,轴,轴承的几何或者力,运动学参数数值+源码+开发文档
- 基于HTML +JavaScript的元旦倒计时代码.docx
- 【Unity资源免费分享】孩子益智小游戏unity 5x系列Baby Doll House Cleaning
- 【资源免费分享】集市游戏(uniyt案例)
- 数据整理结果 2023-12-7 192544 6.dta
- 5.22前端基础(2)
- 糖尿病风险因素分析数据
- matlab项目源码基于matlab的声源定位广义互相关算法的实现.zip
- 基于Go的Dory-Engine应用上云引擎命令行客户端设计源码
- dotnet-core-uninstall-1.7.521001 github上下载下来,从github下载不下来时,可以使用这
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈