一 常见变量获得

CDC * cDc=GetDC();

HDC m_Screenhdc = this->GetDC()->m_hDC;

//  整个窗口客户区的坐标

this->GetClientRect( &m_WndClientRect );

//  图元坐标编辑区的(即某一控件的窗口)

CWnd  m_pEditWnd = GetDlgItem(IDC_PIC_DOTEDIT);  /

/  图元坐标编辑区的相对于对话框的客户区的

Rect     m_editWndRect = getEditClientCoord();

//  图元坐标编辑区的自己的

Rect     m_pEditWnd->GetClientRect( &m_editRect );

//  图元坐标编辑区的DC  m_pEditDC=m_pEditWnd->GetDC();

//  图元坐标编辑区的Graphics  m_pEditGraphics = new Graphics( m_pEditDC->m_hDC );

CRect DlgSymbolEdit::getEditClientCoord()
{
 CRect rect;
 CWnd *pStrokeDis = GetDlgItem(IDC_PIC_DOTEDIT);
 pStrokeDis->GetWindowRect( &rect );
 //  从屏幕坐标转换成本地坐标
 ScreenToClient( rect );
 return rect;
}

二.DrawEdge()函数说明

void DlgSymbolEdit::OnPaint()
{

//再一次说明onpaint在onInitDialog之前运行,所以此处要给Rect等赋值。
 //  图元坐标编辑区的CWnd
 m_pEditWnd = GetDlgItem(IDC_PIC_DOTEDIT);
    //  图元坐标编辑区的自己的rect
    m_pEditWnd->GetClientRect( &m_editRect );
 //  图元坐标编辑区的DC
 m_pEditDC=m_pEditWnd->GetDC();
   m_editRect.left-=3;
   m_editRect.top-=3;
   m_editRect.bottom+=3;
   m_editRect.right+=3;
   //GetDC()->DrawEdge(&m_editRect,EDGE_SUNKEN, BF_RECT);//DrawEdge函数只能用要绘制的空间的CDC。此处用的整个对话框的CDC达不到预期效果。
   m_pEditDC->DrawEdge(&m_editRect,EDGE_SUNKEN, BF_RECT);

。。。。

}

下面是转的函数说明

CDC::DrawEdge函数

CDC::DrawEdge

BOOL DrawEdge( LPRECT lpRect, UINT nEdge, UINT nFlags );

DrawEdge函数自动调用系统相关颜色绘制!无法自行设置颜色!!

返回值

Nonzero if successful; otherwise 0.

如果成功,则返回非零值,否则为0。

参数说明

lpRect

A pointer to a RECT structure that contains the logical coordinates of the rectangle.

指向包含有逻辑坐标矩形的RECT结构的指针。

nEdge

Specifies the type of inner and outer edge to draw. This parameter must be a combination of one inner-border flag and one outer-border flag. See the Remarks section for a table of the parameter’s types.

指定矩形内外边界的类型。该参数是内边界标志和外边界标志的集合。请参阅说明中该参数的类型。

nFlags

The flags that specify the type of border to be drawn. See the Remarks section for a table of the parameter’s values:

指定绘制边界的类型,请参阅说明中该参数的类型。

备注

Call this member function to draw the edges of a rectangle of the specified type and style.

调用该成员函数,绘制指定风格和类型的矩形。

The inner and outer border flags are as follows:

内外边界标志如下:

  • Inner-border flags 内边界标志

    • BDR_RAISEDINNER   Raised inner edge.
      内边界凸出。
    • BDR_SUNKENINNER   Sunken inner edge.

    内边界凹下。

  • Outer-border flags外边界标志
    • BDR_RAISEDOUTER   Raised outer edge. 外边界凸出。
    • BDR_SUNKENOUTER   Sunken outer edge.

    外边界凹下

The nEdge parameter must be a combination of one inner and one outer border flag. The nEdge parameter can specify one of the following flags:

