Custom Mouse Pointer "Out of Memory"

D

Doug

I am using the following code to create a custom mouse pointer when the
mouse is over a text box. However, if I move the mouse over the text box
for any period of time Microsoft Access runs out of memory. I get an "out
of memory" error and Access starts behaving erratically and then bombs.

Does anyone know how to do this without running Access out of memory?

Thanks.

***

Declare Function LoadCursorFromFile Lib "user32" Alias "LoadCursorFromFileA"
(ByVal lpFileName As String) As Long


Declare Function SetCursor Lib "user32"(ByVal hCursor As Long) As Long

-------------------

Function PointM(strPathToCursor As String)

Dim lngRet As Long

lngRet = LoadCursorFromFile(strPathToCursor)
lngRet = SetCursor(lngRet)

End Function

-------------------

Private Sub Label0_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)

PointM (CurrentProject.Path & "\testcursor.cur")

End Sub
 
S

Stephen Lebans

Here is an old post of mine on this subject.

You do not LOAD the cursor on every MouseMove event. Load it once in the
Forms's Load event and then store the handle returned to a global
variable. Use this handle in your call to SetCursor.
Really though, the proper way to handle this is to set the window's
Default Cursor class property to NULL. Then you only have to SetCursor
once on the first MouseMove event of the Image control and then return
everything back to normal on the first MouseMove event of the Form.

Why are you setting a custom cursor anyway. Have you looked at the
available supported system cursors than be set directly with Access?



--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
D

Doug

Steve, thanks for your help (also your website has proved very helpful). I
am setting custom cursors because I don't like the formatting options for
the built-in datasheet view, but I want the datasheet functionality, namely
to highlight and copy cells in a (non-datasheet view) form. In my
continuous form, I can select an entire row, or an entire column, or any
group of contiguous cells and then copy that range. However, none of the
built-in Access cursors are what I want--a down arrow to select an entire
column, a right arrow to select a row, and an oversized "plus" to drag and
select multiple cells. So I've created my own cursors, which essentially
are the same as those seen in datasheet view. If there's a way to use the
cursors Access uses in datasheet view, I'd like to know how.

"Really though, the proper way to handle this is to set the window's Default
Cursor class property to NULL. Then you only have to SetCursor once on the
first MouseMove event of the Image control and then return everything back
to normal on the first MouseMove event of the Form"

How do I set the Default Cursor class property to NULL?

Thanks again,

Doug
 
S

Stephen Lebans

http://www.lebans.com/changemdibackground.htm

This sample shows how to set the Background Brush member of a specific
window Class. You will have to modify as required.

I did have sample code showing how to do exactly what you require - but with
a quick scan of my hard drive - I could not find it.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top