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

    VC++ key down event help

    hi im trying 2 move a picturebox in VC++ with my arrow keys i know its keydown event i want to use and well i cant seem to get it working ive tried alot all i can think of that is

    this is pretty much what i have its basically what ive been playing with

    private:
    void pictureBox1_KeyDown( Object^ /*sender*/, System::Windows::Forms::KeyEventArgs^ e ) {

    switch(e->KeyCode)
    {

    case Keys::Right :
    pictureBox1->Left += 100;


    }
    }
    and when i press right key it dont work im lost for ideas thats just 1 of like 20things ive tried
    help plz ^^

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: VC++ key down event help

    You have posted to the wrong Forum. This is a "Visual C++ Programming" Forum, not a CLI and so on one...
    Victor Nijegorodov

  3. #3
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: VC++ key down event help

    [ redirected ]
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  4. #4
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: VC++ key down event help

    This works very well for me:
    Code:
          System::Void Form1_KeyDown(System::Object^  sender, System::Windows::Forms::KeyEventArgs^  e) 
          {
             switch(e->KeyCode)
             {
             case Keys::Right:
                pictureBox1->Left += 5;
                break;
             case Keys::Left:
                pictureBox1->Left -= 5;
                break;
             case Keys::Up:
                pictureBox1->Top -= 5;
                break;
             case Keys::Down:
                pictureBox1->Top += 5;
                break;
             }
          }
    See the attached project.
    Attached Files Attached Files
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  5. #5
    Join Date
    Jul 2010
    Posts
    3

    Re: VC++ key down event help

    mmm strange i did that 1st excatly how u had it and it dident work :S, mm urs works on my computer soo maybe my project has somthing wrong with it ty i guess i did know how to do it >.< stupid thing lol
    Last edited by RAPIST; July 26th, 2010 at 07:00 PM.

  6. #6
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: VC++ key down event help

    Quote Originally Posted by RAPIST View Post
    ...
    Does your nickname mean something in some language (other than English)?
    Very strange choice…
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  7. #7
    Join Date
    Jul 2010
    Posts
    3

    Re: VC++ key down event help

    lol nah mate just a name i use in games so i use it in fourms as well

  8. #8
    Join Date
    Aug 2010
    Posts
    51

    Re: VC++ key down event help

    hi,


    move a picturebox in VC++ with my arrow keys i know its keydown event i want to use and well i cant seem to get it working ive tried alot all i can think of that is

    this is pretty much what i have its basically what ive been playing with

    regards,
    phe9oxis,
    http://www.guidebuddha.com

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