参数必须是内边界标志和外边界标志的组合。可以为以下值之一:

  • EDGE_BUMP   Combination of BDR_RAISEDOUTER and BDR_SUNKENINNER.
  • EDGE_ETCHED   Combination of BDR_SUNKENOUTER and BDR_RAISEDINNER.
  • EDGE_RAISED   Combination of BDR_RAISEDOUTER and BDR_RAISEDINNER.
  • EDGE_SUNKEN   Combination of BDR_SUNKENOUTER and BDR_SUNKENINNER.

The nFlags parameter types are as follows:

NFlags参数的类型如下:

  • BF_RECT   Entire border rectangle.
    矩形的四周边界。
  • BF_LEFT   Left side of border rectangle.
    矩形的左边界。
  • BF_BOTTOM   Bottom of border rectangle.
    矩形的底部边界
  • BF_RIGHT   Right side of border rectangle.
    矩形的右边界。
  • BF_TOP   Top of border rectangle.
    矩形的顶部边界。
  • BF_TOPLEFT   Top and left side of border rectangle.
    矩形的左、底部边界。
  • BF_TOPRIGHT   Top and right side of border rectangle.
    矩形的右、顶部边界。
  • BF_BOTTOMLEFT   Bottom and left side of border rectangle.
    矩形的左、底部边界。
  • BF_BOTTOMRIGHT   Bottom and right side of border rectangle.

矩形的右、底部边界。

For diagonal lines, the BF_RECT flags specify the end point of the vector bounded by the rectangle parameter.

对于对角线,BF_RECT标志指定了矢量终点:

  • BF_DIAGONAL_ENDBOTTOMLEFT   Diagonal border. The end point is the bottom-left corner of the rectangle; the origin is top-right corner.
    BF_DIAGONAL_ENDBOTTOMLEFT 对角线边界。终点为矩形的左下角,始点为右上角。
  • BF_DIAGONAL_ENDBOTTOMRIGHT   Diagonal border. The end point is the bottom-right corner of the rectangle; the origin is top-left corner.
    BF_DIAGONAL_ENDBOTTOMRIGHT 对角线边界。终点为矩形的右下角,始点为左下角。
  • BF_DIAGONAL_ENDTOPLEFT   Diagonal border. The end point is the top-left corner of the rectangle; the origin is bottom-right corner.
    BF_DIAGONAL_ENDTOPLEFT 对角线边界。终点为矩形的左上角,始点为右下角。
  • BF_DIAGONAL_ENDTOPRIGHT   Diagonal border. The end point is the top-right corner of the rectangle; the origin is bottom-left corner.
    BF_DIAGONAL_ENDTOPRIGHT 对角线边界。终点为矩形的右上角,始点为左下角。

For more information about the Windows API DrawEdge, see ::DrawEdge in the Win32 SDK Programmer’s Reference.

