954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Visual C++

Using Dialog Box:

I want to draw a ball in a solid color and be able to move the ball around on the Dialog Box.

Thanks

lyar1977
Newbie Poster
1 post since Mar 2003
Reputation Points: 10
Solved Threads: 0
 

There's different ways to do this. How do you want to do it? You can do it quickly with dialog wizards or code it from scratch. This sounds like a class assignment. You have to be more specific.

samaru
a.k.a inscissor
Team Colleague
1,256 posts since Feb 2002
Reputation Points: 262
Solved Threads: 18
 
Using Dialog Box: I want to draw a ball in a solid color and be able to move the ball around on the Dialog Box.

Simplest way I can think of would be to set up a timer and update the coordinates of the ball in it. Call InvalidateRect and UpdateWindow to force an update of the screen.

Override the OnPaint message handler for your dialog. Draw your ball in there using the device context pointer provided.

evenstar
Newbie Poster
2 posts since May 2003
Reputation Points: 10
Solved Threads: 0
 

I think what it seems to me that he wants is to associate the moving object (the ball) with a keyboard or mouse control.

cscgal
The Queen of DaniWeb
Administrator
19,422 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 230
 

I've coded a simple program that lets the user control the position of a ball via the arrow keys.

[img]http://www.abdn.ac.uk/~u02cll2/windowsapi/movingball.jpg[/img]

The program can be downloaded here .

The source code can be viewed in HTML format here .

Dante Shamest
Light Poster
46 posts since Apr 2003
Reputation Points: 13
Solved Threads: 0
 

You got too much time on your hands. ;)

samaru
a.k.a inscissor
Team Colleague
1,256 posts since Feb 2002
Reputation Points: 262
Solved Threads: 18
 

Nah, it was good practice. :D

Dante Shamest
Light Poster
46 posts since Apr 2003
Reputation Points: 13
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You