Thread: key

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    30

    key

    im new to windows programming. how do i make certain events trigger when user presses a certain key. like i want a square to be drawn on the window if user presses "s".

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Typically you might handle WM_KEYDOWN to respond to keyboard input and do your drawing within your WM_PAINT message handler. You can use, for example, InvalidateRect or UpdateWindow in response to WM_KEYDOWN messages of interest to ensure painting occurs as you require.

    Draw the rectangle or square with, unsurprisingly, Rectangle.

    For more information on using WM_PAINT, start here.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  3. Directional Keys - Useing in Console
    By RoD in forum C++ Programming
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM
  4. FAQ: Directional Keys - Useing in Console
    By RoD in forum FAQ Board
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM