how to let it get focus?

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  TMyEdit = class(TEdit)
  protected
    procedure createparams(var params: Tcreateparams); override;
  end;

var
  Form1: TForm1;
  tmp: TMyEdit;

implementation

{$R *.DFM}
procedure TMyEdit.createparams(var params: Tcreateparams);
begin
  inherited createparams(params);
  params.exstyle := params.exstyle or WS_EX_TOOLWINDOW;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if not assigned(lst) then
  begin
    tmp := tmylist.Create(application);
    tmp.ParentWindow := getdesktopwindow;
    tmp.Text := 'Test';
    setwindowpos(tmp.handle, HWND_TOP, 50, 50, tmp.width, tmp.height,
                             SWP_SHOWWINDOW or SWP_NOCOPYBITS);
  end;
end;

end.

while i run this, it can show the edit on the desktop, but the edit can't get focus.
how can i let it get focus?
eYesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

EpsylonCommented:
Just use:

tmp := TMyEdit.Create(Self);
InsertControl(tmp);
0
EpsylonCommented:
And use

tmp.Left := 50;
tmp.Top := 50;

to position it.
0
eYesAuthor Commented:
i want it show on desktop not in form.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

JaymolCommented:
I don't think you can, unfortunately.  Create a transparent form and set that as the parent of the TEdit.  That'll get round the problem.

Apart from that, I'm afraid I can't help!

John.
0
EpsylonCommented:
You can only do this by using a form so why not size the form to the size of your editbox.
0
RBertoraCommented:
Following..
0
edeyCommented:
Or, to suggest a completly different alernative:  Use the active desktop to put a <textArea> on the wallpaper.

GL
Mike
0
LischkeCommented:
Interesting suggestions here :-)

eYes, use:

procedure TMyEdit.createparams(var params: Tcreateparams);
begin
  inherited createparams(params);
  params.Style := WS_POPUP;
  params.exstyle := params.exstyle or WS_EX_TOOLWINDOW;
end;


Ciao, Mike
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JaymolCommented:
This looks exactly the same, but works.  (Make a Form1 with a Button1 on it and use this code.)

/////////////////////////////

procedure TForm1.Button1Click(Sender: TObject);
var
      frmNew      :      TForm;
  txtNew      :      TEdit;
begin
      frmNew:=TForm.Create(Application);
  With frmNew do begin
        BorderStyle:=bsNone;
    Width:=200;
    Height:=30;
    Top:=50;
    Left:=50;
      End;
  txtNew:=TEdit.Create(Application);
  With txtNew do begin
        ParentWindow:=frmNew.Handle;
    Width:=200;
    Height:=30;
            Left:=0;
    Top:=0;
  End;
  frmNew.Show;
end;

/////////////////////////////

This is the best I can think of...

John. :-)
0
eYesAuthor Commented:
i want to write a combobox like component. add my own control (such as stringgrid, listview, treeview...etc) as combo list box. if i put that in a form, while user select in the combo list box and his form lost focus(the title bar become gray), what a strange combobox!
also i cant set it's parent to form, because form maybe clip the list box.

any idea?
0
JaymolCommented:
So you don't want what you originally asked for, yeah?
0
JaymolCommented:
Try this then.  (ComboBoxes don't clip to forms!)

procedure TForm1.Button1Click(Sender: TObject);
var
      frmNew : TForm;
  cboNew : TComboBox;
begin
      frmNew:=TForm.Create(Application);
  With frmNew do begin
        BorderStyle:=bsNone;
    Width:=200;
    Height:=30;
    Top:=50;
    Left:=50;
      End;
  cboNew:=TComboBox.Create(Application);
  With cboNew do begin
        ParentWindow:=frmNew.Handle;
    Width:=200;
    Height:=30;
            Left:=0;
    Top:=0;
  End;
  frmNew.Height:=cboNew.Height;
  cboNew.Items.Add('Item 1');
  cboNew.Items.Add('Item 2');
  cboNew.Items.Add('Item 3');
  cboNew.Items.Add('Item 4');
  cboNew.Items.Add('Item 5');
  frmNew.Show;
end;
0
LischkeCommented:
huh huh, anybody realized that I already gave the solution?
0
eYesAuthor Commented:
thanks a lot
0
JaymolCommented:
Mike : Yours was different.  Did you look at his code running and then compare it to yours?  Besides, he keeps asking for other stuff!
0
LischkeCommented:
Jaymol, of course did I look at it. I copied it to my current project and tried out what I thought what could be the solution and it was...

The question for the other stuff raised only because of the suggested solution to use a form.

eYes, I have already written an own combo box. If you need further help on this then ask another question and I'll be there. You can also download a component called TColorPickerButton from www.lischke-online.de where I also use a standalone popup window very similar to the popup of a combobox. Look through the code to get important ideas (mouse capture, message handling etc.).

Ciao, Mike
0
JaymolCommented:
Okay, okay...just a question.  Don't get arsey!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.