Can't Exit Loop - Repeating mouse button Part 2 OI7.1.1 (OpenInsight 32-Bit)
At 25 MAY 2005 12:54:35PM Don Muskopf wrote:
I'm still trying to simulate the keyboard repeat behavior for mouse button clicks. Getting the repeat behavior to work either with the timer, or using WINMSG and calling a loop is pretty straight forward. HOWEVER, GETTING IT TO STOP REPEATING IS THE PROBLEM. For example, see the loop in the code below. Once you enter the loop you can't get out by sending, say, a middlemouse buttondown message to the button control that started the loop. You can exit the loop by executing an event on another control, say by clicking on the Cancel button of the form, but the process must still keep going because my CPU usage stays at 65% and the form designer fails to respond. I have also tried the timer approach, but once the timer starts I never seem to be able to stop it, either. This is making me loopy, lol.
1) ON THE WINDOW CREATE EVENT
declare function Send_Message
Equ TRUE$ to 1
Equ WM_LBUTTONDOWN$ TO '0x201'
Equ WM_MBUTTONDOWN$ TO '0x207'
ButtonDown=Send_Message(@Window:".BUTTON_PREVIOUSMONTH", "QUALIFY_EVENT", WM_LBUTTONDOWN$, TRUE$)
ButtonDownM= Send_Message(@Window:".BUTTON_PREVIOUSMONTH", "QUALIFY_EVENT", WM_MBUTTONDOWN$, TRUE$)
RETURN 1
2) ON THE WINMSG EVENT OF THE BUTTON_PREVIOUSMONTH CONTROL
Declare Function DWM_Repeat_MouseClick
call DWM_Repeat_MouseClick(CtrlEntID, CtrlClassID, hWnd, Message, wParam, lParam)
RETURN 0
3)DWM_REPEAT_MOUSECLICK FUNCTION
Function DWM_Repeat_MouseClick(CtrlEntID, CtrlClassID, hWnd, Message, wParam, lParam)
declare Function DWM_TEST_FUNCTION
declare subroutine yield
ExitLoop='
Equ TRUE$ to 1
Equ WM_LBUTTONDOWN$ TO '513'
Equ WM_MBUTTONDOWN$ TO '519'
If message=WM_MBUTTONDOWN$ then ExitLoop=true$
If message=WM_LBUTTONDOWN$ then ExitLoop=0
IF ExitLoop 1 and ExitLoop 0 then goto Exit
* Help, let me out of this loop!
Loop
Until ExitLoop Do
yield()
Do anything here or nothing, still can't get out of the loopRepeat
Exit:
RETURN 0
At 25 MAY 2005 01:34PM [email protected] wrote:
If we're reading your request and code you wish to exit from within a tight closed loop with no way that the exit condition can be met as the loop has to be exited for the exit condition to be met (OI code is not reentrant). You need to check an external property or something and exit based on that. For example if you wanted to loop until a window was closed, check for the handle of the window. If you wanted another control to control the closing of the loop use that control to set a custom property of the window and check that within the loop.
The Sprezzatura Group Web Site
World Leaders in all things RevSoft
At 25 MAY 2005 02:03PM Don Muskopf wrote:
Thanks, Sprezzatura. I didn't know that OI code was not reentrant.