View previous topic :: View next topic |
Author |
Message |
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Tue Dec 17, 2002 4:19 pm Post subject: Mouse over Dialog |
|
|
Here is an example of how to create a mouseover for a dialog
Code: |
DIALOG CREATE,Mouse Over Dialog,-1,0,240,160
DIALOG ADD,STYLE,STYLE1,,18,B,,0000A0
DIALOG ADD,TEXT,TEXT1,36,62,112,13,Pass mouse over dialog
DIALOG ADD,TEXT,TEXT2,70,76,84,29,TEXT2,,STYLE1
DIALOG SHOW
:evloop
wait event,0
%e = @event()
goto %e
rem here starts the mouseover code
:timer
%%top = @sum(@Winpos(@Winexist(Mouse Over Dialog),T),4)
%%left = @Winpos(@Winexist(Mouse Over Dialog),L)
%%wide = @diff(@Winpos(@Winexist(Mouse Over Dialog),W),3)
%%high = @Winpos(@Winexist(Mouse Over Dialog),H)
%y = @mousepos(y)
%x = @mousepos(x)
if @equal(1111,@greater(%x,@sum(%%left,0))@greater(@sum(@sum(%%left,%%wide),0),%x)@greater(%y,@sum(%%top,0))@greater(@sum(@sum(%%top,%%high),0),%y))
dialog set,text2,OVER
else
dialog set,text2,OUT
end
goto evloop
:Close
|
_________________ Chris
Http://theblindhouse.com |
|
Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Tue Dec 17, 2002 7:57 pm Post subject: |
|
|
This is what I just made:
Code: |
DIALOG CREATE,Mouse Over Dialog,-1,0,189,224
DIALOG ADD,STYLE,STYLE1,,18,B,,0000A0
DIALOG ADD,BUTTON,BUTTON1,198,4,180,24,BUTTON1
DIALOG ADD,TEXT,TEXT1,8,6,,,Mouseover:
DIALOG ADD,LIST,LIST1,50,4,180,144
DIALOG ADD,PROGRESS,PROGRESS1,22,4,150,24,0
DIALOG SHOW
rem Put here the elements that should be used. Warning, not all kinds of elements work...
%%Mouseover = progress1|list1|button1
gosub MouseoverSTART
:evloop
wait event,0
goto @event()
:timer
rem Check where the mouse is
gosub Mouseover
rem Now %%Mouseover holds the current mouseover element.
rem If there isn't an element, but the mouse is over the dialog,
rem DIALOG will apear...
dialog set,text1,Mouseover: %%Mouseover
goto evloop
:Close
exit
rem Include this in all your code
:MouseoverSTART
list create,9
list add,9,
%%Mouseover = %%Mouseover|
repeat
list add,9,@substr(%%Mouseover,1,@pred(@pos(|,%%Mouseover)))
%%Mouseover = @strdel(%%Mouseover,1,@pos(|,%%Mouseover))
until @equal(@pos(|,%%Mouseover),0)
exit
:Mouseover
%%Counter = 0
list seek,9,0
%z = @wintext(@winatpoint(@mousepos(x),@mousepos(y)))
if @match(9,%z)
%%Mouseover = @item(9)
else
%%Mouseover =
end
if @equal(%%Mouseover,)
%%top = @sum(@Winpos(@Winexist(@dlgtext()),T),4)
%%left = @Winpos(@Winexist(@dlgtext()),L)
%%wide = @diff(@Winpos(@Winexist(@dlgtext()),W),3)
%%high = @Winpos(@Winexist(@dlgtext()),H)
%y = @mousepos(y)
%x = @mousepos(x)
if @equal(1111,@greater(%x,@sum(%%left,0))@greater(@sum(@sum(%%left,%%wide),0),%x)@greater(%y,@sum(%%top,0))@greater(@sum(@sum(%%top,%%high),0),%y))
%%Mouseover = dialog
end
end
exit |
It just checks for the element name, and not all type of elements can be used, but I was too lazy too make a script that checks for the exact location of elements....  |
|
Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
|
Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Dec 17, 2002 9:03 pm Post subject: |
|
|
OOPS - that link is VDS3 code. This should work in both VDS3 and VDS4:
_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Code: |
Title Mouse Over Effects
DIALOG CREATE,Mouse Over Efects,-1,0,250,250
DIALOG ADD,STYLE,STYLE4,Tahoma,10,BC,DKRED,RED
DIALOG ADD,STYLE,STYLE3,Tahoma,10,Bi,BACKGROUND,DKBLUE
DIALOG ADD,STYLE,STYLE2,Tahoma,10,BC,LTGREEN,DKGREEN
DIALOG ADD,STYLE,STYLE1,Tahoma,10,BC,DKGREEN,LTGREEN
DIALOG ADD,BUTTON,BUTTON,20,30,80,40,Hello !!,,STYLE3
DIALOG ADD,BUTTON,BUTTON1,20,30,80,40,Hello !!
DIALOG ADD,CHECK,CHECK,70,30,180,20,Check box,,,STYLE3,click
DIALOG ADD,CHECK,CHECK1,70,30,180,20,Check box
DIALOG ADD,CHECK,CHECK2,90,30,180,20,Another check,,,STYLE1,click
DIALOG ADD,CHECK,CHECK21,90,30,180,20,Another check,,,STYLE2
DIALOG ADD,PROGRESS,PROGRESS,130,30,80,40
DIALOG ADD,BUTTON,BUTTON2,132,32,76,36,Hola !!!
DIALOG ADD,TEXT,back,190,40,100,20,,STYLE2
DIALOG ADD,TEXT,TEXT,192,42,96,16,Click me !!,,STYLE4,click,hand
DIALOG ADD,TEXT,TEXT1,192,42,96,16,Click me !!,,STYLE1
DIALOG SHOW
rem create a list and put in the elementes for mouse over event
list create,1
list loadtext,1
"button1
"text1
"check1
"check21
"progress
rem end of the list configuration
:loop
%e = @event()
if %e
goto %e
end
rem here starts the mouseover code
%%xyz = 0
repeat
list seek,1,%%xyz
%y = @diff(@mousepos(y),22)
rem we reduce %y in 22 pixels due to the window title height
%x = @diff(@mousepos(x),3)
rem then reduce %x due to the window 3D border
rem here we compare the position of the cursor with the 4 element coordenates
rem @greater(%x,@sum(@dlgpos(@item(1),l),@dlgpos(,l)))
rem @greater(@sum(@sum(@dlgpos(@item(1),l),@dlgpos(@item(1),w)),@dlgpos(,l)),%x)
rem @greater(%y,@sum(@dlgpos(@item(1),t),@dlgpos(,t)))
rem @greater(@sum(@sum(@dlgpos(@item(1),t),@dlgpos(@item(1),h)),@dlgpos(,t)),%y)
if @equal(1111,@greater(%x,@sum(@dlgpos(@item(1),l),@dlgpos(,l)))@greater(@sum(@sum(@dlgpos(@item(1),l),@dlgpos(@item(1),w)),@dlgpos(,l)),%x)@greater(%y,@sum(@dlgpos(@item(1),t),@dlgpos(,t)))@greater(@sum(@sum(@dlgpos(@item(1),t),@dlgpos(@item(1),h)),@dlgpos(,t)),%y))
dialog hide,@item(1)
else
dialog show,@item(1)
end
rem replace the over effect with other vds command
%%xyz = @succ(%%xyz)
until @equal(%%xyz,@count(1))
rem end of the mouseover code
goto loop
:buttonBUTTON
:button1BUTTON
:button2BUTTON
:button21BUTTON
:textCLICK
info Hello from Spain !!!@cr()Hola a todos !!!
goto loop
:checkCLICK
if @dlgtext(check)
dialog set,check1,1
else
dialog set,check1,
end
goto loop
:check2CLICK
if @dlgtext(check2)
dialog set,check21,1
else
dialog set,check21,
end
goto loop
:close
info Adios !!
|
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Wed Dec 18, 2002 2:33 pm Post subject: |
|
|
That one doesn't work for me... I got an error at line 54 'Element name not valid'. When I used an info, the element name was 'button1'...
Ps. I used VDS 4 on Windows XP Home edition... |
|
Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Wed Dec 18, 2002 7:58 pm Post subject: |
|
|
Sorry Skit,
It isn't my code, I just added extra commas to allow for
tooltips in VDS4. It may be full of bugs, I've only ran it a
few short times and thought the effects were cool.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Wed Dec 18, 2002 8:26 pm Post subject: |
|
|
That's what I was thinking.... Mac & VDS 4 ???
Well, maybe somewhere in time!  |
|
Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Wed Dec 18, 2002 8:34 pm Post subject: |
|
|
 _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Wed Dec 18, 2002 8:39 pm Post subject: |
