can we draw shapes (line,circle , etc.) in dialog-based mfc visual studio 2010?
I want to implement an oscilloscop开发者_开发问答e to display some different frequency via dialog-based MFC visual c++, but as I googling too much , I found out that the only way to drawing shapes in visual c++ is to use SDI or MDI ! I want to know if there is a way to drawing my frequency chart by dialog-based mfc. if anyone know any reference , I really appreciate it if he/she introduce it to me .
Yes you can draw in dialogs with MFC.
In short, drop a "static" (or image, I'm not certain) resource on the dialog, override/derive the class and handle the WM_PAINT message to draw the graph/oscilloscope.
have a look at http://www.codeproject.com/KB/miscctrl/High-speedCharting.aspx for an excellent example.
you can draw onto anything using GDI, you can even implement a custom control for your oscilloscope if you plan on reusing it, else you can just use a static/picture frame to act as a container.
for something that can have many updates, like an oscilloscope, you'd probably need to double buffer the surface you draw on, else you'll get tearing. a short overview of using GDI can be found here.
MFC has its own equivalents of the GDI data structures and functions, see this.
精彩评论