Solved

Draw something

Posted on 2000-03-07
2
223 Views
Last Modified: 2010-04-02
I have a dialog based application, I would like to draw something (say, a circle) in a given area on the dialog box(better) or on a new window as I click a "Draw" button on the dialog box. How to do it?
0
Comment
Question by:yingchunli
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Expert Comment

by:gelbert
ID: 2593418
You can create static control and handle WM_PAINT message. This message handler should implement painting of whatever you want.
So when user press "draw" button you can just call Invalidate() & UpdateWindow() with window handle of static control.
0
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
ID: 2593442
For windows?

You draw a circle using the Ellipse() function.  You will need to have a DC to draw in.  Usually you do this in the WM_PAINT message so you can get this DC from the BeginPaint() function.

Like

case WM_PAINT:
{
   PAINTSTRUCT PS;
    HDC DCHnd = BeginPaint(WndHnd,&PS);
    RECT CltRct;
    GetClientRect(WndHnd,&CltRct);
    Ellipse(DCHnd,CltRct.left, CltRct.top, CltRec.right, CltRct.bottom);
    EndPaint(WndHnd,&PS);
    break;
}

let me know if you have any questions
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C++ get user from AD  (VS6) 7 110
I could not build boost code, 10 114
object oriented programming comparison 5 93
keep track of class structure 1 52
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question