mmm, not sure that i understand this.
I take it the hex codes indicate base 16, but your saying that where the option in VB is for one value or the other, it can be substituted by the addition of the integer addition of those two or more integer values?
ie 2 Or 4 = 6?
reminds me of a favorite quote: there are 10 types of people in this world, those who understand binary and those who don't
I will try these, but don't really understand how it works.
thanks r
On Mon, 17 May 2004 10:47:52 +1000, <[EMAIL PROTECTED]> wrote:
A bit of "roll-your-own" binary could be in order here. I can't say if this is the only problem, but it's a start...
Converted to Mapinfo 'DEFINES for the Wait function DEFINE QS_KEY = 1 '&H1 DEFINE QS_MOUSEMOVE = 2 '&H2 DEFINE QS_MOUSEBUTTON = 4 '&H4 DEFINE QS_POSTMESSAGE = 8 '&H8 DEFINE QS_TIMER = 16 '&H10 DEFINE QS_PAINT = 32 '&H20 DEFINE QS_SENDMESSAGE = 64 '&H40 DEFINE QS_HOTKEY = 128 '&H80 DEFINE QS_MOUSE = 6 '(QS_MOUSEMOVE Or QS_MOUSEBUTTON) DEFINE QS_INPUT = 7 '(QS_MOUSE Or QS_KEY) DEFINE QS_ALLEVENTS = 191 '(QS_INPUT Or QS_POSTMESSAGE Or QS_TIMER Or QS_PAINT Or QS_HOTKEY) DEFINE QS_ALLINPUT = 255 '(QS_SENDMESSAGE Or QS_PAINT Or QS_TIMER Or QS_POSTMESSAGE Or QS_MOUSEBUTTON Or QS_MOUSEMOVE Or QS_HOTKEY Or QS_KEY)
Cheers, David Jerrard
Robert Crossley <[EMAIL PROTECTED]> on 17/05/2004 10:29:28 AM
Please respond to [EMAIL PROTECTED]
To: MapInfo List <[EMAIL PROTECTED]> cc: Subject: MI-L Wait Function
Hi all,
Still having some trouble with a function on XP, and an associate suggested that the problem may be helped by pausing the program to allow ?buffers to be flushed? before going onto the next operation (the exact description of the potential problem was on the assembly code side of where I am comfortable working).
Anyway, he suggested the sleep function does not help as there is a
problem with sleep on XP, and I don't want to pause the execution of
MapInfo, but rather just stop moving on until MapInfo had caught up. The
following VB code was given as an option, and while most of it is fairly
easy to convert (eg. Private Const -> DEFINE), I am having trouble working
out how to call the MsgWaitForMultipleObjects function. It is failing in
MapBasic as the define functions don't work with constants which use the
Or in them (understandable as it just substitutes the text). I am getting
a compile error when calling
If MsgWaitForMultipleObjects(0, 0, 0, timeRemaining, QS_ALLINPUT) > 0
Then
End If
Has anyone implemented this function in MapBasic? or is there an alternative? I want to pause MapInfo from processing the next operation while allowing it to finish what it was doing.
r
Original VB code Private Const QS_KEY = &H1 Private Const QS_MOUSEMOVE = &H2 Private Const QS_MOUSEBUTTON = &H4 Private Const QS_POSTMESSAGE = &H8 Private Const QS_TIMER = &H10 Private Const QS_PAINT = &H20 Private Const QS_SENDMESSAGE = &H40 Private Const QS_HOTKEY = &H80 Private Const QS_MOUSE = (QS_MOUSEMOVE Or QS_MOUSEBUTTON) Private Const QS_INPUT = (QS_MOUSE Or QS_KEY) Private Const QS_ALLEVENTS = (QS_INPUT Or QS_POSTMESSAGE Or QS_TIMER Or QS_PAINT Or QS_HOTKEY) Private Const QS_ALLINPUT = (QS_SENDMESSAGE Or QS_PAINT Or QS_TIMER Or QS_POSTMESSAGE Or QS_MOUSEBUTTON Or QS_MOUSEMOVE Or QS_HOTKEY Or QS_KEY)
Private Declare Function GetTickCount Lib "kernel32" () As Long Private Declare Function MsgWaitForMultipleObjects Lib "user32" (ByVal nCount As Long, pHandles As Long, ByVal fWaitAll As Long, ByVal dwMilliseconds As Long, ByVal dwWakeMask As Long) As Long
' ********************************************************* ' * MsgWait ' * ' * Sleeps for a specified time but allows ' * events to process immediately ' * ' * Input: ms - milliseconds to wait ' * Output: none ' ********************************************************* Public Sub MsgWait(ByVal ms As Long)
Dim start As Long, timeRemaining As Long, timeNow As Long
start = GetTickCount() timeRemaining = ms Do ' Sleep until timeout or event occurs MsgWaitForMultipleObjects 0, 0, 0, timeRemaining, QS_ALLINPUT timeNow = GetTickCount() If timeNow - start >= timeRemaining Then Exit Sub ElseIf timeNow < start Then ' Handle GetTickCount 49.7 day wrap around start = timeNow End If timeRemaining = timeRemaining - (timeNow - start) start = timeNow DoEvents Loop End Sub
Converted to Mapinfo
'DEFINES for the Wait function
DEFINE QS_KEY = &H1
DEFINE QS_MOUSEMOVE = &H2
DEFINE QS_MOUSEBUTTON = &H4
DEFINE QS_POSTMESSAGE = &H8
DEFINE QS_TIMER = &H10
DEFINE QS_PAINT = &H20
DEFINE QS_SENDMESSAGE = &H40
DEFINE QS_HOTKEY = &H80
DEFINE QS_MOUSE = (QS_MOUSEMOVE Or QS_MOUSEBUTTON)
DEFINE QS_INPUT = (QS_MOUSE Or QS_KEY)
DEFINE QS_ALLEVENTS = (QS_INPUT Or QS_POSTMESSAGE Or QS_TIMER Or QS_PAINT
Or QS_HOTKEY)
DEFINE QS_ALLINPUT = (QS_SENDMESSAGE Or QS_PAINT Or QS_TIMER Or
QS_POSTMESSAGE Or QS_MOUSEBUTTON Or QS_MOUSEMOVE Or QS_HOTKEY Or QS_KEY)
Sub MsgWait(ByVal ms As Integer) '----------------------- 'Written By: RC '-----------------------
Dim start As Integer Dim timeRemaining As Integer Dim timeNow As Integer
'Set up general error handler ONERROR GOTO ErrorHandler
Print "Waiting " + ms + " milliseconds."
start = GetTickCount()
timeRemaining = ms
Do
' Sleep until timeout or event occurs
If MsgWaitForMultipleObjects(0, 0, 0, timeRemaining, QS_ALLINPUT) > 0
Then
End If
timeNow = GetTickCount()
If timeNow - start >= timeRemaining Then
Exit Sub
ElseIf timeNow < start Then
' Handle GetTickCount 49.7 day wrap around
start = timeNow
End If
timeRemaining = timeRemaining - (timeNow - start)
start = timeNow
'DoEvents
Loop
EXIT SUB
ErrorHandler:
CALL ErrorMessage("MsgWait")
END SUB 'ProForma
--
Robert Crossley
Agtrix P/L 9 Short St PO Box 63 New Brighton 2483 Far Southern Queensland AUSTRALIA
153.549004 E 28.517344 S
P: 02 6680 1309 F: New Connection M: 0419 718 642 E: [EMAIL PROTECTED] W: www.agtrix.com W: www.wotzhere.com
--------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Message number: 11772
************************************************************ Opinions contained in this e-mail do not necessarily reflect the opinions of the Queensland Department of Main Roads, Queensland Transport or Maritime Safety Queensland, or endorsed organisations utilising the same infrastructure. If you have received this electronic mail message in error, please immediately notify the sender and delete the message from your computer. ************************************************************
--
Robert Crossley Agtrix P/L 9 Short St PO Box 63 New Brighton 2483 Far Southern Queensland AUSTRALIA
153.549004 E 28.517344 S
P: 02 6680 1309 F: New Connection M: 0419 718 642 E: [EMAIL PROTECTED] W: www.agtrix.com W: www.wotzhere.com
--------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Message number: 11774
