CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2001
    Posts
    65

    How can you set the position of a bitmap?

    Hi,

    I have a "continue" button attched to my scenery area for my game.

    There is a main image : "Image1".

    When I press the continue button, the scenery changes and the next set loads.

    But, the "Image1" stays in the same position on the screen as in Scenery1. How can I set the position of this bitmap (in a picture box) to somewhere from my screen. If possible could I attach the code the main scenery image, rather than the continue button as well?

    Thanks

    Mark


  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: How can you set the position of a bitmap?


    picture1.move(picture1.left+picture1.width)
    'or
    picture1.left = picture1.left+picture1.width



    'you can put this code in a timer event

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: How can you set the position of a bitmap?

    Yes, you can do so, but you'll have to use a temporary picturebox.
    Load the image into the (invisible) temporary picture box and then use PaintPicture to place this image anywhere on your main picturebox.

    For making the image clickable, there are two ways:

    If it's a rectangular button then you can simply check the coordinates in the Picture1_MouseDown event.

    If x > 10 and y > 10 and x < 100 and y < 50 then
    Do something

    This will be like clicking a rectangular hotspot defined by the rectangle (10,10)-(100,50)

    If it's an ellipse or any other complicated area, then you have to use the APIs CreateEllipticRgn, CreatePolygonRgn to define the clickable area and then use PtInRegion to check whether the clicked point is within the hotspot.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured