Answered by:
Graphics in VC++

Question
-
Are there any suggested online resources for doing graphics work in VC++ in VS 2017 Community?
I see significant material for C# but nothing yet found for VC++ .... not surprised !One clue was
Don't create your own graphics for drawing -- use e->Graphics instead.
e->Graphics->DrawRectangle( ... );
where e-> is the PaintEventArgs object
TIA
Bob
Bob
Tuesday, January 15, 2019 12:37 AM
Answers
-
Hello,
I am glad you have got your solution, I would appreciate it if you mark them as answer and this will be beneficial to other community.
Your understanding and cooperation will be grateful.
Best Wishes,
Jack
MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
- Marked as answer by srfpala Thursday, January 17, 2019 7:39 AM
Wednesday, January 16, 2019 6:55 AM
All replies
-
Hello,
Thanks for posting here.
>>Are there any suggested online resources for doing graphics work in VC++ in VS 2017 Community?
I have create a WinForm by using C++/CLI, and add a picture box control to the Form,look like this:
In the picturebox paint function, seems that I could use the code what you have showed. Code like this:
private: System::Void pictureBox1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) { System::Drawing::Pen^ blackPen = gcnew System::Drawing::Pen(System::Drawing::Color::Black, 3); e->Graphics->DrawRectangle(blackPen, 20, 20, 100, 100); }
Test Result like this:
So I guess maybe you are talking about use Graphics class in C++/CLI. Here is the sample.
Hope these will help you.
Best Wishes,
Jack
MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
- Edited by Jack Zhang - AAA Tuesday, January 15, 2019 5:18 AM
- Proposed as answer by Guido Franzke Wednesday, January 16, 2019 7:05 AM
Tuesday, January 15, 2019 4:17 AM -
There are significant resources for graphics in Visual C++. But you tend to need to know what you are looking for since there is no real useful all in one reference available.
There is the documentation for the older Windows Controls library, menus and resources, the older GDI or GDI+. There is the documentation for Windows Imaging Components, Direct2D and Direct3D. Finally there is information on the DPI awareness in Windows.
To put it simply, the .NET languages use the native Win32 API to do the drawing, the CLR wraps it into a nice easier to use class. So if C# is capable of drawing, then you should be very surprised if there is no C++ way of doing it.
This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
- Edited by Darran Rowe Tuesday, January 15, 2019 5:41 AM
- Proposed as answer by Guido Franzke Wednesday, January 16, 2019 7:05 AM
Tuesday, January 15, 2019 5:40 AM -
Thanks to Jack and Darran.
Drawing example worked.
Much to learn.
BobBob
Tuesday, January 15, 2019 11:21 PM -
Hello,
I am glad you have got your solution, I would appreciate it if you mark them as answer and this will be beneficial to other community.
Your understanding and cooperation will be grateful.
Best Wishes,
Jack
MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
- Marked as answer by srfpala Thursday, January 17, 2019 7:39 AM
Wednesday, January 16, 2019 6:55 AM