PC Review


Reply
Thread Tools Rate Thread

Cursor Location / Title Bar height

 
 
Strahimir Antoljak
Guest
Posts: n/a
 
      20th Oct 2004
I want to track the cursor location relative to a control on the form. I am
aware of System.Windows.Forms.Cursor.Position which provides absolute cursor
position relative to the screen. With right subtractions of the form
location and the control location it is possible to get the relative cursor
location to the screen.... with one exception - form has a title bar, and
border widths which I do not know the values of. Is there a way to find out
the title bar width and border widths? preferably programmatically? thanks


--
Strah @ Langan


 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      20th Oct 2004
"Strahimir Antoljak" <(E-Mail Removed)> schrieb:
>I want to track the cursor location relative to a control on the
> form. I am aware of System.Windows.Forms.Cursor.Position
> which provides absolute cursor position relative to the screen.
> With right subtractions of the form location and the control location
> it is possible to get the relative cursor location to the screen....


Take a look at the properties of the 'SystemInformation' class and the
form's/control's 'PointToClient' and 'PointToScreen' methods.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

 
Reply With Quote
 
Peter Proost
Guest
Posts: n/a
 
      20th Oct 2004
Maybe the PointToClient method can help you,
or maybe this piece of code,
place a label and a button on a form, call the label lblMouse and copy paste
the following code

<<<<<<<<code>>>>>>>>>
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
lblMouse.Text = "X: " & e.X & " Y: " & e.Y
lblMouse.Refresh()
End Sub

Private Sub Button1_MouseMove(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles Button1.MouseMove
lblMouse.Text = "X: " & e.X & " Y: " & e.Y
lblMouse.Refresh()
End Sub

<<<<<<<<<code>>>>>>>>>>

hth
Peter


"Strahimir Antoljak" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> I want to track the cursor location relative to a control on the form. I

am
> aware of System.Windows.Forms.Cursor.Position which provides absolute

cursor
> position relative to the screen. With right subtractions of the form
> location and the control location it is possible to get the relative

cursor
> location to the screen.... with one exception - form has a title bar, and
> border widths which I do not know the values of. Is there a way to find

out
> the title bar width and border widths? preferably programmatically? thanks
>
>
> --
> Strah @ Langan
>
>



 
Reply With Quote
 
Strahimir Antoljak
Guest
Posts: n/a
 
      20th Oct 2004
Herfried,

exactly what I needed. thanks for the quick and 'to the point' replay
--
Strah @ Langan

"Herfried K. Wagner [MVP]" <hirf-spam-me-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Strahimir Antoljak" <(E-Mail Removed)> schrieb:
>>I want to track the cursor location relative to a control on the
>> form. I am aware of System.Windows.Forms.Cursor.Position
>> which provides absolute cursor position relative to the screen.
>> With right subtractions of the form location and the control location
>> it is possible to get the relative cursor location to the screen....

>
> Take a look at the properties of the 'SystemInformation' class and the
> form's/control's 'PointToClient' and 'PointToScreen' methods.
>
> --
> Herfried K. Wagner [MVP]
> <URL:http://dotnet.mvps.org/>



 
Reply With Quote
 
Strahimir Antoljak
Guest
Posts: n/a
 
      20th Oct 2004
Peter,

exactly what I needed. Thanks a bunch

--
Strah @ Langan

"Peter Proost" <(E-Mail Removed)> wrote in message
news:eHzZ%(E-Mail Removed)...
> Maybe the PointToClient method can help you,
> or maybe this piece of code,
> place a label and a button on a form, call the label lblMouse and copy
> paste
> the following code
>
> <<<<<<<<code>>>>>>>>>
> Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As _
> System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
> lblMouse.Text = "X: " & e.X & " Y: " & e.Y
> lblMouse.Refresh()
> End Sub
>
> Private Sub Button1_MouseMove(ByVal sender As Object, ByVal e As _
> System.Windows.Forms.MouseEventArgs) Handles Button1.MouseMove
> lblMouse.Text = "X: " & e.X & " Y: " & e.Y
> lblMouse.Refresh()
> End Sub
>
> <<<<<<<<<code>>>>>>>>>>
>
> hth
> Peter
>
>
> "Strahimir Antoljak" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
>> I want to track the cursor location relative to a control on the form. I

> am
>> aware of System.Windows.Forms.Cursor.Position which provides absolute

> cursor
>> position relative to the screen. With right subtractions of the form
>> location and the control location it is possible to get the relative

> cursor
>> location to the screen.... with one exception - form has a title bar, and
>> border widths which I do not know the values of. Is there a way to find

> out
>> the title bar width and border widths? preferably programmatically?
>> thanks
>>
>>
>> --
>> Strah @ Langan
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
changing the height of the WinXP Title Bars? =?Utf-8?B?ei5lbnRyb3BpYw==?= Windows XP Customization 10 1st Jul 2006 08:58 AM
Taskbar And Window Title Height =?Utf-8?B?Tmljaw==?= Windows XP General 0 26th Apr 2006 07:57 PM
How to get standard windows's title and menu 's height? Ekey Microsoft C# .NET 2 14th Apr 2004 11:21 AM
Center one form over another + height of title bar C-Sharper or C-Hasher, one of the two Microsoft C# .NET 4 9th Mar 2004 07:58 PM
Determining the height (in pixels) of a windows title bar. Max Microsoft VB .NET 2 2nd Nov 2003 02:37 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:51 AM.