eYes
asked on
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?
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
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?
And use
tmp.Left := 50;
tmp.Top := 50;
to position it.
tmp.Left := 50;
tmp.Top := 50;
to position it.
ASKER
i want it show on desktop not in form.
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.
Apart from that, I'm afraid I can't help!
John.
You can only do this by using a form so why not size the form to the size of your editbox.
Following..
Or, to suggest a completly different alernative: Use the active desktop to put a <textArea> on the wallpaper.
GL
Mike
GL
Mike
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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(Appli cation);
With frmNew do begin
BorderStyle:=bsNone;
Width:=200;
Height:=30;
Top:=50;
Left:=50;
End;
txtNew:=TEdit.Create(Appli cation);
With txtNew do begin
ParentWindow:=frmNew.Handl e;
Width:=200;
Height:=30;
Left:=0;
Top:=0;
End;
frmNew.Show;
end;
////////////////////////// ///
This is the best I can think of...
John. :-)
//////////////////////////
procedure TForm1.Button1Click(Sender
var
frmNew : TForm;
txtNew : TEdit;
begin
frmNew:=TForm.Create(Appli
With frmNew do begin
BorderStyle:=bsNone;
Width:=200;
Height:=30;
Top:=50;
Left:=50;
End;
txtNew:=TEdit.Create(Appli
With txtNew do begin
ParentWindow:=frmNew.Handl
Width:=200;
Height:=30;
Left:=0;
Top:=0;
End;
frmNew.Show;
end;
//////////////////////////
This is the best I can think of...
John. :-)
ASKER
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?
also i cant set it's parent to form, because form maybe clip the list box.
any idea?
So you don't want what you originally asked for, yeah?
Try this then. (ComboBoxes don't clip to forms!)
procedure TForm1.Button1Click(Sender : TObject);
var
frmNew : TForm;
cboNew : TComboBox;
begin
frmNew:=TForm.Create(Appli cation);
With frmNew do begin
BorderStyle:=bsNone;
Width:=200;
Height:=30;
Top:=50;
Left:=50;
End;
cboNew:=TComboBox.Create(A pplication );
With cboNew do begin
ParentWindow:=frmNew.Handl e;
Width:=200;
Height:=30;
Left:=0;
Top:=0;
End;
frmNew.Height:=cboNew.Heig ht;
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;
procedure TForm1.Button1Click(Sender
var
frmNew : TForm;
cboNew : TComboBox;
begin
frmNew:=TForm.Create(Appli
With frmNew do begin
BorderStyle:=bsNone;
Width:=200;
Height:=30;
Top:=50;
Left:=50;
End;
cboNew:=TComboBox.Create(A
With cboNew do begin
ParentWindow:=frmNew.Handl
Width:=200;
Height:=30;
Left:=0;
Top:=0;
End;
frmNew.Height:=cboNew.Heig
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;
huh huh, anybody realized that I already gave the solution?
ASKER
thanks a lot
Mike : Yours was different. Did you look at his code running and then compare it to yours? Besides, he keeps asking for other stuff!
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
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
Okay, okay...just a question. Don't get arsey!!
tmp := TMyEdit.Create(Self);
InsertControl(tmp);