I was able to overcome this limitation by implementing a timer in an
external DLL and then using the Integrated Mapping support to notify the
MBX that the timer interval had expired. The basics are here for anyone
who wants to attempt this:
In a C++ DLL (using MFC extensions):
DMapInfo mapinfo; //MapInfo Integrated Mapping Object
char strMBApp[255]; //name of mb app, set in StartTimer()
char strMessage[255]; //message to send to MB, set in StartTimer()
//this get's called by the timer event
VOID CALLBACK MyTimerProc(
HWND hWnd, // handle of window for timer
UINT uMsg, // WM_TIMER message
UINT idEvent, // timer identifier
DWORD dwTime // current system time
)
{
//get the current running mb apps
DMBApplications mbApps;
mbApps.AttachDispatch(mapinfo.GetMBApplications(), false);
//find my app
DMapBasicApplication mbApp;
_variant_t vt(strMBApp);
LPDISPATCH pDisp = mbApps.Item(vt);
if ( pDisp != NULL )
{
//send a message to my app
//this will end up in the RemoteMsgHandler
mbApp.AttachDispatch(pDisp, false);
mbApp.Do(strMessage);
mbApp.ReleaseDispatch();
}
else
{
mapinfo.Do("Note \"Could Not Find Application.\"");
}
mbApps.ReleaseDispatch();
}
//Call this from MapBasic to start the timer
//iSeconds is the timer interval in seconds
//sAppName is the name of the calling mapbasic app (i.e., "myapp.mbx")
//pDispatch is the disp pointer of MI (SystemInfo(17))
//sMessage is the message to send to RemoteMsgHandler
//returns the timer id needed to kill the timer when you're done
STDAPI_(UINT) StartTimer(UINT iSeconds, LPCSTR sAppName, LPDISPATCH
pDispatch, LPCSTR sMessage)
{
strcpy(strMBApp, sAppName);
strcpy(strMessage, sMessage);
//attach to MI Pro
mapinfo.AttachDispatch(pDispatch, false);
return SetTimer(0, 0, iSeconds*1000, (TIMERPROC)MyTimerProc);
}
//Call this from MapBasic to kill the timer
//iTimerID is the timer id returned by StartTimer()
STDAPI_(void) EndTimer(UINT iTimerID)
{
KillTimer(0, iTimerID);
mapinfo.ReleaseDispatch();
}
Then, in MB:
Declare Function StartTimer Lib "mydll.dll"
(ByVal iSeconds as Integer,
ByVal sAppName as String,
ByVal iDispatch as Integer,
ByVal sMessage as String) as Integer
Declare Sub EndTimer Lib "mydll.dll"
(ByVal iTimerID as Integer)
"Warren Vick, Europa Technologies Ltd." wrote:
>
> Hello Troy,
>
> Unfortunately MI/MB does not have any concept of event timers. It is
> possible to write a MapBasic program which would wait a period of time and
> then refresh, but this would hog the whole Pro session and not allow any
> other use of the application (apart from stopping the looping program). The
> best solution is to use an external timer program (see recent thread about
> animation) to inject a DDE message into Pro. Pro can then have a MB program
> listening for this message and refresh all/some of the mapper windows. Sorry
> it's not a simple solution!
>
> Regards,
> Warren Vick
> Europa Technologies Ltd.
> http://www.europa-tech.com
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Friday, August 09, 2002 6:47 PM
> To: [EMAIL PROTECTED]
> Subject: RE: MI-L Connecting to Live ODBC data and refreshing
>
> Does anyone have an idea how to automatically refresh a mapview? I would
> imagine it would involve using the mapbasic window and issuing some
> statement like, start a timer for 4 seconds, if the timer = zero, refresh
> the map window, restart the timer, or something like that. I have neither
> mapbasic nor any experience with it. Anyone think this would work for my
> needs?
>
> Thanks,
> Troy
> Rural/Metro Fire Dept.
>
> ---------------------------------------------------------------------
> List hosting provided by Directions Magazine | www.directionsmag.com |
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> Message number: 2447
>
> ---------------------------------------------------------------------
> List hosting provided by Directions Magazine | www.directionsmag.com |
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> Message number: 2453
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Gary Schwartz
Director of Software Development
Mapping Analytics
2 Graham Road West
Ithaca, NY 14850
(585) 271-6490
[EMAIL PROTECTED]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 2461