#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    18
    Rep Power
    0

    KeyListener in visual c++??


    my program wish to capture user input via keyboard, and assign the source and destination node value.

    int count =0;

    do
    {
    //how to capture user input via keyboard???
    if(count=0)
    {
    SourceIndex =? ; //user input assign
    }
    if(count=1)
    {
    DestinationIndex = ?;
    }
    }; while(count>1)
    count++;

    thanks Experts!
  2. #2
  3. No Profile Picture
    Offensive Member
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2002
    Location
    in the perfect world
    Posts
    622
    Rep Power
    28
    What OS?

    What compiler?

    What language or API? (ie WIN32, MFC, DELPHI ect)
    The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.

    Frank Zappa
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    18
    Rep Power
    0
    is win 32...........by i did incorporate direct X as to do the graphic stuff...........

    compiler......visual c++ 6.0

    this is the code follow by once able to capture user input and pass to the Findshortestpath fucntion.............

    if (KEYPRESSED('S'))
    {
    pressedKey = true;

    if (pressedKey)
    {
    s = FindShortestPath (Matrix,NumberOfNodes,SourceIndex, DestinationIndex, ShortestPath);
    MessageBox(gHwnd, s, "Shortest Path Found", MB_OK);
    }
    Start= 1;

    }
    if (Start ==1)
    {
    pMap->Draw();
    pCar->Move();
    pCar->Draw();

    pDrawEngine->Flip( );
    }
  6. #4
  7. No Profile Picture
    Offensive Member
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2002
    Location
    in the perfect world
    Posts
    622
    Rep Power
    28
    look up 'GetKeyState()" ect on MSDN

    you will need to check the HIWORD of the return == 1 if the key is down. In English keyboards the code for a letter or digit is its ASCI code (or one of the Virtual Key codes).
    The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.

    Frank Zappa

IMN logo majestic logo threadwatch logo seochat tools logo