MFC 常见问题

一 常见变量获得

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值