davornik 4 Posted 11 hours ago 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 When I press right button is it possible for password to be shown and on unpress to be hidden again? Share this post Link to post
Uwe Raabe 2141 Posted 49 minutes ago (edited) The buttons of a TButtonedEdit are no controls, so there simply is no handle. Instead they provide an instance FGlyph of a private type TGlyph derived from TCustomControl, which handles the mouse events. This control has the edit control as parent. Perhaps you can achieve your goal by deriving from TButtonControl and override GetEditButtonClass. This gives you access to the protected FGlyph and allows to replace it with a derived class implementing the requested behavior. Edited 48 minutes ago by Uwe Raabe Share this post Link to post