|
|
Still I think we need a chatbox on this site... Just a little one... |
|
Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
|
Back to top |
|
 |
cnodnarb Professional Member


Joined: 11 Sep 2002 Posts: 763 Location: Eastman, GA
|
Posted: Sun Dec 29, 2002 3:14 am Post subject: A Better MouseOver |
|
|
I don't know how we all could have missed this for so long. It seems so obvious.
Unlike most of my code this one is short and understandable! ROFL
Code: |
DIALOG CREATE,A better mouseover,-1,0,240,160
DIALOG ADD,BUTTON,BUTTON1,57,51,,,BUTTON1
dialog add,status,status1
DIALOG SHOW
rem grab hwnd of button1
%%button1 = @winexists(@win(~button1))
:timer
rem check hwnd of mouseover dialog
if @equal(@winatpoint(@mousepos(X),@mousepos(Y)),%%button1)
dialog set,status1,MouseOver!
else
dialog set,status1,MouseOut!
end
:evloop
wait event,.1
goto @event()
:close
exit
|
NodNarb |
|
Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Sun Dec 29, 2002 4:19 am Post subject: |
|
|
Yikes..that's too obvious. _________________ -Sheep
My pockets hurt... |
|
Back to top |
|
 |
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Sun Dec 29, 2002 8:15 am Post subject: |
|
|
Nice one, NodNarb  |
|
Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Sun Dec 29, 2002 1:38 pm Post subject: |
|
|
This can also be done without having to grab the button handle.
Code: | title Mouseover Test
DIALOG CREATE,Button Mouseover,-1,0,240,160
DIALOG ADD,BUTTON,BUTTON1,57,51,,,BUTTON1
DIALOG ADD,STATUS,STAT
DIALOG SHOW
:timer
if @equal(@wintext(@winatpoint(@mousepos(x),@mousepos(y))),BUTTON1)
dialog set,STAT,MouseOver on BUTTON1
else
dialog set,STAT,MouseOut on BUTTON1
end
:evloop
wait event,.1
goto @event()
:close
exit |
_________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Sun Dec 29, 2002 1:53 pm Post subject: |
|
|
But what if you have to check if the mouse is over an edit box?
Solution: Code: |
if @equal(@wintext(@winatpoint(@mousepos(x),@mousepos(y))),@dlgtext(EDIT1))
dialog set,STAT,MouseOver on EDIT1
end |
The only bad thing about this way is that how more you want to check, how more (and longer) the Timer event will be... But the idea is pretty good! |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|