Thread: moving/icons/bitmaps

  1. #1
    Registered User canine's Avatar
    Join Date
    Sep 2001
    Posts
    125

    moving/icons/bitmaps

    this is sort of a long question or at least requires a long awnser sorry, but at first how can i get an icon on the screen get it to move around with the arrow keys and or how can i do the same with a bitmap. I have an idea but it doesent work making a code example most relevant.
    Its asking a lot for an awnser to this thanx in advance
    In a perfect world every dog would have a home and every home would have a dog.
    Visit My Web Site, Canine Programming
    I use Win32 API

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793

    Re: moving/icons/bitmaps

    Originally posted by canine
    this is sort of a long question or at least requires a long awnser sorry, but at first how can i get an icon on the screen get it to move around with the arrow keys and or how can i do the same with a bitmap. I have an idea but it doesent work making a code example most relevant.
    Its asking a lot for an awnser to this thanx in advance
    One idea....

    You could create a standard child window and have its WM_PAINT paint the icon onto itself.....the when an arrow key is pressed, move the windows with SetWindowPos()...

  3. #3
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    As an alternative to Fordy's fine suggestion you may wish to look at DrawIcon to move your icon about. For bitmaps, try BitBlt. Both functions take x,y (pixel) co-ordinates as arguments/parameters so you could set up variables to hold these and increment or decrement these variables according to key presses. Handle WM_KEYDOWN to trap keyboard input and force a window repaint by using InvalidateRect on the bounding rectangle of your image. All drawing should ideally be performed in your WM_PAINT handler.

    Hope that helps some.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  4. #4
    canine
    Guest
    this might be a dumb qeustion but how can i have a child window have its own wm_paint and is it neccesary to paint it in its own WM_PAINT not just the main window's WM_PAINT?

  5. #5
    Registered User canine's Avatar
    Join Date
    Sep 2001
    Posts
    125
    uh that last post was me i wasn't logged in
    In a perfect world every dog would have a home and every home would have a dog.
    Visit My Web Site, Canine Programming
    I use Win32 API

  6. #6
    canine
    Guest
    wait what do you mean by a standard child window AND how could i have that child window
    have its own WM_PAINT message?

  7. #7
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by canine
    wait what do you mean by a standard child window AND how could i have that child window
    have its own WM_PAINT message?
    You could subclass with SetWindowLong.......but looking at at I dont know why I suggested it....Ken's suggestion is 10 * better and 10 * easier

  8. #8
    canine
    Guest
    uh is it really im having trouble printing icons and bimaps in general and when you recall it to make another one will it work AND will you have to erase the first one?

  9. #9
    "The Oldest Member Here" Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,039
    simply draw one large one as big as the window, like a background, and draw your sprites in the front. that way, there will never be trails of the image when you move your sprites

  10. #10
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346
    You might find some answers at The Forgers API tutorial:
    http://www.winprog.org/tutorial/index.html

    I believe he has an animation section.

    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

Popular pages Recent additions subscribe to a feed