Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Point on form

Status
Not open for further replies.

earlrainer

Programmer
Mar 1, 2002
170
IN
Hi guys

I wish to get the Tpoint of the place on the form where the focus is at the moment.

for example I can get the Tpoint of the place where i have the mouse cursor by
GetCursorPos(p);

where p is of type Tpoint.

but i dont know how to get the above with the place where the keyboard focus is.

(one way to do that would be to move the mouse cursor to same place where keyboard focus is ..but i dont know to do that either.)

Can you guys help me
& sorry for the bad explanation of the problem...but hope you understand what i want to do.

Bye
 
if an Edit box has focus, pass the left and top properties of the edit box to the clientToScreen api function to get the screen coordinates.

Is this what you want? What exactly are you wanting to do?
 
Hi Weez,

I was trying something fancy in my application.

I have many controls on my form.mostly edit boxes and grids.

what i want to do is ,I want to show the part of my form where the focus is present magnified.

the code that i use to do the above uses Trect etc.
and this is turn requires the point where the focus is.

I manage to magnify that part of the screen where the mouse cursor is...but that does not satisfy my requirements.

what happens is that I can press tab and focus moves to the next control,but this control is not showed magnified instead that place is showed magnified where the mouse cursor is present.

I use GetCursorPos(p) to get point where mouse cursor is....
so similarly i want to get point where keyboard focus is.

This should be easy for you.

Bye




 
Can you not do something like

Using edit1.top, left and ClientToscreen, you can then calculate your new TRect structure from the return values. ScreenToClient will convert them for your form.

I've never done anything like this so this is what I would try as a first pass.

hope that's helpful
lou
[penguin]
 
hi,

what you want to make is already doen by CoolDev
They made a component TcoolLoupe what does the same you are describing above. See website cooldev.com

Steph
 
Wont you have a problem when you are magnifying two different locations at the same time ??? [bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
> I want to show the part of my form
> where the focus is present magnified.

Bleah. Are you sure that from a user interface point of view, this is a sane thing to do? Generally, you should make your app look exactly like every other Windows app in the universe, so as to avoid surprising the user.

But to address your problem: look at TCustomForm.ActiveControl, and TControl.OnEnter and TControl.OnExit.

You might approach this by setting an OnEnter routine for every single focusable control on the form, which grabs the canvas of that control and magnifies it; and an OnExit routine for every single focusable control on the form which repairs the damage.
Code:
procedure TForm1.EverythingEnter(Sender: TObject);
begin
  if Sender is TEdit then
    with Sender as TEdit do
... etc. ...
end;

procedure TForm1.EverythingExit(Sender: TObject);
begin
  (Sender as TWinControl).Repaint;
end;
-- Doug Burbidge mailto:doug@ultrazone.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top