Announcement

Collapse
No announcement yet.

Keybd_Event question/Decimal point

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Keybd_Event question/Decimal point

    I was curious why this won't send the Decimal point to the currently focused field.

    Code:
              SetFocus MoneyHandle& 
              sTxt = TRIM$(sTxt)
              IF LEN(sTxt) > 0 THEN
                FOR IJ = 1 TO LEN(sTxt)
                  MDigit = MID$(sTxt,IJ,1)
                  IF VAL(MDigit) >= 0 AND VAL(MDigit) <= 9 THEN
                    KeyBd_Event ASC(MDigit), MapVirtualKey(ASC(MDigit), 0), 0, 0: SLEEP 0
                    KeyBd_Event ASC(MDigit), MapVirtualKey(ASC(MDigit), 0), %KEYEVENTF_KEYUP, 0: SLEEP 0
                  ELSE  
                    KeyBd_Event %VK_DECIMAL, MapVirtualKey(%VK_DECIMAL, 0), 0, 0: SLEEP 0
                    KeyBd_Event %VK_DECIMAL, MapVirtualKey(%VK_DECIMAL, 0), %KEYEVENTF_KEYUP, 0: SLEEP 0                
                  END IF  
                NEXT                 
              END IF
    Bob Mechler

  • #2
    Is the currently focused 'field' displayed where a %ES_NUMBER style is in use?
    Rod
    I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

    Comment


    • #3
      No %ES_NUMBER STYLE.
      The textbox in question is superclassed and won't allow a CONTROL SET TEXT of a number coming back from a popup calculator attached to the textbox.

      I resorted to the Keybd_event function to pass a single character from the number returned from the popup calculator function to the superclassed control. The number returned is 0-9 a decimal pt and a possible -. The Keybd event passes the 0-9 just fine to the superclassed control but filters out the '.' I tried passing VK_DECIMAL and ASC('.') with no success.

      I can type the '.' from either place on the keyboard so why can't I use Keybd_event to pass either ASC('.') OR %VK_DECIMAL.

      The superclassed control will accept a - as the first character entered only if one is entered at all. It will accept exactly one decimal point and will terminate the input when the pre-defined number of decimal place is reached.

      Is there another way to take a string and pass the string one character at a time besides keybd_event or what do I need to do.

      Thanks,

      Bob Mechler

      Comment


      • #4
        I found some code in William Burns Sendkeys app that fixes my problem. Very nice work Mr. Burns.

        Bob Mechler

        Comment

        Working...
        X