Computer Graphics First

Source: Internet
Author: User

--------------------Configuration:penbrush-win32 Debug--------------------
Compiling ...
PenBrushView.cpp
D:\Program Files (x86) \microsoft Visual Studio\myprojects\penbrush\penbrushview.cpp (4): fatal error C1083:cannot open p Recompiled header file: ' debug/penbrush.pch ': No such file or directory
Error executing cl.exe.

Penbrushview.obj-1 error (s), 0 warning (s)
A: When pressing F4, error location to # include "stdafx.h"; workaround "This is a compile-time error, can be temporarily regardless of this error, continue to link, you can find the link is correct, as follows
--------------------Configuration:penbrush-win32 Debug--------------------
Compiling resources ...
Compiling ...
StdAfx.cpp
Compiling ...
PenBrush.cpp
MainFrm.cpp
PenBrushDoc.cpp
PenBrushView.cpp
Generating Code ...
Linking ...

penbrush.exe-0 error (s), 0 warning (s)
And then we're going to compile this project again.
--------------------Configuration:penbrush-win32 Debug--------------------
Compiling ...
Skipping ... (No relevant changes detected)
PenBrushView.cpp

penbrushview.obj-0 error (s), 0 warning (s)
You can see the previous reported errors disappear. Then link again to get
--------------------Configuration:penbrush-win32 Debug--------------------
Linking ...

penbrush.exe-0 error (s), 0 warning (s)
This will solve the problem.
Code section
CRect rect;
GetClientRect (rect);
PDC->setmapmode (mm_anisotropic);
PDC->setwindowext (rect. Width (), Rect. Height ());
PDC->setviewportext (rect. Width (),-rect. Height ());
PDC->setviewportorg (rect. Width ()/2, Rect. Height ()/2);

Rect. Offsetrect (-rect. Width ()/2,-rect. Height ()/2);
Rect. Deflaterect (100, 100);

CPen Newpen, *poldpen;
Newpen.createpen (Ps_solid, 1, RGB (0, 0, 255));
Poldpen = PDC->selectobject (&newpen);

CBrush Newbrush, *poldbrush;
Newbrush.createsolidbrush (RGB (255, 0, 0));
Poldbrush = PDC->selectobject (&newbrush);

PDC->rectangle (&rect);
PDC->selectobject (Poldpen);
PDC->selectobject (Poldbrush);

Code 1
CRect rect;
GetClientRect (rect);
PDC->setmapmode (mm_anisotropic);
PDC->setwindowext (rect. Width (), Rect. Height ());
PDC->setviewportext (rect. Width (),-rect. Height ());
PDC->setviewportorg (rect. Width ()/2, Rect. Height ()/2);
PDC->rectangle (rect);
The resulting rectangle is displayed in the first quadrant, and only a portion of it is shown (lower left corner)

Code 2
CRect rect;
GetClientRect (rect);
PDC->setmapmode (mm_anisotropic);
PDC->setwindowext (rect. Width (), Rect. Height ());
PDC->setviewportext (rect. Width (),-rect. Height ());
PDC->setviewportorg (rect. Width ()/2, Rect. Height ()/2);

Rect. Offsetrect (-rect. Width ()/2,-rect. Height ()/2);

CPen Newpen, *poldpen;
Newpen.createpen (Ps_solid, 1, RGB (0, 0, 255));
Poldpen = PDC->selectobject (&newpen);

PDC->rectangle (rect);
The resulting rectangle will be the extent of the view area.

Code 3
CRect rect;
GetClientRect (rect);
PDC->setmapmode (mm_anisotropic);
PDC->setwindowext (rect. Width (), Rect. Height ());
PDC->setviewportext (rect. Width (),-rect. Height ());
PDC->setviewportorg (rect. Width ()/2, Rect. Height ()/2);

Rect. Offsetrect (-rect. Width ()/2,-rect. Height ()/2);
Rect. Deflaterect (100, 100);

CPen Newpen, *poldpen;
Newpen.createpen (Ps_solid, 1, RGB (0, 0, 255));
Poldpen = PDC->selectobject (&newpen);

PDC->rectangle (rect);
Then the rectangle will shrink to the center

Back to the original code section
There's this piece of code in there.
CPen Newpen, *poldpen;
Newpen.createpen (Ps_solid, 1, RGB (0, 0, 255));
Poldpen = PDC->selectobject (&newpen);

CBrush Newbrush, *poldbrush;
Newbrush.createsolidbrush (RGB (255, 0, 0));
Poldbrush = PDC->selectobject (&newbrush);
Know that it is creating brushes and brushes and selecting them into the device context
And then when you draw the
PDC->rectangle (&rect);
You can see that there are no color parameters in the inside; Pen is used to draw lines, brush is used to fill, and when the user does not create brushes and brushes is the "black pen white brush".
In this way, the graph will be overwritten, and the underlying will be overwritten by the upper layer later.
The following code can explain the situation
CRect rect;
GetClientRect (rect);
PDC->setmapmode (mm_anisotropic);
PDC->setwindowext (rect. Width (), Rect. Height ());
PDC->setviewportext (rect. Width (),-rect. Height ());
PDC->setviewportorg (rect. Width ()/2, Rect. Height ()/2);

Rect. Offsetrect (-rect. Width ()/2,-rect. Height ()/2);
Rect. Deflaterect (100, 100);

CPen Newpen, *poldpen;
Newpen.createpen (Ps_solid, 1, RGB (0, 0, 255));
Poldpen = PDC->selectobject (&newpen);

PDC->rectangle (rect);

CBrush Newbrush, *poldbrush;
Newbrush.createsolidbrush (RGB (255, 0, 0));
Poldbrush = PDC->selectobject (&newbrush);

PDC->roundrect (Rect, CPoint (50, 50));

PDC->selectobject (Poldpen);
PDC->selectobject (Poldbrush);
Here the first rectangle is "blue-edged white flour", and then painted the obtuse rectangle is "blue side red face."

Computer Graphics First

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.