dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 40

Thread: action on pressing a key

  1. #16
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641

    Re: action on pressing a key

    Does the code inside the WM_KEYDOWN case get called?

    Put a beep or messagebox there to see if it enters that section.

    Regards / Z
    Nobody cares how it works as long as it works

  2. #17
    Join Date
    Apr 2007
    Posts
    75

    Re: action on pressing a key

    hi Z ,

    yes it gets called ... i treid out the following & count kept increasing everytime i pressed "a". So thats not a problem

    if (wParam == 'A')

    { count = count+1;

    sprintf (str," Output %d",count );

    }

  3. #18
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641

    Re: action on pressing a key

    What do you mean by "still doesnt react on pressing the key" ?

    Perhaps you need another WM_PAINT message to update the display to see the changes...

    If your code gets called then obviously dref has been assigned a value.
    Nobody cares how it works as long as it works

  4. #19
    Join Date
    Apr 2007
    Posts
    75

    Re: action on pressing a key

    i mean that inspite of pressing the key, "dn" keeps printing the samne stuff. i.e it considers dref still to be 0 & not equal to d0,as written in the keydown case

  5. #20
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641

    Re: action on pressing a key

    Aha, you declared dref inside the message handler.
    Move this variable outside the function, i.e. making it global.

    Code:
    float dref = 0 ;
    Nobody cares how it works as long as it works

  6. #21
    Join Date
    Apr 2007
    Posts
    75

    Re: action on pressing a key

    also no effect ... do i need to declare / write something more in my keydown message case ??

  7. #22
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641

    Re: action on pressing a key

    Print debug messages to screen or to a file to find out if the variables have the expected values.

    Also, if you post more of your code, it will be easier to help.
    Nobody cares how it works as long as it works

  8. #23
    Join Date
    Apr 2007
    Posts
    75

    Re: action on pressing a key

    #edit#
    Last edited by sdherzo; July 5th, 2007 at 07:34 AM.

  9. #24
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,628

    Re: action on pressing a key

    Call InvalidateRect to cause repainting your window (causing WM_PAINT to be sent to your window).
    Victor Nijegorodov

  10. #25
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641

    Re: action on pressing a key

    You need to move the calculation of d0 outside WM_PAINT so that it is calculated always (also in case of WM_KEYDOWN).

    And you still have the wrong assignment:
    Code:
     d0 = dref;
    should be
    Code:
     dref = d0;
    Nobody cares how it works as long as it works

  11. #26
    Join Date
    Apr 2007
    Posts
    75

    Re: action on pressing a key

    thanks guys ! i will try them out & get back to u guys !

  12. #27
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641

    Re: action on pressing a key

    No problem.

    Based on the nature of your questions so far, I recommend that you try some basic C/C++ tutorials.

    It will help you get over that initial threshold where one tends to think there is something magical going on.
    I've been there myself, so you can trust me when I say that programming is perfectly free from magic.
    Nobody cares how it works as long as it works

  13. #28
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,628

    Re: action on pressing a key

    Did you try to InvalidateRect?
    If it still won't help then, please, create a small test project reproducing your problem and post it to the Forum as zip archive (don't include Debug and Release folders, .ncb, .aps files!)
    Victor Nijegorodov

  14. #29
    Join Date
    Apr 2007
    Posts
    75

    Re: action on pressing a key

    u mean just type InvalidateRect(hWnd, NULL, TRUE); after the case WM_PAINT ???

  15. #30
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,628

    Re: action on pressing a key

    Quote Originally Posted by sdherzo
    ... after the case WM_PAINT ???
    No.
    After you have got some new data and do want to update your View.
    Victor Nijegorodov

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)