Thread: Newbie: WM_CHAR help needed!

  1. #1
    Registered User
    Join Date
    Oct 2002

    Newbie: WM_CHAR help needed!

    Hi. I've just started using VC++, and I'm trying to work out how to capture mouse / keybutton strokes. I have a simple dialog, and I'm capturing all the mouse stuff ok, but the windows message handler I've added for keystrokes just doesn't seem to do anything! Basically, if the user presses the c button on the keyboard, I want it to have the same effect as clicking the Clear button on the dialog, so I did this (mapped to a WM_CHAR message)

    void CPaintORamaDlg::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
    	if( nChar == 'c' )
    I also tried mapping an identical function to a WM_KEYDOWN message, but when I run the program, and press c, nothing happens.

    Can someone please explain what I'm missing?


  2. #2
    Registered User
    Join Date
    Dec 2002
    Every control on dialogs is a seperate window. So has own messages, you can not catch them while focused a control, for this you may try to remove all controls then use the same thing. For example pop a messagebox when pressed 'C', and one more try after adding at least one control, in high rate now you will not see a messagebox.
    So I suggest you,

    1. Subclass that control(which gets 'C' char)


    2. Use Accelerators

    I think second is better. I hope this helps.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie with Very Newbie Question
    By Jedi_Mediator in forum C++ Programming
    Replies: 18
    Last Post: 07-01-2008, 08:00 AM
  2. Newbie in C++
    By forum_aaa in forum C++ Programming
    Replies: 13
    Last Post: 05-15-2005, 10:01 PM
  3. Some help for a newbie?
    By Ilmater in forum C++ Programming
    Replies: 23
    Last Post: 04-19-2004, 07:44 PM
  4. Newbie needs C++ help with pauses- help needed badly.
    By dgprog in forum C++ Programming
    Replies: 2
    Last Post: 07-11-2002, 05:11 PM
  5. Newbie Game Develpoers Unite!
    By Telenosis in forum Game Programming
    Replies: 10
    Last Post: 06-22-2002, 02:02 PM