Recent

Author Topic: Create Form (or Top control) that accept mousedown event but don't get focus.  (Read 1985 times)

dmitryb

  • Jr. Member
  • **
  • Posts: 62
Hello
I need to create dropdown window for my custom combobox.
How can I create Form (or Top control) that accept mousedown event but don't get focus.

In Delphi I used

Code: Pascal  [Select][+][-]
  1. procedure TPopupInactiveFormEh.WMMouseActivate(var Message: TWMMouseActivate);
  2. begin
  3.   Message.Result := MA_NOACTIVATE;
  4. end;
  5.  
for forms

or

Code: Pascal  [Select][+][-]
  1. procedure TPopupListboxEh.CreateParams(var Params: TCreateParams);
  2.  
  3.   Params.WndParent := GetDesktopWindow;
  4.  
  5. function TPopupListboxEh.CanFocus: Boolean;
  6. begin
  7.   Result := False;
  8. end;

for child controls

No WM_MOUSEACTIVATE work. Doesn't work at all in Lazarus.

No GetDesktopWindow in Linux GTK. Crossplatform solution needed.

jamie

  • Hero Member
  • *****
  • Posts: 6090
There is a csNoFocus  setting  for the Tcontrol.ControlStyle.

docs state it will not receive focus if that is set...
The only true wisdom is knowing you know nothing

dmitryb

  • Jr. Member
  • **
  • Posts: 62
Hello jamie

When setting this parameter, I do not see any effect of selecting Form or focusing control.

Code: Pascal  [Select][+][-]
  1. procedure TForm2.FormCreate(Sender: TObject);
  2. begin
  3.   ControlStyle := ControlStyle + [csNoFocus];
  4. end;
  5.  
  6. constructor TMyControl.Create(Owner: TComponent);
  7. begin
  8.   inherited Create(Owner);
  9.   ControlStyle := ControlStyle + [csNoFocus];
  10. end;
  11.  

Teseted in Win32(Windows10) and GTK2(Ubuntu 18.04.1).

 

TinyPortal © 2005-2018