Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default VBA - Click mouse to change cursor to cross hair that spans the en

I need the ability to allow the user to change the cursor to a cross hair
that covers the entire form that detected the mouse event. This is needed so
user can read values along sides and bottom of form as he/she moves mouse
over the form. I have been unable to find any vba code to do this.

Gary
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default VBA - Click mouse to change cursor to cross hair that spans the en

Application.Cursor = xlDefault or...
--
HTH...

Jim Thomlinson


"gary" wrote:

I need the ability to allow the user to change the cursor to a cross hair
that covers the entire form that detected the mouse event. This is needed so
user can read values along sides and bottom of form as he/she moves mouse
over the form. I have been unable to find any vba code to do this.

Gary

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default VBA - Click mouse to change cursor to cross hair that spans th

Jim,

What I need is a full-form cross hair, not just a "+" sign cursor. The
lines need to extend from the cursor position on the form to the horizontal
and vertical edges of the form. I'm thinking some code will be required.

Thanks,

Gary

"Jim Thomlinson" wrote:

Application.Cursor = xlDefault or...
--
HTH...

Jim Thomlinson


"gary" wrote:

I need the ability to allow the user to change the cursor to a cross hair
that covers the entire form that detected the mouse event. This is needed so
user can read values along sides and bottom of form as he/she moves mouse
over the form. I have been unable to find any vba code to do this.

Gary

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default VBA - Click mouse to change cursor to cross hair that spans the en

Gary,
On a userform with 2 labels, lblHoriz and lblVert:

Private Sub UserForm_Initialize()
With lblHoriz
.Height = 1
.Left = 0
.Width = Me.Width
End With

With lblVert
.Width = 1
.Top = 0
.Height = Me.Height
End With
End Sub

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
lblHoriz.Top = Y
lblVert.Left = X
End Sub

NickHK

"gary" wrote in message
...
I need the ability to allow the user to change the cursor to a cross hair
that covers the entire form that detected the mouse event. This is needed

so
user can read values along sides and bottom of form as he/she moves mouse
over the form. I have been unable to find any vba code to do this.

Gary



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default VBA - Click mouse to change cursor to cross hair that spans th

Hi Nick,

Your solution is very elegant. All I had to add was to set the label border
style to 1 (single line) so I could see the lines. It does exactly what I
asked. (Single one).

What I am actually trying to do is add cross hairs to an IE object set with
the following code.

The Addlabel dies at runtime with Run time error Invalid class string
which I think is due to the ie.label.lblHoriz not being the correct way to
add a label control to the IE object. I dont know what would be correct.

Also I dont know how to make the correct event handler for the mouse move
event while the mouse is on the IE form.

Any ideas?

Dim ie as Object

Sub Addlabel(strControl As String, intLeft As Integer, intTop As Integer,
intWidth As Integer, intHeight As Integer, strCaption As String)

Dim mycmd As Control

Set mycmd = Controls.Add(strControl)
mycmd.Left = intLeft
mycmd.Top = intTop
mycmd.Width = intWidth
mycmd.Height = intHeight
mycmd.BorderStyle = 1
If strCaption < "" Then
mycmd.Caption = strCaption
End If
mycmd.Visible = True
End Sub


'
' not sure about this
'
Private Sub ie_MouseMove(ByVal Button As Integer, ByVal Shift As Integer,
ByVal X As Single, ByVal Y As Single)
lblHoriz.Top = Y
lblVert.Left = X
End Sub


Private Sub UserForm_Initialize()

With lblHoriz
.Height = 1
.Left = 0
.Width = Me.Width
End With

With lblVert
.Width = 1
.Top = 0
.Height = Me.Height
End With


set ie = CreateObject("InternetExplorer.Application")
ie.AddressBar = False
ie.MenuBar = False
ie.Toolbar = False
ie.Width = 600
ie.Height = 750
ie.Left = 0
ie.Top = 0
ie.navigate "www.yahoo.com



With ie

While Not .readyState = READYSTATE_COMPLETE
DoEvents
Wend

I can control scroll bars with:

..document.parentWindow.Scroll 100, 200
..Visible = True

Add cross hairs here --NOT CORRECT
Call UserForm1.Addlabel( "ie.label.lblHoriz",2, 10, 175, 20, "")

Call UserForm1.Addlabel( " ie.label.lblVert",2, 20, 175, 20, "")

..end with



"NickHK" wrote:

Gary,
On a userform with 2 labels, lblHoriz and lblVert:

