CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    May 2007
    Posts
    5

    Moving two images..?!

    is it possible to actual have two different keydown events such as A to move one picture and left to move another. so holding down A and left will move both pictures...

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Moving two images..?!

    Quote Originally Posted by Phoenixium
    is it possible to actual have two different keydown events such as A to move one picture and left to move another. so holding down A and left will move both pictures...
    Welcome to the Forum

    No it is not possible.

  3. #3
    Join Date
    May 2007
    Posts
    5

    Re: Moving two images..?!

    Quote Originally Posted by Shuja Ali
    Welcome to the Forum

    No it is not possible.
    nice warming welcome ^_^

    ok thanks

  4. #4
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Moving two images..?!

    Actually the KeyPress/KeyDown events will fire the moment you press A. You can't press both the keys at the same time, there will be a delay between the key presses.

    If what I understood your first post correctly, you want both the pictures to move the moment user presses A and Left Button. Right?

  5. #5
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Moving two images..?!

    Quote Originally Posted by Shuja Ali
    Welcome to the Forum

    No it is not possible.
    Lol Shuja ...

    Nice one...

    Well if your looking to have the images move while a key is pressed, and stops when the key is released..

    It can be done with a Timer....

    In keydown you set a boolean "True" and keyup you set the Boolean "False" ..

    and in the timer event you check the boolean and move the images accordingly...

    Check out Crop/Zoom image thread for a example of using timers

    Gremmy....
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  6. #6
    Join Date
    May 2007
    Posts
    5

    Re: Moving two images..?!

    hmm... could do, seems easier that way.

  7. #7
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Moving two images..?!

    Well i was a bit bored today and decided to tackle this question with a small demo...

    Fire it up, select the method of movement, (continous or auto stop)..
    and start pressing keys..

    Just something to note.. the keyboard cant always handle more than 3 keys press simultaniously, Depending on the scanline you can sometimes get 4 or 5, but generaly it's around 3...

    Also when using continous the centre keys, "S" and "J" stop them...

    Then because you cant move up and down at the same time i used a custom TriState variable for up/stop/down and left/stop/right ....

    enjoy...

    Gremmy....
    Attached Files Attached Files
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  8. #8
    Join Date
    May 2007
    Posts
    5

    Re: Moving two images..?!

    i must say its quite impressive no idea what that Enum is just looking into it now ^_^

  9. #9
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Moving two images..?!

    Enum is used to create you own data types...
    Like boolean is a datatype and can be described with enum as such
    Code:
    Enum Boolean
        True
        False
    End Enum
    Also usig a Enum (Enumerated) variable is handy as it is called up in intelisence..

    Gremmy
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

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