Some minor issues with this program

This is a discussion on Some minor issues with this program within the Windows Programming forums, part of the Platform Specific Boards category; Hi all I am currently working on this program (as attached) and would appreciate if anyone could advice me on ...

  1. #1
    Beginner
    Join Date
    Oct 2003
    Posts
    8

    Question Some minor issues with this program

    Hi all

    I am currently working on this program (as attached) and would appreciate if anyone could advice me on some of the issues.

    This program actually allows you to control the movement of the ball (bitmap) by using timers. It consists of a control panel that enables you to control the ball movement direction and speed.

    Some issues faced are:
    1) When I click on start/stop, minimize the main window and restore it, the bitmap is gone.

    2) When the control panel moves over the bitmap, it disappears.

    3) Hot-keys doesn't work with the control panel (IE: on keypress "w", the ball should move upwards direction etc).

    4) How can I center the bitmap on launching the application? (I have tried to put it on the onCreate() handler but when the main window is maximize, it doesn't seem proportion).

    Thanks in advance
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    Sep 2004
    Posts
    3
    1. + 2. You need to redraw the bitmap on the WM_PAINT message.

    3. I didn't look at the source code but are you sure you are looking at the message correctly in wparam?

    4. make a simple algorithm from the client rect and do the (top - bottom) / 2 and (left - right) / 2 then place the bitmap there.

  3. #3
    Beginner
    Join Date
    Oct 2003
    Posts
    8
    You mean I need to do a InvalidateRect(NULL); under WM_PAINT message?

    For point 3, yes, I think I placed the message correctly... just that I removed it because it wasn't working... you have to place it again to test.

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    >>> onCreate() handler

    Smells like MFC, if you are using MFC you should say so. Most people in here use the API and a lot of the API functions are wrapped up in MFC classes and don't work in the same way, or even take the same parameters.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  5. #5
    Beginner
    Join Date
    Oct 2003
    Posts
    8
    Oh. So sorry about being unclear. Didn't know about it Yes, I'm using MFC (Visual Studio 6).

    Any solutions/suggestions?

  6. #6
    Beginner
    Join Date
    Oct 2003
    Posts
    8
    Ah, managed to solve the problems on my own.

    For those who are interested, here's now it can be done.

    In the OnTimer() event, replace DrawBall() with InvalidateRect(NULL,TRUE);

    In the OnPaint() event, call the DrawBall() function. In this way, the ball will always be repainted.

    That's all. Thanks for those whom have helped Appreciate it very much.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 12:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 12:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 09:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21