Private Sub UserForm_Initialize()
With lblHoriz
.Height = 1
.Left = 0
.Width = Me.Width
End With

With lblVert
.Width = 1
.Top = 0
.Height = Me.Height
End With
End Sub

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
lblHoriz.Top = Y
lblVert.Left = X
End Sub

NickHK

"gary" wrote in message
...
I need the ability to allow the user to change the cursor to a cross hair
that covers the entire form that detected the mouse event. This is needed

so
user can read values along sides and bottom of form as he/she moves mouse
over the form. I have been unable to find any vba code to do this.

Gary






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default VBA - Click mouse to change cursor to cross hair that spans th

Gary,
You've lost me now.
You are creating an instance of Internet Explorer at run time, but I do not
see the connection between that and the userform.
You can place a web browser on a userform using the "Microsoft web Browser"
control.
You then want to put cross hairs over that ?
Is that what you are after ?

NickHK

"gary" wrote in message
...
Hi Nick,

Your solution is very elegant. All I had to add was to set the label

border
style to 1 (single line) so I could see the lines. It does exactly what I
asked. (Single one).

What I am actually trying to do is add cross hairs to an IE object set

with
the following code.

The Addlabel dies at runtime with "Run time error Invalid class string"
which I think is due to the " ie.label.lblHoriz" not being the correct way

to
add a label control to the IE object. I don't know what would be correct.

Also I don't know how to make the correct event handler for the mouse move
event while the mouse is on the IE form.

Any ideas?

Dim ie as Object

Sub Addlabel(strControl As String, intLeft As Integer, intTop As Integer,
intWidth As Integer, intHeight As Integer, strCaption As String)

Dim mycmd As Control

Set mycmd = Controls.Add(strControl)
mycmd.Left = intLeft
mycmd.Top = intTop
mycmd.Width = intWidth
mycmd.Height = intHeight
mycmd.BorderStyle = 1
If strCaption < "" Then
mycmd.Caption = strCaption
End If
mycmd.Visible = True
End Sub


'
' not sure about this
'
Private Sub ie_MouseMove(ByVal Button As Integer, ByVal Shift As Integer,
ByVal X As Single, ByVal Y As Single)
lblHoriz.Top = Y
lblVert.Left = X
End Sub


Private Sub UserForm_Initialize()

With lblHoriz
.Height = 1
.Left = 0
.Width = Me.Width
End With

With lblVert
.Width = 1
.Top = 0
.Height = Me.Height
End With


set ie = CreateObject("InternetExplorer.Application")
ie.AddressBar = False
ie.MenuBar = False
ie.Toolbar = False
ie.Width = 600
ie.Height = 750
ie.Left = 0
ie.Top = 0
ie.navigate "www.yahoo.com"



With ie

While Not .readyState = READYSTATE_COMPLETE
DoEvents
Wend

' I can control scroll bars with:

.document.parentWindow.Scroll 100, 200
.Visible = True

'Add cross hairs here --NOT CORRECT
Call UserForm1.Addlabel( "ie.label.lblHoriz",2, 10, 175, 20, "")

Call UserForm1.Addlabel( " ie.label.lblVert",2, 20, 175, 20, "")

.end with



"NickHK" wrote:

Gary,
On a userform with 2 labels, lblHoriz and lblVert:

Private Sub UserForm_Initialize()
With lblHoriz
.Height = 1
.Left = 0
.Width = Me.Width
End With

With lblVert
.Width = 1
.Top = 0
.Height = Me.Height
End With
End Sub

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
lblHoriz.Top = Y
lblVert.Left = X
End Sub

NickHK

"gary" wrote in message
...
I need the ability to allow the user to change the cursor to a cross

hair
that covers the entire form that detected the mouse event. This is

needed
so
user can read values along sides and bottom of form as he/she moves

mouse
over the form. I have been unable to find any vba code to do this.

Gary






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default VBA - Click mouse to change cursor to cross hair that spans th

Nick,

The user form contains several controls to allow the user to specify what
charts he wants to see in the IE window. Once I have the inputs I attempt
to create an IE browser window and go to the URL that will get the desired
info. I would like the cursor to change to cross hairs while it is over the
IE window so the user can more accurately get values that are displayed along
the borders.

I hope that makes sense.

Thanks for asking,

Gary


"NickHK" wrote:

Gary,
You've lost me now.
You are creating an instance of Internet Explorer at run time, but I do not
see the connection between that and the userform.
You can place a web browser on a userform using the "Microsoft web Browser"
control.
You then want to put cross hairs over that ?
Is that what you are after ?

NickHK

"gary" wrote in message
...
Hi Nick,

Your solution is very elegant. All I had to add was to set the label

border
style to 1 (single line) so I could see the lines. It does exactly what I
asked. (Single one).

What I am actually trying to do is add cross hairs to an IE object set

with
the following code.

The Addlabel dies at runtime with "Run time error Invalid class string"
which I think is due to the " ie.label.lblHoriz" not being the correct way

to
add a label control to the IE object. I don't know what would be correct.

Also I don't know how to make the correct event handler for the mouse move
event while the mouse is on the IE form.

Any ideas?

Dim ie as Object

Sub Addlabel(strControl As String, intLeft As Integer, intTop As Integer,
intWidth As Integer, intHeight As Integer, strCaption As String)

Dim mycmd As Control

Set mycmd = Controls.Add(strControl)
mycmd.Left = intLeft
mycmd.Top = intTop
mycmd.Width = intWidth
mycmd.Height = intHeight
mycmd.BorderStyle = 1
If strCaption < "" Then
mycmd.Caption = strCaption
End If
mycmd.Visible = True
End Sub


'
' not sure about this
'
Private Sub ie_MouseMove(ByVal Button As Integer, ByVal Shift As Integer,
ByVal X As Single, ByVal Y As Single)
lblHoriz.Top = Y
lblVert.Left = X
End Sub


Private Sub UserForm_Initialize()

With lblHoriz
.Height = 1
.Left = 0
.Width = Me.Width
End With

With lblVert
.Width = 1
.Top = 0
.Height = Me.Height
End With


set ie = CreateObject("InternetExplorer.Application")
ie.AddressBar = False
ie.MenuBar = False
ie.Toolbar = False
ie.Width = 600
ie.Height = 750
ie.Left = 0
ie.Top = 0
ie.navigate "www.yahoo.com"



With ie

While Not .readyState = READYSTATE_COMPLETE
DoEvents
Wend

' I can control scroll bars with:

.document.parentWindow.Scroll 100, 200
.Visible = True

'Add cross hairs here --NOT CORRECT
Call UserForm1.Addlabel( "ie.label.lblHoriz",2, 10, 175, 20, "")

Call UserForm1.Addlabel( " ie.label.lblVert",2, 20, 175, 20, "")

.end with



"NickHK" wrote:

Gary,
On a userform with 2 labels, lblHoriz and lblVert:

Private Sub UserForm_Initialize()
With lblHoriz
.Height = 1
.Left = 0
.Width = Me.Width
End With

With lblVert
.Width = 1
.Top = 0
.Height = Me.Height
End With
End Sub

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
lblHoriz.Top = Y
lblVert.Left = X
End Sub

NickHK

"gary" wrote in message
...
I need the ability to allow the user to change the cursor to a cross

hair
that covers the entire form that detected the mouse event. This is

needed
so
user can read values along sides and bottom of form as he/she moves

mouse
over the form. I have been unable to find any vba code to do this.

Gary






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default VBA - Click mouse to change cursor to cross hair that spans th

Gary,
But you are attempting to draw cross hairs on IE that is completely
separated from your userform and Excel ?
Or you do have a web browser control on your userform ?

NickHK

"gary" wrote in message
...
Nick,

The user form contains several controls to allow the user to specify what
charts he wants to see in the IE window. Once I have the inputs I

attempt
to create an IE browser window and go to the URL that will get the desired
info. I would like the cursor to change to cross hairs while it is over

the
IE window so the user can more accurately get values that are displayed

along
the borders.

I hope that makes sense.

Thanks for asking,

Gary


"NickHK" wrote:

Gary,
You've lost me now.
You are creating an instance of Internet Explorer at run time, but I do

not
see the connection between that and the userform.
You can place a web browser on a userform using the "Microsoft web

Browser"
control.
You then want to put cross hairs over that ?
Is that what you are after ?

NickHK

"gary" wrote in message
...
Hi Nick,

Your solution is very elegant. All I had to add was to set the label

border
style to 1 (single line) so I could see the lines. It does exactly

what I
asked. (Single one).

What I am actually trying to do is add cross hairs to an IE object set

with
the following code.

The Addlabel dies at runtime with "Run time error Invalid class

string"
which I think is due to the " ie.label.lblHoriz" not being the correct

