?
Solved

how to let it get focus?

Posted on 1999-10-26
17
Medium Priority
?
273 Views
Last Modified: 2010-04-04
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?
0
Comment
Question by:eYes
  • 6
  • 3
  • 3
  • +3
17 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 2159122
Just use:

tmp := TMyEdit.Create(Self);
InsertControl(tmp);
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2159131
And use

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

to position it.
0
 

Author Comment

by:eYes
ID: 2159134
i want it show on desktop not in form.
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
LVL 6

Expert Comment

by:Jaymol
ID: 2159137
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
 
LVL 13

Expert Comment

by:Epsylon
ID: 2159167
You can only do this by using a form so why not size the form to the size of your editbox.
0
 
LVL 7

Expert Comment

by:RBertora
ID: 2159168
Following..
0
 
LVL 6

Expert Comment

by:edey
ID: 2159194
Or, to suggest a completly different alernative:  Use the active desktop to put a <textArea> on the wallpaper.

GL
Mike
0
 
LVL 10

Accepted Solution

by:
Lischke earned 400 total points
ID: 2159205
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
 
LVL 6

Expert Comment

by:Jaymol
ID: 2159210
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
 

Author Comment

by:eYes
ID: 2159234
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
 
LVL 6

Expert Comment

by:Jaymol
ID: 2159247
So you don't want what you originally asked for, yeah?
0
 
LVL 6

Expert Comment

by:Jaymol
ID: 2159273
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
 
LVL 10

Expert Comment

by:Lischke
ID: 2159282
huh huh, anybody realized that I already gave the solution?
0
 

Author Comment

by:eYes
ID: 2159296
thanks a lot
0
 
LVL 6

Expert Comment

by:Jaymol
ID: 2159300
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
 
LVL 10

Expert Comment

by:Lischke
ID: 2159359
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
 
LVL 6

Expert Comment

by:Jaymol
ID: 2159379
Okay, okay...just a question.  Don't get arsey!!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…
Suggested Courses

588 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question