MFC 常见问题的更多相关文章

  1. MFC常见问题解惑

    MFC类的分类 1 Root: CObject : CObject2 Application Architecture Classes: CWinApp/CFrameWnd/... 3 Window, ...

  2. MFC常见问题以及解决方法(2)_Cstring和string互相转换

    MFC默认编码是unicode(自己改成多字符集是不行的),对话框中对字符串的处理都是宽字符,而且添加变量会默认是CString类型,当你代码中想用string但又遇到必须转为CString的情况,就 ...

  3. MFC常见问题以及解决方法(1)_MFC下文本编辑框按下回车后窗口退出

    这里主要介绍遇到这种方法的解决方案,解决方法可能有多种,但这里只给出有效的一种,这里不会详细说明出现问题的原因以及为什么这样解决,想了解更多可以百度,写这个主要是防止以后忘记,做个简单的笔记. 问题: ...

  4. MFC常见问题总结

    1. c++中的函数前面加个LRESULT是什么意思啊?在微软vc提供的头文件中有定义在winnt.h中typedef long LONG;在windef.h中typedef LONG LRESULT ...

  5. VC++学习之VC中常见问题

    VC++学习之VC中常见问题 (1)为什么某个类突然在工作区间里面突然看不见了? 只是类隐藏了,打开FILEVIEW,找到隐藏类的头文件,随便敲一下键盘的空格键,类就会在CLASSVIEW中显示了 ( ...

  6. MFC控件CTabCtrl关联变量

    1.先建立一个对话框MFC应用程序,然后在工具箱里面把Tab Control控件放到对话框中的合适位置上. 再在对话框类中,将该控件绑定一个变量 用两种方法: 1 ) 自己定义成员变量 CTabCtr ...

  7. 【MFC】MFC绘图不闪烁——双缓冲技术

    MFC绘图不闪烁——双缓冲技术[转] 2010-04-30 09:33:33|  分类: VC|举报|字号 订阅 [转自:http://blog.163.com/yuanlong_zheng@126/ ...

  8. 非MFC工程中使用MFC库

    目录(?)[-] 需求说明 常见问题 问题分析 参考解决方法 我的解决方案 Stdafxh的原理   需求说明 C++工程的类型有很多,从VS(或VC)可以看到常见的有:Win32 Console A ...

  9. MFC中的双缓冲技术(解决绘图闪烁问题)

    转自 MFC绘图不闪烁——双缓冲技术[转] 在VC/MFC用CDC绘图时,频繁的刷新,屏幕会出现闪烁的现象,CPU时间占用率相当高,绘图效率极低,很容易出现程序崩溃. 所谓双缓冲技术,下面是百度百科的 ...

随机推荐

  1. CentOS 6.x安装配置MongoDB 3.4.x

    说明: 操作系统:CentOS 5.X 64位 IP地址:192.168.21.128 实现目的: 安装配置MongoDB数据库 具体操作: 一.关闭SElinux.配置防火墙 1.vi /etc/s ...

  2. mothur trim.seqs 去除PCR引物

    trim.seqs 有以下几个主要应用: 1)根据barcode 拆分序列: 2)去除PCR引物 3) 去除低质量序列 trim.seqs 在使用时必须输入一个fasta 格式的序列,然后在加至少一个 ...

  3. VS2015 applicationhost.config 本地域名访问

    .vs\config\applicationhost.config <?xml version="1.0" encoding="UTF-8"?> & ...

  4. C# 最小化到托盘,托盘右击菜单显示

    添加notifyIcon控件,并添加Icon,否则托盘没有图标(托盘右键菜单也可直接在属性里添加): 主要的代码: public partial class Form1 : Form { #regio ...

  5. tf.variable_scope

    转载:https://blog.csdn.net/gaoyueace/article/details/79079068 例如: #在名字为ae的命名空间内创建变量 with tf.variable_s ...

  6. glibc中fork系统调用传参

    因为想跟踪下在新建进程时,如何处理新建进程的vruntime,所以跟踪了下fork. 以glic-2.17中ARM为例(unicore架构的没找到),实际上通过寄存器向系统调用传递的参数为: r7: ...

  7. DEFINE_PER_CPU,如何实现“数组”

    引述自:http://www.unixresources.net/linux/clf/linuxK/archive/00/00/47/91/479165.html Kevin.Liu 的<调度器 ...

  8. Python集成开发环境PyCharm调试

    Run/Debug配置: 设置断点:在行号后单击(再单击取消) 启动调试:Shift+F9 单步执行:F8 进入函数:F7 跳出函数:Shift+F8 运行到下一个断点:F9 调试中查看: 退出调试: ...

  9. hibernate 之 sql查询

    如果用hibernate执行原生sql进行数据查询可以调用 SQLQuery query = getSession().createSQLQuery(sql); 然后再执行 query.list() ...

  10. SpringBoot------集成PageHelper分页功能

    添加MyBatis的代码,地址 https://www.cnblogs.com/tianhengblogs/p/9537665.html 修改以下部分: 1.添加MyBatisConfig packa ...