Jump to content
davornik

TButtonedEdit RightButton - OnMouseDown/OnMouseUp

Recommended Posts

Is it possible to detect OnMouseDown and on MouseUp events on the TButtonedEdit RightButton (TEditButton)?

I am trying to set it to Show/Hide password when I press/unpress the right button, but there is only an OnClick event for the right button.

Tried also subclassing, but there is no handle for the right button in TButtonedEdit?

 

procedure TForm1.FormCreate(Sender: TObject);
begin
  //SetWindowSubclass(ButtonedEdit1.RightButton.Handle, @ButtonedEditSubclassProc, 1, DWORD_PTR(ButtonedEdit1.RightButton)); <- no Handle for RightButton
  SetWindowSubclass(ButtonedEdit1.Handle, @ButtonedEditSubclassProc, 1, DWORD_PTR(ButtonedEdit1));
end;

function ButtonedEditSubclassProc(hWnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM; uIdSubclass: UINT_PTR; dwRefData: DWORD_PTR): LRESULT; stdcall;
begin
  case uMsg of
    WM_LBUTTONDOWN: Form1.ButtonedEdit1.PasswordChar:=#0; 
    WM_LBUTTONUP: Form1.ButtonedEdit1.PasswordChar:='*';
    WM_NCDESTROY: RemoveWindowSubclass(hWnd, @ButtonedEditSubclassProc, uIdSubclass);
  end;
  Result := DefSubclassProc(hWnd, uMsg, wParam, lParam);
end;

Password is hidden

 

1.png.ead8ebaa61fd8a0b8f58e1d6a1efa40b.png

 

When I press right button is it possible for password to be shown and on unpress to be hidden again?

 

2.png.d438d94e48537f2d927382793ecdef35.png

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×