资源简介
VC 实现窗口状态栏显示鼠标坐标信息的方法,这是个完整的代码实例 ,在VC6.0环境下可编译源代码并运行看效果,具体效果请参见测试截图。可在窗体的状态栏内显示设备坐标和逻辑坐标的X/Y信息,变量ID_SEPARATOR用来显示设备坐标系下的鼠标位置,ID_SEPARATOR用来显示逻辑坐标系下的鼠标位置。return m_bkBrush; 作为约定,返回背景色对应的刷子句柄。
代码片段和文件信息
// ChildView.cpp : implementation of the CChildView class
// download by http://www.codefans.net
#include “stdafx.h“
#include “color.h“
#include “ChildView.h“
#include “MainFrm.h“
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
int MyGlobal;
/////////////////////////////////////////////////////////////////////////////
// CChildView
CChildView::CChildView()
{
m_ptMouse = CPoint(00); // Initialize the m_ptMouse
}
CChildView::~CChildView()
{
}
BEGIN_MESSAGE_MAP(CChildViewCWnd )
//{{AFX_MSG_MAP(CChildView)
ON_WM_PAINT()
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChildView message handlers
BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs)
{
if (!CWnd::PreCreateWindow(cs))
return FALSE;
cs.dwExstyle |= WS_EX_CLIENTEDGE;
cs.style &= ~WS_BORDER;
cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS
::LoadCursor(NULL IDC_ARROW) HBRUSH(COLOR_WINDOW+1) NULL);
return TRUE;
}
void CChildView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Demonstrate how to access the global variable.
MyGlobal = 9999;
CColorApp * pApp = (CColorApp *)AfxGetApp();
pApp->MyGlobal = 8888;
// Display some prompt text.
dc.TextOut(2020“It demonstrates message relection of WM_CTLCOLOR. please see About Dialog “);
dc.TextOut(2040“It demonstrates the path of GDI.“);
dc.TextOut(2060“It demonstrates how to add a global variable.“);
dc.TextOut(2080“It demonstrates the MAP_MODE of GDI and displays the coordinate of mouse in status bar.“);
// I will draw a rectangle with a sin() edge.
dc.BeginPath();
CRect rectTemp(200200500400);
DrawSpecialRect(dc rectTemp);
dc.EndPath();
CBrush MyBrush (RGB(2550255));
CBrush * OldBrush = (CBrush *) dc.Selectobject(&MyBrush);
dc.StrokeAndFillPath();
dc.Selectobject(OldBrush);
// I will draw a cross line of new coordinate.
CRect rect;
GetClientRect(rect);
dc.MoveTo(0 rect.Height()/2);
dc.LineTo(rect.Width() rect.Height()/2);
dc.MoveTo(rect.Width()/2 0);
dc.LineTo(rect.Width()/2 rect.Height());
// Do not call CWnd::OnPaint() for painting messages
}
void CChildView::DrawSpecialRect(CPaintDC &dc CRect rect)
{
CPoint pt1 pt2 pt3 pt4;
pt1 = rect.TopLeft();
pt2 = pt1 + CSize(rect.Width() 0);
pt3 = rect.BottomRight();
pt4 = pt1 + CSize(0 rect.Height());
dc.MoveTo(pt1);
DrawSinLine(dc pt1 pt2);
dc.LineTo(pt3);
dc.LineTo(pt4);
dc.LineTo(pt1);
}
void CChildView::DrawSinLine(CPaintDC &dc CPoint pt1 CPoint pt2)
{
// Note: (pt1.y == pt2.y) && (pt2.x > pt1.x)
// I will draw the line with 1000 points in two circle of sin();
double step = double(pt2.x - pt1.x) / 1000;
double x y;
for (x = 0; x <= 1000; x++)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4221 2009-09-22 18:42 codesc.net\abbeyclrdemo\ChildView.cpp
文件 1563 2002-12-21 18:18 codesc.net\abbeyclrdemo\ChildView.h
文件 24084 2009-09-22 18:39 codesc.net\abbeyclrdemo\color.aps
文件 1963 2003-05-08 17:53 codesc.net\abbeyclrdemo\COLOR.CLW
文件 4615 2009-09-22 18:42 codesc.net\abbeyclrdemo\COLOR.CPP
文件 4464 2002-11-04 13:53 codesc.net\abbeyclrdemo\COLOR.DSP
文件 535 2002-08-31 16:41 codesc.net\abbeyclrdemo\COLOR.DSW
文件 1408 2009-09-22 18:42 codesc.net\abbeyclrdemo\COLOR.H
文件 8919 2002-12-15 20:14 codesc.net\abbeyclrdemo\COLOR.RC
文件 1097 2009-09-22 18:42 codesc.net\abbeyclrdemo\ColorEdit.cpp
文件 1151 2002-08-31 17:42 codesc.net\abbeyclrdemo\ColorEdit.h
文件 3068 2009-09-22 18:42 codesc.net\abbeyclrdemo\MainFrm.cpp
文件 1714 2002-12-21 17:20 codesc.net\abbeyclrdemo\MainFrm.h
文件 5494 2002-12-22 14:17 codesc.net\abbeyclrdemo\PROGRAM.TXT
文件 3534 2002-08-31 16:41 codesc.net\abbeyclrdemo\ReadMe.txt
文件 1078 2002-08-31 16:41 codesc.net\abbeyclrdemo\RES\COLOR.ICO
文件 397 2002-08-31 16:41 codesc.net\abbeyclrdemo\RES\COLOR.RC2
文件 682 2002-12-15 20:04 codesc.net\abbeyclrdemo\RESOURCE.H
文件 245 2009-09-22 18:42 codesc.net\abbeyclrdemo\StdAfx.cpp
文件 1111 2002-11-23 15:52 codesc.net\abbeyclrdemo\StdAfx.h
目录 0 2015-07-13 23:08 codesc.net\abbeyclrdemo\RES
目录 0 2015-07-13 23:08 codesc.net\abbeyclrdemo
目录 0 2015-07-13 23:08 codesc.net
----------- --------- ---------- ----- ----
71343 23
相关资源
- VC++基于OpenGL模拟的一个3维空间模型
- 基于VC++的SolidWorks二次开发SolidWorks
- VC6 USB开发源码
- VC操作SQLSERVER数据库
- aes加解密(vc源程序)
- vc_串口通讯
- 吕鑫vc6c++数据结构视频源码
- 派克变换VC++源码(附文档)
- 基于opencv漫水填充算法综合
- VC++ 串口
- VC++ 大富翁4_大富翁游戏源码
- MFC的异步网络通讯应用程序
- VC++ 摄像头视频采集与回放源程序
- 转 VC++ 实现电子邮件(Email)发送
- 基于MFC的VC++仿QQ浏览器源码(雏形)
- VC++ 服务程序编写及安装与卸载
- VC++6.0番茄西红柿VAXvirsual assist X完美破
- VC编程助手2010破解版(原名VA_X_10.6.
- 基于改进的fcm算法的图像分割vc++
- VC++6.0 绿色版,免安装,非常好用。
- Microsoft Visual C++ 2005 Redistributable Pack
- VC++MFC课程设计的学生成绩管理系统
- VC6查找与替换插件
- 大智慧365DLL插件设计
- Microsoft Visual C++ 2010 Redistributable Pack
- VC经典教程等chm格式学习资料包
- 基于VC、MATLAB的汽车制动性能仿真
- VC++6.0汉化包
- VC++完整商业界面源码(再上传)
- VC++编程技术600个大型项目源码.rar
评论
共有 条评论