Solved

Draw something

Posted on 2000-03-07
2
224 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

734 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