当前位置:网站首页>Course outline of market drawing 1- basic knowledge

Course outline of market drawing 1- basic knowledge

2022-06-13 05:09:00 HQChart

Course outline of market drawing 1- Basic knowledge of

canvas

HDC Canvas handle
Get canvas handle mode

  1. BeginPaint(), EndPaint(), Trigger InvalidateRect(), InvalidateRgn ()
    Corresponding MFC Of OnPaint()
    void UIBlockList::OnPaint()
    {
          
    	CPaintDC dc(this);
    	.......
    }
    
  2. GetDC(), ReleaseDC() Corresponding MFC CClientDC Before release , Unable to get at
  3. GetWindowDC(), ReleaseDC() Corresponding MFC CWindowDC Before release , Unable to get at

resources

All resources are used as handles , Use resources in the canvas through functions **SelectObject()** load resources . Generally, it is best to restore after use

HGDIOBJ obj = ::SelectObject(hDC,  Resource handle ); // Set up a resource , Returns the handle to the previous resource 
::MoveToEx(hDC, x1, y1, NULL);
::LineTo(hDC, x2, y2);
::SelectObject(hDC, obj);  // After use ,  Restore the resource to the last 

Resources are released using DeleteObject() , A macro is usually used , Release the resource and set the resource handle to null

#ifndef DELETE_OBJECT
#define DELETE_OBJECT(obj) if (obj) {
      ::DeleteObject(obj); obj=NULL; }
#endif

written words

HFONT Font handle
Create a function CreateFontIndirect(), CreateFont()
Corresponding MFC class CFont
Common functions
Set font color SetTextColor()
Draw text DrawText(), TextOut()
Calculate the length of the text GetTextExtentPoint32()
Set background color SetBkMode()

brush

HBRUSH Brush handle
Create a function CreateBrushIndirect, CreateSolidBrush
Corresponding MFC class CBrush
Common functions
SetDCBrushColor() Only change the color , There will be no new objects
Fill rectangular block FillRect()
Draw a rectangle Rectangle()
Rounded rectangle RoundRect()
The ellipse Ellipse()
The pie chart Pie()
Arc Arc()
Irregular figures Polygon()

paint brush

HPEN Brush handle , Used to draw line segments
Create a function CreatePenIndirect,CreatePen
Corresponding MFC class CPen
Common functions
SetDCPenColor() Change the color , There will be no new objects
MoveToEx, LineTo

Exercise one

 Insert picture description here
Draw the above figure on the canvas ,
Border around
Cut into pieces 4 A rectangle
The first 1 One is a parallel line ,45 Degree angle
The first 2 A rectangle , The space around is 10,
The first 3 Circle , The outer radius of the rectangle is 70%
The first 4 Two equilateral triangles
Give rectangle , round , Equilateral triangles are filled in red

原网站

版权声明
本文为[HQChart]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/164/202206130503274362.html