-
Hourglass from a DLL
Let's say you make a DLL, and you have a small bit of code like so:
Code:
Public Sub BusyProgram(cmdButton As Object)
On Error Resume Next
cmdButton.Enabled = False
Screen.MousePointer = vbHourglass
DoEvents
End Sub
This code will not work when an app calls it. The button will become disabled, but the hourglass will not appear.
I know why. It's beause the DLL doesn't know what form/application it's supposed to make busy.
So how do i get a DLL to turn my cursor into an hourglass? I guess i need some tricks with the form name and/or the hwnd.
PS: Edneeis and I have already determined that it will work if you call the class from within the same project, so you need to have two different projects running in order to test this correctly.
-
Man that is wierd! I tried LoadCursor API and still no good. I usually call the Screen.MousePointer in the app around the call to the dll that way it leaves it to the developer if they want to show the cursor or not. Although I could see situations where it would be good to have it in the method being call, like a if the method performs more than one long action in the same method or something.
Well sorry I couldn't help. Let me know if you do get it working, because now it has peeked my curiosity.
-
I'm in the process of creating a DLL full of some commonly used code. It doesn't have everything, but it has a series of weird code that you would use often.
I just want to create a small sub that will disable a passed in object, and then make the hourglass appear. (Of course i'll have a way to reverse this)
I tried sending in the form name as an object, and then tried applying the hourglass within a With frmName but that didn't work either.
I guess i'm just trying to see if anyone is smarter than me (not too hard i suspect).
-
Did you Dim WithEvents myobject on the client code side?
Just curious.
-
Um...... no. Can you suggest how i should code that? I don't understand what you want me to do.
-
But what if the dll doesn't have any events?
-
I don't have any events in the DLL, and i'm not sure how that would help this situation.
-
OoooooooooooooooooooH!!! Damn it. Look at this.
Code:
Public Function Hourglass(ByRef frmName As Object)
frmName.MousePointer = vbHourglass
End Function
If you do that in the DLL, the hourglass code works. Damn. And i just released version 1 of my CommonCode DLL.
Thanks a lot made_of_asp. Your comments and thoughts pushed my mind in the right direction. I am thankfull for your ideas. It appears we have a solution folks.
-
No Problem
I dont know what ByRef does, io tried that without it and it didnt work.;) ;)