Menu

Help with wm_gettext

2002-11-28
2012-09-26
  • Nobody/Anonymous

    What is the right way to get the contents of a text field to a var declared as char strControl[50] ?

    Right now im trying to:
    char EditValue[50];
    char banana;
    SendMessage(hWndEditControl1, WM_GETTEXT, 49, banana);
    sprintf(EditValue, "%d", banana);

    But the var is storing wrong values like if the text field has the value 1234abcd in the screen, the variable gets the value  -92 !?

     
    • Nobody/Anonymous

      char buffer[51];
      GetDlgItemText(hwnd, IDC_DFXXX, buffer, 50);

      That's all. Try:
      SetWindowText(hwnd, buffer);
      to see the content of buffer.
      If you want to read in numbers you can limit the datafield to accept only numbers then convert that buffer to number with something like atol, atof.

      rpeter

       
    • Nobody/Anonymous

      could use that but if the Window it actually a main window that command could casue some runtime errors

      try using
      int len = GetWindowTextLenght(hwnd,IDC_BOX);
      banana = SendMessage(hwnd, WM_GETTEXT,len ,0);

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.