ActiveX Control

Hi,
I am making a activex textbox control in visual basic 6.0 and i want to create it so that when the user drags the mouse inside the textbox it changes colour and when their mouse exits the textbox the textbox goes back to the original colour..
How could i make this happen?
Thanks
LVL 1
adam8Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sudhi022299Commented:
Are you trying to simulate cut, copy , paste feature ?
0
MaximkaCommented:
Hi adam8!
Use API function


Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Type POINTAPI
        x As Long
        y As Long
End Type

Put Timer object on the control and in
Timer1_Timer Event put code that checks that mouse still in range
   dim tPOINT as POINTAPI
   dim l as long
   l=GetCursorPos(tPoint)
   If tPoint.x > Text1.Left and tPoint.x < text1.Left + text1.Width and
tPoint.y > Text1.Top and tPoint.y<Text1.Top+Text1.Width then
   screen.MousePointer=....
   else
       timer1.enabled=false
       screeen.mousePointer=vbNormal
   end if


put
  Timer1.Enabled= True in Text1_MouseMove event


Set the Timer1 interval to 1

Bye-bye.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
adam8Author Commented:
Thanks.
I knew there was a way to do that involving a timer but I don't like using timers too much unless i really need to because they slow down the program a bit.. Is there any other possibility.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

adam8Author Commented:
I tried what you told me and it didn't work..
Could you please help.
0
MaximkaCommented:
Hi adam8 !
Can You explane what a problem , because it has to work. So what You mean it doesn't work .
0
adam8Author Commented:
i will explain in detail.
when i wrote the first comment i said that when the cursor entered inside (Not clicked but moved inside) the textbox i wanted the textbox to change color and then when the mouse exited the textbox i wanted it to go back to it's normal color.
i tried the thing you wrote and i changed it so instead of the cursor changing the textox would change but instead the textbox stayed the color it was supposed to change into. so for some reason the program thought the cursor was always inside the textbox..
That was what went wrong.
Bye
0
MaximkaCommented:
I think that You forgot in Timer1_Timer
when You had write
  If 'Mouse not in range of text then
  Timer1.Enabled=False
to add the operator
  Text1.Color=...

try to put breakpoint on Timer1.Enabled=False
and look when it will arrive to it

Bye-bye...
0
MaximkaCommented:
If that will not work so I send the part of Timer1_Timer code and will see together.

Cheers.
0
adam8Author Commented:
i added the text1.color comment and i added it under the timer1_Timer
and i set the interval to 1 and i set the timer to enabled and i entered the API and i don't know what i am doing wrong.
0
adam8Author Commented:
something happened...
when i entered the cursor inside the textbox it changed color....
but when i moved the cursor outside the textbox it didn't go back to the original color....
How can this be fixed..
0
MaximkaCommented:
You have to fix it in IF condition by that You identificating textbox range.So in else of the IF You have to put
text1.enabled=false
text1.color=......
'it has to be some thing like that

l=GetCursorPos(MyPoint)
IF MyPoint.x > text1.left and MyPoint.X < text1.left+text1.width and MyPoint.y>text1.top and MyPoint.Y < text1.top + text1.Height then
    text1.color=.....
else
    text1.color=....
    timer1.enabled=false
end if
 
0
adam8Author Commented:
It is like that but i will try again...
The mousmove function enables timer1 but the mousemove function only occurs when the mouse moves within text1. which means if the mouse is outside the textbox the timer wont become enabled because the mouse move function wont be used...
Is that what is going wrong?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.