way
to
add a label control to the IE object. I don't know what would be

correct.

Also I don't know how to make the correct event handler for the mouse

move
event while the mouse is on the IE form.

Any ideas?

Dim ie as Object

Sub Addlabel(strControl As String, intLeft As Integer, intTop As

Integer,
intWidth As Integer, intHeight As Integer, strCaption As String)

Dim mycmd As Control

Set mycmd = Controls.Add(strControl)
mycmd.Left = intLeft
mycmd.Top = intTop
mycmd.Width = intWidth
mycmd.Height = intHeight
mycmd.BorderStyle = 1
If strCaption < "" Then
mycmd.Caption = strCaption
End If
mycmd.Visible = True
End Sub


'
' not sure about this
'
Private Sub ie_MouseMove(ByVal Button As Integer, ByVal Shift As

Integer,
ByVal X As Single, ByVal Y As Single)
lblHoriz.Top = Y
lblVert.Left = X
End Sub


Private Sub UserForm_Initialize()

With lblHoriz
.Height = 1
.Left = 0
.Width = Me.Width
End With

With lblVert
.Width = 1
.Top = 0
.Height = Me.Height
End With


set ie = CreateObject("InternetExplorer.Application")
ie.AddressBar = False
ie.MenuBar = False
ie.Toolbar = False
ie.Width = 600
ie.Height = 750
ie.Left = 0
ie.Top = 0
ie.navigate "www.yahoo.com"



With ie

While Not .readyState = READYSTATE_COMPLETE
DoEvents
Wend

' I can control scroll bars with:

.document.parentWindow.Scroll 100, 200
.Visible = True

'Add cross hairs here --NOT CORRECT
Call UserForm1.Addlabel( "ie.label.lblHoriz",2, 10, 175, 20, "")

Call UserForm1.Addlabel( " ie.label.lblVert",2, 20, 175, 20, "")

.end with



"NickHK" wrote:

Gary,
On a userform with 2 labels, lblHoriz and lblVert:

Private Sub UserForm_Initialize()
With lblHoriz
.Height = 1
.Left = 0
.Width = Me.Width
End With

With lblVert
.Width = 1
.Top = 0
.Height = Me.Height
End With
End Sub

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift

As
Integer, ByVal X As Single, ByVal Y As Single)
lblHoriz.Top = Y
lblVert.Left = X
End Sub

NickHK

"gary" wrote in message
...
I need the ability to allow the user to change the cursor to a

cross
hair
that covers the entire form that detected the mouse event. This

is
needed
so
user can read values along sides and bottom of form as he/she

moves
mouse
over the form. I have been unable to find any vba code to do this.

Gary








  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default VBA - Click mouse to change cursor to cross hair that spans the en

Gary,
Or if you only wish to track the mouse when a button is held down:
Dim MoveCrossHairs As Boolean

Private Sub UserForm_Initialize()
With lblHoriz
.Height = 1
.Left = 0
.Width = Me.Width
End With

With lblVert
.Width = 1
.Top = 0
.Height = Me.Height
End With
End Sub

Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
If Button = xlPrimaryButton Then 'Or whichever button you wish to respond
to
MoveCrossHairs = True
lblHoriz.Top = Y
lblVert.Left = X
End If
End Sub

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
If MoveCrossHairs Then
lblHoriz.Top = Y
lblVert.Left = X
End If
End Sub

Private Sub UserForm_MouseUp(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
MoveCrossHairs = False
End Sub

NickHK

"gary" wrote in message
...
I need the ability to allow the user to change the cursor to a cross hair
that covers the entire form that detected the mouse event. This is needed

so
user can read values along sides and bottom of form as he/she moves mouse
over the form. I have been unable to find any vba code to do this.

Gary



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
cross hair johnpotter94501 Excel Discussion (Misc queries) 7 November 24th 09 01:18 PM
Row Column Cross Hair h2fcell Excel Worksheet Functions 3 October 1st 08 04:32 PM
How do I change the cursor from cross to arrow Famil Club Excel Discussion (Misc queries) 1 August 31st 06 10:23 AM
HOW DO I CHANGE THE EXCEL CURSOR TO AN ARROW FROM A CROSS ? Accellerate Excel Worksheet Functions 1 May 28th 06 12:09 AM
Can I change the "white cross" cursor in Excel to another cursor? KFEagle Excel Discussion (Misc queries) 1 May 3rd 05 08:01 PM


All times are GMT +1. The time now is 11:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"