CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Managed C++ and C++/CLI
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Managed C++ and C++/CLI Discuss Managed C++ and .NET-specific questions related to C++.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old July 20th, 2005, 11:47 AM
    gfr1 gfr1 is offline
    Junior Member
     
    Join Date: May 2002
    Posts: 23
    gfr1 is an unknown quantity at this point (<10)
    Capture a key stroke

    How can I capture a Keystroke when in a TextBox and check if its the return key. I've IsInputChar() method but it dosen't seam to work.
    Reply With Quote
      #2    
    Old July 20th, 2005, 03:50 PM
    _david _david is offline
    Junior Member
     
    Join Date: Apr 2005
    Posts: 8
    _david is an unknown quantity at this point (<10)
    Re: Capture a key stroke

    if (textBoxName->Text->Chars[i]==13) // 13 or KEY_ENTER look that up in the .net stdlib.h

    Whatever the code for enter is, it might be ten, what I would do is check the values of what's in the textbox after you've pressed enter, either that or display each keypress's value that's entered into the textbox by changing the keypress event handler, just double click on the textbox and the IDE will create the function for you, and then write out MessageBox::Show(KeyPressValue::ToString() or use String::Format("{0}", KeyPress_Value) which should be simple enough to do. Otherwise, you would have to use more redirection or whatever with the TextBoxName->Text->ToCharArray()::Chars() something to that effect I don't want to open beta 2 right now and look.

    That should work, you could just check the value of the keypress before it's entered with making a TextBoxName_KeyPress procedure, I don't know exactly how to do that without looking.
    Reply With Quote
      #3    
    Old July 21st, 2005, 07:27 AM
    gfr1 gfr1 is offline
    Junior Member
     
    Join Date: May 2002
    Posts: 23
    gfr1 is an unknown quantity at this point (<10)
    Re: Capture a key stroke

    The functions you mentioned work if a keystroke causes entry into the procedure for that box. But the enter key does not cause entry into the event handler for that box. In MFC there is a PreTranslateMessage handler that you can use I'm looking for something along that line. Thanks for the reply that was some good info.
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Managed C++ and C++/CLI


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 11:23 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009