资源简介
学习C++和MFC的时候用VC6.0写的一个画图的demo小程序,主要总结一下MFC最基础的语法,实现了画线条,矩形,椭圆以及颜色,线条粗细,线条类型的设置 和 文字的输出、界面回车保存,字体设置,光标位置调整等,新学习MFC的童鞋可以看看。

代码片段和文件信息
#include “stdafx.h“
#include “BtnST.h“
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CButtonST
CButtonST::CButtonST()
{
m_MouseOnButton = FALSE;
m_hIconIn = NULL;
m_hIconOut = NULL;
m_cxIcon = 0;
m_cyIcon = 0;
m_hCursor = NULL;
// Default type is “flat“ button
m_bIsFlat = TRUE;
// By default draw border in “flat“ button
m_bDrawBorder = TRUE;
// By default icon is aligned horizontally
m_nAlign = ST_ALIGN_HORIZ;
// By default show the text button
m_bShowText = TRUE;
// By default for “flat“ button don‘t draw the focus rect
m_bDrawFlatFocus = FALSE;
// By default the button is not the default button
m_bIsDefault = FALSE;
SetDefaultInactiveBgColor();
SetDefaultInactiveFgColor();
SetDefaultActiveBgColor();
SetDefaultActiveFgColor();
// No tooltip created
m_ToolTip.m_hWnd = NULL;
// Do not draw as a transparent button
m_bDrawTransparent = FALSE;
m_pbmpOldBk = NULL;
} // End of CButtonST
CButtonST::~CButtonST()
{
// Restore old bitmap (if any)
if (m_dcBk.m_hDC != NULL && m_pbmpOldBk != NULL)
{
m_dcBk.Selectobject(m_pbmpOldBk);
}
// Destroy the icons (if any)
// Note: the following two lines MUST be here! even if
// BoundChecker says they are unnecessary!
if (m_hIconIn != NULL) ::DestroyIcon(m_hIconIn);
if (m_hIconOut != NULL) ::DestroyIcon(m_hIconOut);
// Destroy the cursor (if any)
if (m_hCursor != NULL) ::DestroyCursor(m_hCursor);
} // End of ~CButtonST
BEGIN_MESSAGE_MAP(CButtonST CButton)
//{{AFX_MSG_MAP(CButtonST)
ON_WM_CAPTURECHANGED()
ON_WM_SETCURSOR()
ON_WM_KILLFOCUS()
ON_WM_MOUSEMOVE()
ON_WM_CTLCOLOR_REFLECT()
ON_WM_SYSCOLORCHANGE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CButtonST::SetIcon(int nIconInId int nIconOutId)
{
HICON hIconIn;
HICON hIconOut;
HINSTANCE hInstResource = AfxFindResourceHandle(MAKEINTRESOURCE(nIconInId) RT_GROUP_ICON);
// Set icon when the mouse is IN the button
hIconIn = (HICON)::LoadImage(hInstResource/*AfxGetApp()->m_hInstance*/ MAKEINTRESOURCE(nIconInId) IMAGE_ICON 0 0 0);
// Set icon when the mouse is OUT the button
hIconOut = (nIconOutId == NULL) ? NULL : (HICON)::LoadImage(hInstResource/*AfxGetApp()->m_hInstance*/ MAKEINTRESOURCE(nIconOutId) IMAGE_ICON 0 0 0);
SetIcon(hIconIn hIconOut);
/*
// Note: the following two lines MUST be here! even if
// BoundChecker says they are unnecessary!
if (m_hIconIn != NULL) ::DestroyIcon(m_hIconIn);
if (m_hIconOut != NULL) ::DestroyIcon(m_hIconOut);
// Set icon when the mouse is IN the button
m_hIconIn = (HICON)::LoadImage(hInstResource MAKEINTRESOURCE(nIconInId) IMAGE_ICON 0 0 0);
// Set icon when the mouse is OUT the button
m_hIconOut = (nIconOutId == NULL) ? m_hIconIn : (HICON)::LoadImage(hInstResource MAKEINTRESOURCE(n
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 22197 2001-07-17 16:37 Graphic\BtnST.cpp
文件 6589 2001-08-02 16:21 Graphic\BtnST.h
文件 55508 2017-08-16 09:40 Graphic\Debug\BtnST.obj
文件 0 2017-08-16 09:43 Graphic\Debug\BtnST.sbr
文件 5209 2017-08-15 13:54 Graphic\Debug\Graph.obj
文件 0 2017-08-15 13:54 Graphic\Debug\Graph.sbr
文件 3728384 2017-08-17 16:21 Graphic\Debug\Graphic.bsc
文件 5054564 2017-08-17 16:21 Graphic\Debug\Graphic.exe
文件 3825588 2017-08-17 16:21 Graphic\Debug\Graphic.ilk
文件 22172 2017-08-17 16:08 Graphic\Debug\Graphic.obj
文件 6910680 2017-08-15 13:54 Graphic\Debug\Graphic.pch
文件 4285440 2017-08-17 16:21 Graphic\Debug\Graphic.pdb
文件 2374748 2017-08-17 10:12 Graphic\Debug\Graphic.res
文件 0 2017-08-17 16:08 Graphic\Debug\Graphic.sbr
文件 13935 2017-08-15 13:54 Graphic\Debug\GraphicDoc.obj
文件 0 2017-08-15 13:54 Graphic\Debug\GraphicDoc.sbr
文件 59109 2017-08-17 16:21 Graphic\Debug\GraphicView.obj
文件 0 2017-08-17 16:21 Graphic\Debug\GraphicView.sbr
文件 20942 2017-08-17 09:56 Graphic\Debug\MainFrm.obj
文件 0 2017-08-17 09:56 Graphic\Debug\MainFrm.sbr
文件 21981 2017-08-16 09:55 Graphic\Debug\SettingDlg.obj
文件 0 2017-08-16 09:55 Graphic\Debug\SettingDlg.sbr
文件 105967 2017-08-15 13:54 Graphic\Debug\StdAfx.obj
文件 1364538 2017-08-15 13:54 Graphic\Debug\StdAfx.sbr
文件 12841 2017-08-16 09:40 Graphic\Debug\SXBtn.obj
文件 0 2017-08-16 09:43 Graphic\Debug\SXBtn.sbr
文件 11613 2017-08-15 13:54 Graphic\Debug\TestBtn.obj
文件 0 2017-08-15 13:54 Graphic\Debug\TestBtn.sbr
文件 238592 2017-08-17 16:21 Graphic\Debug\vc60.idb
文件 405504 2017-08-17 16:21 Graphic\Debug\vc60.pdb
............此处省略39个文件信息
相关资源
- C++获取计算机的CPU ID,硬盘序列号等
- C++头文件转delphi工具 + 源码
- 基于MFC的TCP调试助手源码95706
- 国际象棋的qt源代码
- C++中头文件与源文件的作用详解
- 基于mfc的多线程文件传输
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- MFC数字钟(基于VC6.0)
- 安科瑞智能电能表MODBUS通讯程序 VC6
- VC++MFC小游戏实例教程(实例)+MFC类库
- VC6LineNumberAddin.dll
- 用VC6.0实现多边形扫描线填充算法
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- VC助手 VC6.0助手
- c++素数筛选法
- C++ mqtt 用法
- ChartCtrl控件库(可在VS2019中使用)
- 商品库存管理系统 C++ MFC
评论
共有 条评论