Sign in to follow this  
Followers 0
anand

How to destroy an event call?

2 posts in this topic

Hi,

I am facing big problem. First please find below code.

#include <GUIConstantsEx.au3>

#include<GUIConstants.au3>

#include <WindowsConstants.au3>

#include <GuiStatusBar.au3>

#include <GuiButton.au3>

#Include <Misc.au3>

;Create Window

;Local $window

Global $record=1,$play,$Stop,$next,$previous,$slidebar,$statusbar,$window,$forward,$backward,$mdown=0

$dll = DllOpen("user32.dll")

Opt("GUIOnEventMode",1) ; Change to OnEvent mode

$window=GUICreate("Event Player",500,100,720,0,$WS_EX_APPWINDOW ,$WS_EX_TOPMOST)

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"lmousedown")

GUISetOnEvent($GUI_EVENT_PRIMARYUP,"lmouseup")

GUISetOnEvent($GUI_EVENT_CLOSE, "closewin")

$statusbar=_GUICtrlStatusBar_Create($window)

$slidebar=GUICtrlCreateSlider(200,10,200,50)

GUISetOnEvent($GUI_EVENT_MOUSEMOVE,"lmousemove")

;GUICtrlSetOnEvent($slidebar,"clickslide")

GUICtrlSetLimit($slidebar, 200, 0) ;change min/max value

$play=GUICtrlCreateButton(">",10,10,30,30);Create Play button

GUICtrlSetOnEvent($play,"clickplay");Set event for play button

$Stop=GUICtrlCreateButton("()",40,10,30,30);Create Stop button

GUICtrlSetOnEvent($Stop,"clickstop"); set event for stop button

$backward=GUICtrlCreateButton("<",70,10,30,30);Create backward button

GUICtrlSetOnEvent($backward,"clickbackward");set event for backward button

$forward=GUICtrlCreateButton(">",100,10,30,30);Create forward button

GUICtrlSetOnEvent($forward,"clickforward");Set event for forward button

$previous=GUICtrlCreateButton("<<",130,10,30,30);Create Next button

GUICtrlSetOnEvent($previous,"clickprevious");set event for Previous button

$next=GUICtrlCreateButton(">>",160,10,30,30);Create next button

GUICtrlSetOnEvent($next,"clicknext");Set event for Next button

GUISetState();Set window visible true

GUICtrlSetData($slidebar,0);Sliderbar start position

Do

$msg = GUIGetMsg()

if $msg=$slidebar Then ToolTip(GUICtrlRead($slidebar))

Sleep(100)

;GUICtrlSetData($slidebar,GUICtrlRead($slidebar)+1)

Until $msg = $GUI_EVENT_CLOSE

;Click on play button

func clickplay()

;MsgBox(0,"test",_GUICtrlButton_GetText($play))

if _GUICtrlButton_GetText($play) = ">" then

_GUICtrlButton_SetText($play,"||")

$i=0

$k=0

while True

If _IsPressed("1", $dll) Then

if _GUICtrlButton_GetText($play) = "=" then _GUICtrlButton_SetText($play,">")

Return

EndIf

$k=GUICtrlRead($slidebar)

GUICtrlSetData($slidebar,GUICtrlRead($slidebar)+1)

Sleep(100)

if GUICtrlRead($slidebar)=200 then

$record=$record+1

GUICtrlSetData($slidebar,0);Sliderbar start position

_GUICtrlStatusBar_SetText($statusbar,"Record number:"&$record)

Sleep(100)

EndIf

$i=$i+1

If _IsPressed("1", $dll) Then

Return

_GUICtrlButton_SetText($play,">")

EndIf

WEnd

Else

_GUICtrlButton_SetText($play,">")

EndIf

EndFunc

;Click on stop button

func clickstop()

EndFunc

;Click on backward button

func clickbackward()

GUICtrlSetData($slidebar,GUICtrlRead($slidebar)-1)

EndFunc

;Click onforward button

func clickforward()

GUICtrlSetData($slidebar,GUICtrlRead($slidebar)+1)

EndFunc

;Click on previous button

func clickprevious()

;GUICtrlSetData($slidebar,0);Sliderbar start position

if $record>1 then $record=$record-1

_GUICtrlStatusBar_SetText($statusbar,"R.no: "&$record)

EndFunc

;Click on next button

func clicknext()

;GUICtrlSetData($slidebar,0);Sliderbar start position

$record=$record+1

_GUICtrlStatusBar_SetText($statusbar,"R.no: "&$record)

EndFunc

;Click down on window

func lmousedown()

$mdown=1

Execute("return")

EndFunc

;mouse move on window

func lmousemove()

if $mdown=1 Then

_GUICtrlButton_SetText($play,">")

_GUICtrlStatusBar_SetText($statusbar,"R.no: "&$record&":"&GUICtrlRead($slidebar))

EndIf

EndFunc

;mouse up on window

func lmouseup()

$mdown=0

EndFunc

;Window close event

func closewin()

Exit

EndFunc

;Drag slider

func clickslide()

;MsgBox(0,"test","Slider clicked")

EndFunc

Share this post


Link to post
Share on other sites



I have uploadted the output of the below code. Please find that also.

In this what i did is i created one window like media player. I need the functionalities similar to the windows media player. So, i created play/pause,next,previous,forward,bacward and slider. I added events for all these controls.

What i want is to if i click play button the slider must move. If i click pause button again the slider should stop the movement. The slider pointer postion is as it is. Again if i press play button it will move again. It will continue the same way all the times. I don't have problem in this. It is working fine.

The problem is coming while i drag the slider pointer. For example,you clicked play button. The slider pointer started to moving. During the slider pointer movement if you drag the slider pointer it will allow you to drag right or left. At this point i need to stop the play button event ie) click event. Because if you change the slider pointer no need to execute from the current position. Need to change the values.

For clear information,

I have added drag event for slider. I have added click event for play button. If you click play button the corresponding click event method will call. In this what i did is that i had written code inside while loop for slider movement. After pressing play button the slider pointer will move. Think this time if i drag the slider right side or left side the drag event method will get called. The control will go to start execute the statements inside the drag event. once the completeion of executing all the statements inside the drag event the control will again transfer back to play event method and it will continue the execution.

More details,

In this point i don't want to go back to contiue the execution in play event method. I need to exit out from the play event and pause the script.

What i want is, If i drag the slider pointer manually the play event should be come to over and no need to proceed/continue again in the loop after executing statements in drag event for slider is over.

Regards!

Anantharajan.

post-46738-1236776574_thumb.jpg

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0