比如我原本光标定义在edit1的字符之间,我想点击button1后,实现键盘上的backspace按键的功能,就是删除该光标前面一个字符,本人实现不能,关键在于焦点问题以及如何按钮实现按键功能,望解答

解决方案 »

  1.   

    SendMessage(hwnd, WM_KEYDOWN, (WPARAM)VK_BACK, NULL);
    SendMessage(hwnd, WM_KEYUP, (WPARAM)VK_BACK, NULL);
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      Edit1.Perform(WM_CHAR, VK_BACK, 1);
    end;procedure TForm1.SpeedButton1Click(Sender: TObject);
    begin
      Edit1.Perform(WM_CHAR, VK_BACK, 1);
    end;
      

  3.   

      Edit1.SelLength := 1;
      if Edit1.SelText ='' then Edit1.SelLength := 2;
      Edit1.SelText := '';
      

  4.   

      //删除前面一个字符,应该加上
      Edit1.SelStart := Edit1.SelStart - 1;
      Edit1.SelLength := 1;
      if Edit1.SelText ='' then Edit1.SelLength := 2;
      Edit1.SelText := '';
      

  5.   

    Edit1.Perform(WM_CHAR, VK_BACK, 0);