Jump to content

Flash-matic


trancexx
 Share

Recommended Posts

@ValeryVal, you need to be more specific.

This OCX (MapWindow GIS ActiveX) has many interfaces, but main one is very complex for AutoIt and AutoObject.

It's name - _DMap.

This example (IE only) allows to change size of of _DMap.

File DMap.html:

<HTML><HEAD><TITLE>New Page</TITLE></HEAD>
<BODY>
<script type="text/javascript">
<!--
function onclickbtn()
{
alert("Change back color to 0xCCCCAA");
document.map.BackColor=0xCCCCAA;
alert("resize control");
document.map.Resize(500,500)
}
-->
</script>
<p>
<div>
<form id="Form1" method="post" runat="server">
<OBJECT id="map2" style="Z-INDEX: 101; LEFT: 32px; WIDTH: 440px; POSITION: absolute; TOP: 56px; HEIGHT: 264px"
classid="clsid:54F4C2F7-ED40-43B7-9D6F-E45965DF7F95" name="map" VIEWASTEXT>
</OBJECT>
<input type="button" onclick='onclickbtn();' value="Drive Map">
</form>
</div>
</BODY>
</HTML>

My AutoIt sample:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
Global $oMap, $oSf

$oMap = ObjCreate("MAPWINGIS.Map.1")
if not IsObj($oMap) then
  MsgBox(0,'','Can not create Map object!')
  exit
endif
MsgBox(0,'','Creation MapWinGIS Map object is OK!')

$GUI = GUICreate("", 640, 580,(@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2)

$GUI_OBJ = GUICtrlCreateObj($oMap, 10, 50, 620, 520)
GUISetState()
$oMap.Resize(500,500)

While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
 Case $GUI_EVENT_CLOSE
  ExitLoop
 EndSwitch
WEnd

Exit

It shows that $oMap is Object.

But call of method Resize(500,500) is failed.

$oMap can be embedded into window by GUICtrlCreateObj. To view it you can comment line with $oMap.Resize(500,500).

The same error will be exposed with help AutoItObject methods _AutoItObject_ObjCreate.

My Delphi example with this ocx works fine, though.

The Delphi file with data read from a Type Library has the following lines:

// *********************************************************************//
// DispIntf:  _DMap
// Flags:   (4112) Hidden Dispatchable
// GUID:    {1D077739-E866-46A0-B256-8AECC04F2312}
// *********************************************************************//
  _DMap = dispinterface
    ['{1D077739-E866-46A0-B256-8AECC04F2312}']

It is clear that _DMap has interface type like dispinterface!

How can I implement this _DMap instance by AutoItObject UDF?

Thank you for any comments.

:)

The point of world view

Link to comment
Share on other sites

The problem with dispinterface could be resolved by AutoObject UDF, I think.

This _DMap can be implement as Event object, where the body of event method has direct call by IDispach.Invoke method using DispId and method's formal parameters. So it would be like Delphi procedure DispCallByIDProc which is used to call dispatch method identified by dispatch identifier in dispinterface.

See about dispinterface in Delphi here

The point of world view

Link to comment
Share on other sites

  • 2 weeks later...

The problem with dispinterface could be resolved by AutoObject UDF, I think.

This _DMap can be implement as Event object, where the body of event method has direct call by IDispach.Invoke method using DispId and method's formal parameters. So it would be like Delphi procedure DispCallByIDProc which is used to call dispatch method identified by dispatch identifier in dispinterface.

See about dispinterface in Delphi here

Methods of that interface are flagged as STDCALL FUNC DISPATCH. That means they are accessible only thru IDispatch no matter how confusing that may sound. You should QueryInterface (created object) for IDispatch and implement custom Dispatch with for example _AutoItObject_ObjectFromDtag.

Or maybe it would be enough to wrapp returned pointer of that QueryInterface call. If so, even easier.

edit: as my 2 cents

Edited by trancexx
Link to comment
Share on other sites

This is a grand piece of work, but reading it makes me feel wholly retarded.

If someone could please offer an example of using this wonderfulness to play a local swf using the relative ocx, i would be much obliged.

edit: nm, got it. Using just option 4 and the constants, and then everything else as normal.

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

This is a grand piece of work, but reading it makes me feel wholly retarded.

If someone could please offer an example of using this wonderfulness to play a local swf using the relative ocx, i would be much obliged.

edit: nm, got it. Using just option 4 and the constants, and then everything else as normal.

Excellent, sit A.

The thing you ask can be reduced to:

#include "AutoitObject.au3"
#include <AutoitObject.au3>

; Error monitoring
Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")
Func _ErrFunc()
    ConsoleWrite("COM Error, ScriptLine(" & $oError.scriptline & ") : Number 0x" & Hex($oError.number, 8) & " - " & $oError.windescription & @CRLF)
EndFunc


_AutoItObject_Startup()

Global Const $sCLSID_ShockwaveFlash = "{D27CDB6E-AE6D-11CF-96B8-444553540000}"

Global $oShockwaveFlash = ObjCreate("ShockwaveFlash.ShockwaveFlash") ;
If Not IsObj($oShockwaveFlash) Then $oShockwaveFlash = _AutoItObject_ObjCreateEx(@ScriptDir & "\Flash10m.ocx", $sCLSID_ShockwaveFlash)

If Not IsObj($oShockwaveFlash) Then Exit -11

Global $GUI = GUICreate("Test DLL", 600, 530)
Global $hControl = GUICtrlCreateObj($oShockwaveFlash, 0, 50, 600, 400)

Global $sPath = "http://autoitobject.origo.ethz.ch/system/files/AutoItObject.swf" ; can be local file on the disk too
$oShockwaveFlash.Movie = $sPath

GUISetState()

While 1
    If GUIGetMsg() = -3 Then ExitLoop
WEnd

For that you can use Macromedia's pre-Adobe Flash.ocx too. That one is no bigger than 430kB in upx-ed version 6, or 800 and something originally if I recall correctly.

Link to comment
Share on other sites

thanks,

mine ended up as such:

_AutoItObject_Startup()

Global Const $sCLSID_ShockwaveFlash = "{D27CDB6E-AE6D-11CF-96B8-444553540000}"
Global Const $sIID_IShockwaveFlash = "{D27CDB6C-AE6D-11CF-96B8-444553540000}"
Global $oShockwaveFlash

; 4. _AutoItObject_ObjCreateEx. This one works from server file directly (doesn't require installed flash, only flash dll)
If Not IsObj($oShockwaveFlash) Then $oShockwaveFlash = _AutoItObject_ObjCreateEx(@ScriptDir & "\Flash10o.ocx", $sCLSID_ShockwaveFlash, $sIID_IShockwaveFlash)

fileinstall ("movie.swf" , "D:\movie.swf" , 1)


    Global $flash = GUICreate("Videos", @DesktopWidth, @DesktopHeight, 0, 0, BitOR($WS_POPUPWINDOW, $WS_EX_TOPMOST, $DS_SETFOREGROUND)) ;  $WS_CLIPSIBLINGS , $WS_CLIPCHILDREN ,
    GUISetBkColor (0x00)
    WinSetOnTop("Videos", "", 1)

    Global $vid = GUICtrlCreateObj($oShockwaveFlash, 270, 200, @DesktopWidth / 1.8, @DesktopHeight / 1.8)

    With $oShockwaveFlash
        .bgcolor = "#c0c0c0"
        .Movie = "D:\movie.swf" 
        .ScaleMode = 3
        .Loop = "True"
        .wmode = ""
        .FlashVars = ""
        .Play()
    EndWith

GUISetState()

any reliable places to find the oldschool flash.ocx files?

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

Websense let me through, thank you ma'am, you rock :)

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

  • 2 weeks later...

Methods of that interface are flagged as STDCALL FUNC DISPATCH. That means they are accessible only thru IDispatch no matter how confusing that may sound. You should QueryInterface (created object) for IDispatch and implement custom Dispatch with for example _AutoItObject_ObjectFromDtag.

Or maybe it would be enough to wrapp returned pointer of that QueryInterface call. If so, even easier.

Now I've resolved my problems by additional dll to wrap _DMap.

BTW. This dll has function to return Nil value for call some methods of other interfaces in MapWindow GIS ActiveX.

:unsure:

Do you know about working Nil implementation in AutoIt?

Edited by ValeryVal

The point of world view

Link to comment
Share on other sites

Now I've resolved my problems by additional dll to wrap _DMap.

May I see it?

BTW. This dll has function to return Nil value for call some methods of other interfaces in MapWindow GIS ActiveX.

:unsure:

Do you know about working Nil implementation in AutoIt?

How is Nil defined?

edit: after some reading and thinking I've come to conclusion that this is definitely a design error with _DMap dispatch implementation. Devs of that module use MFC wrapper/framework to build that dispatch. This is causing different situations.

Object creation process in that case should be different than it's with native ObjCreate function or any of available AutoItObject functions for the job.

The solution could be that they override MFC's IsInvokeAllowed() function; It should return TRUE.

Another thing to consider could be possible incompleteness of AutoIt's internal GUICtrlCreateObj() function and current implementation. I know that function query passed object for IOleObject. What happens (or not happens) afterwards could also be the cause of this funny and annoying quirk.

What confuses me is you saying that it works with additional dll. Strange. Does it work with AutoIt GUI object control or something else? How is object created?

Edited by trancexx
Link to comment
Share on other sites

How is Nil defined?

It is defined as method of IMyMapWinGis interface:

{ Dispatch interface for MyMapWinGis Object }

IMyMapWinGis = interface(IDispatch)

.....

function Get_Nil: IDispatch; safecall;

.....

The implementation of this method is very easy:

function TMyMapWinGis.Get_Nil: IDispatch;

begin

Result := Nil;

end;

edit: after some reading and thinking I've come to conclusion that this is definitely a design error with _DMap dispatch implementation. Devs of that module use MFC wrapper/framework to build that dispatch. This is causing different situations.

Object creation process in that case should be different than it's with native ObjCreate function or any of available AutoItObject functions for the job.

The solution could be that they override MFC's IsInvokeAllowed() function; It should return TRUE.

Yes. You are right!

I'm trying to discuss this error with it's author. Here:

http://www.mapwindow.org/phorum/read.php?3,22176

As you see Sergei gave me moral charter to adapt the _DMap for my intention.

Another thing to consider could be possible incompleteness of AutoIt's internal GUICtrlCreateObj() function and current implementation. I know that function query passed object for IOleObject. What happens (or not happens) afterwards could also be the cause of this funny and annoying quirk.

No. Apart from the known invalid pass of hWnd into COM object the AutoIt rules fine for me. Maybe some bug (or feature) with Enum, too.

:unsure:

What confuses me is you saying that it works with additional dll. Strange. Does it work with AutoIt GUI object control or something else? How is object created?

Yes. MapWrap.dll is DLL for Class_MyMapWinGis

const

LIBID_MapWrap: TGUID = '{XXXXXX}';

const

{ Component class GUIDs }

Class_MyMapWinGis: TGUID = '{XXXXXX}';

type

{ Forward declarations: Interfaces }

IMyMapWinGis = interface;

IMyMapWinGisDisp = dispinterface;

DMyMapEvents = dispinterface;

This is function to create $oMapWrap

;==============================
Func CreateMap($hWnd)
  $oMapWrap = ObjCreate("MapWrap.MyMapWinGis")
  if not IsObj($oMapWrap) then
    ConsoleWrite('Can not create Map object!' & @CrLF)
    exit
  endif
 $oMap = $oMapWrap.IMap
 if not IsObj($oMap) then
   ConsoleWrite('Can not create Map object!' & @CrLF)
   exit
 endif
 $oMap.MapResizeBehavior = $rbIntuitive
 $oMap.SendSelectBoxFinal = True
 $oMap.SendMouseUp = True
 $oNil = $oMapWrap.Get_Nil
endfunc

You can see here how I get $oNil object. It allows to call Open method of ShapeFile object.

Object $oMap is ActiveX Control which is repaired _DMap object. I can embed $oMap into GUI by this line:

$Preview = GUICtrlCreateObj($oMap, $PreviewX, $PreviewY,  $PreviewW, $PreviewH)

The ShapeExplorer screenshot:

post-9395-0-61606200-1303731844_thumb.pn

Edited by ValeryVal

The point of world view

Link to comment
Share on other sites

...That's variant with vt=VT_DISPATCH and data=0.

Nice.

Suggest to Sergei overriding IsInvokeAllowed function

After this:

In general, considering my lack of time, there is little chance that I'll implement it in near future. But I'd recommend to take initiative in your own hands :>

It will be perky tip, I think. Thereto I can't use his _DMapEvents.

:unsure:

Thank you.

The point of world view

Link to comment
Share on other sites

The solution could be that they override MFC's IsInvokeAllowed() function; It should return TRUE.

It's great that IsInvokeAllowed returns False. In this case I have free hands for adaption some meth&prop&vars&results of _DMap and other interfaces to chaste AutoIt facilities. The process doesn't complete, yet.

The point of world view

Link to comment
Share on other sites

It's great that IsInvokeAllowed returns False. In this case I have free hands for adaption some meth&prop&vars&results of _DMap and other interfaces to chaste AutoIt facilities. The process doesn't complete, yet.

Fuck that. :unsure: I took initiative too.

Could you try the latest AutoItObject 1.2.5.0 (link)? I thing this should work now:

#AutoIt3Wrapper_UseX64=n

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

#include "AutoitObject.au3"

; Error monitoring
Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")
Func _ErrFunc()
    ConsoleWrite("COM Error, ScriptLine(" & $oError.scriptline & ") : Number 0x" & Hex($oError.number, 8) & " - " & $oError.windescription & @CRLF)
EndFunc   ;==>_ErrFunc


_AutoItObject_Startup()

Global $oMap = _AutoItObject_ObjCreate("MAPWINGIS.Map.1")
If Not IsObj($oMap) Then $oMap = _AutoItObject_ObjCreateEx(@ScriptDir & "\MapWinGIS.ocx", "{54F4C2F7-ED40-43B7-9D6F-E45965DF7F95}") ; , "{1D077739-E866-46A0-B256-8AECC04F2312}")

ObjEvent($oMap, "_Map_Events_", "_DMapEvents")

Global $hGUI = GUICreate("_Map Test", 640, 580, -1, -1, $WS_OVERLAPPEDWINDOW)

Global $hGUI_OBJ = GUICtrlCreateObj($oMap, 10, 50, 620, 420)
Global $hButton = GUICtrlCreateButton("Click", 100, 480, 100, 25)


GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $hButton
            $oMap.BackColor = Random(0, 0xFFFFFF, 1)
    EndSwitch
WEnd

$oMap = 0
Exit



Func _Map_Events_FileDropped($sFile)
    ConsoleWrite("> _Map_Events_FileDropped = " & $sFile & @CRLF)
EndFunc   ;==>_Map_Events_FileDropped

Func _Map_Events_DblClick()
    ConsoleWrite("! _Map_Events_DblClick fired" & @CRLF)
EndFunc   ;==>_Map_Events_DblClick
Edited by trancexx
Link to comment
Share on other sites

Sorry for late answer. I see your progress with this fallacious control.

:>

I took initiative too.

This is ungrateful and hard work. I'll uphold your intention.

:unsure:

This first script is almost working for me:

#AutoIt3Wrapper_UseX64=n
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include "AutoitObject.au3"

Global $oMap, $Preview, $oNil
Global $Sh_Count = 0, $Layer_count = 0
Global $ZoomIn, $ZoomOut, $Pan, $Selection, $None
Global $cmZoomIn = 0, $cmZoomOut = 1, $cmPan = 2, $cmSelection = 3, $cmNone = 4

Global $ShapeDir = "C:\Program Files\MapWindow\Sample Projects\United States\Shapefiles"

; Error monitoring
Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")
Func _ErrFunc()
    ConsoleWrite("COM Error, ScriptLine(" & $oError.scriptline & ") : Number 0x" & Hex($oError.number, 8) & " - " & $oError.windescription & @CRLF)
EndFunc   ;==>_ErrFunc

CreateMap()

Global $hGUI = GUICreate("_Map Test", 640, 580, -1, -1, $WS_OVERLAPPEDWINDOW)

$AddLayer = GUICtrlCreateButton("Add Layer", 10, 10, 60, 25)
$Clear = GUICtrlCreateButton("Clear", 80, 10, 60, 25)
$None = GUICtrlCreatePic(@ScriptDir & "\Cursor_.bmp", 150, 10, 20, 20)
$ZoomIn = GUICtrlCreatePic(@ScriptDir & "\Plus_.bmp", 170, 10, 20, 20)
$ZoomOut = GUICtrlCreatePic(@ScriptDir & "\Minus_.bmp", 190, 10, 20, 20)
$Pan = GUICtrlCreatePic(@ScriptDir & "\Move_.bmp", 210, 10, 20, 20)
$Select = GUICtrlCreatePic(@ScriptDir & "\Select_.bmp", 230, 10, 20, 20)

$Preview = GUICtrlCreateObj($oMap, 10, 50, 620, 420)

GUISetState()
 
While 1
 Switch GUIGetMsg()
 Case $GUI_EVENT_CLOSE
  ExitLoop
 Case $AddLayer
  LoadShapefile()
 Case $Clear
  ClearMap()
 Case $ZoomIn
  $oMap.CursorMode = 0
 [b]; See the form of cursor here![/b]
  MsgBox(0,"","CursorMode")
 Case $ZoomOut
  $oMap.CursorMode = 1
 Case $Pan
  $oMap.CursorMode = 2
 Case $Selection
  $oMap.CursorMode = 3
 Case $None
  $oMap.CursorMode = 4
 EndSwitch
WEnd

$oMap = 0
Exit

;==============================
Func CreateMap()
 _AutoItObject_Startup()
$oMap = _AutoItObject_ObjCreate("MAPWINGIS.Map.1")
If Not IsObj($oMap) Then 
  ConsoleWrite('Create Map object by _AutoItObject_ObjCreateEx!' & @CrLF)
  $oMap = _AutoItObject_ObjCreateEx(@ScriptDir & "\MapWinGIS.ocx", "{54F4C2F7-ED40-43B7-9D6F-E45965DF7F95}") ; , "{1D077739-E866-46A0-B256-8AECC04F2312}")
 endif
 $oMap.BackColor = 0xAAFFFF
 $oMap.Redraw()
 $oMap.SendSelectBoxFinal = True
 $oMap.SendMouseUp = True
 ObjEvent($oMap, "_Map_Events_", "_DMapEvents")
 $oNil = _AutoItObject_PtrToIDispatch(0)
endfunc

;==============================
Func ClearMap()
 $oMap.RemoveAllLayers()
 $oMap.Redraw()
endfunc

;==============================
Func LoadShapefile()
local $Filter = "Shape Files (*.shp)"
local $oSf, $sFile

 $sFile = FileOpenDialog("Open Image", $ShapeDir, $Filter, 1)
 if @Error then return
 $oSf = ObjCreate("MAPWINGIS.Shapefile")
 $Res = $oSf.Open($sFile, $oNil)
 $LayerHandle = $oMap.AddLayer($oSf, True)
 $Layer_count += 1
 $CurrentLayer = $LayerHandle
 $oMap.ShapeLayerLineColor($LayerHandle) = 0x000000
 $oMap.ShapeLayerFillColor($LayerHandle) = Random(0, 0x00FFFF, 1)
 $oMap.ShapeLayerFillStipple($LayerHandle) = 0
; $ShapeLayerLineWidth = $oMap.ShapeLayerLineWidth($LayerHandle)
; $ShapeLayerStippleTransparent = $oMap.ShapeLayerStippleTransparent($CurrentLayer)
 $oMap.ShapeLayerStippleTransparent($CurrentLayer) = True
; $ShapeLayerFillTransparency = $oMap.ShapeLayerFillTransparency($CurrentLayer)
 $oMap.ShapeLayerFillTransparency($CurrentLayer) = 0.5
 $oSf = 0
EndFunc   ;==>LoadShapefile

Func _Map_Events_FileDropped($sFile)
  ConsoleWrite("> _Map_Events_FileDropped = " & $sFile & @CRLF)
EndFunc   ;==>_Map_Events_FileDropped

Func _Map_Events_DblClick()
  ConsoleWrite("! _Map_Events_DblClick fired" & @CRLF)
EndFunc   ;==>_Map_Events_DblClick

But! Cursor doesn't change it's form. ShapeExplorer can do it by the same script.

You'll see cursor form changing in place of my note

; See the form of cursor here!

Before MsgBox appearing

Buttons is attached, too.

buttons.zip

The point of world view

Link to comment
Share on other sites

Maybe it has sense to create new thread

MapWindowGis-matic with control debugging, the deepest immersion...

BTW 4min 9sec! One year ago - Sunday, April 25, 2010. During the Vertical Blue 2010 free diving competition new Zealander free diver William Trubridge, 29, dived to 116m below the surface and completed the dive in 4min 9sec - setting the new world record for the Deepest free immersion dive (FIM)

Edited by ValeryVal

The point of world view

Link to comment
Share on other sites

Sorry for late answer. I see your progress with this fallacious control.

:>

This is ungrateful and hard work. I'll uphold your intention.

:unsure:

This first script is almost working for me:

#AutoIt3Wrapper_UseX64=n
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include "AutoitObject.au3"

Global $oMap, $Preview, $oNil
Global $Sh_Count = 0, $Layer_count = 0
Global $ZoomIn, $ZoomOut, $Pan, $Selection, $None
Global $cmZoomIn = 0, $cmZoomOut = 1, $cmPan = 2, $cmSelection = 3, $cmNone = 4

Global $ShapeDir = "C:\Program Files\MapWindow\Sample Projects\United States\Shapefiles"

; Error monitoring
Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")
Func _ErrFunc()
    ConsoleWrite("COM Error, ScriptLine(" & $oError.scriptline & ") : Number 0x" & Hex($oError.number, 8) & " - " & $oError.windescription & @CRLF)
EndFunc   ;==>_ErrFunc

CreateMap()

Global $hGUI = GUICreate("_Map Test", 640, 580, -1, -1, $WS_OVERLAPPEDWINDOW)

$AddLayer = GUICtrlCreateButton("Add Layer", 10, 10, 60, 25)
$Clear = GUICtrlCreateButton("Clear", 80, 10, 60, 25)
$None = GUICtrlCreatePic(@ScriptDir & "\Cursor_.bmp", 150, 10, 20, 20)
$ZoomIn = GUICtrlCreatePic(@ScriptDir & "\Plus_.bmp", 170, 10, 20, 20)
$ZoomOut = GUICtrlCreatePic(@ScriptDir & "\Minus_.bmp", 190, 10, 20, 20)
$Pan = GUICtrlCreatePic(@ScriptDir & "\Move_.bmp", 210, 10, 20, 20)
$Select = GUICtrlCreatePic(@ScriptDir & "\Select_.bmp", 230, 10, 20, 20)

$Preview = GUICtrlCreateObj($oMap, 10, 50, 620, 420)

GUISetState()
 
While 1
 Switch GUIGetMsg()
 Case $GUI_EVENT_CLOSE
  ExitLoop
 Case $AddLayer
  LoadShapefile()
 Case $Clear
  ClearMap()
 Case $ZoomIn
  $oMap.CursorMode = 0
 [b]; See the form of cursor here![/b]
  MsgBox(0,"","CursorMode")
 Case $ZoomOut
  $oMap.CursorMode = 1
 Case $Pan
  $oMap.CursorMode = 2
 Case $Selection
  $oMap.CursorMode = 3
 Case $None
  $oMap.CursorMode = 4
 EndSwitch
WEnd

$oMap = 0
Exit

;==============================
Func CreateMap()
 _AutoItObject_Startup()
$oMap = _AutoItObject_ObjCreate("MAPWINGIS.Map.1")
If Not IsObj($oMap) Then 
  ConsoleWrite('Create Map object by _AutoItObject_ObjCreateEx!' & @CrLF)
  $oMap = _AutoItObject_ObjCreateEx(@ScriptDir & "\MapWinGIS.ocx", "{54F4C2F7-ED40-43B7-9D6F-E45965DF7F95}") ; , "{1D077739-E866-46A0-B256-8AECC04F2312}")
 endif
 $oMap.BackColor = 0xAAFFFF
 $oMap.Redraw()
 $oMap.SendSelectBoxFinal = True
 $oMap.SendMouseUp = True
 ObjEvent($oMap, "_Map_Events_", "_DMapEvents")
 $oNil = _AutoItObject_PtrToIDispatch(0)
endfunc

;==============================
Func ClearMap()
 $oMap.RemoveAllLayers()
 $oMap.Redraw()
endfunc

;==============================
Func LoadShapefile()
local $Filter = "Shape Files (*.shp)"
local $oSf, $sFile

 $sFile = FileOpenDialog("Open Image", $ShapeDir, $Filter, 1)
 if @Error then return
 $oSf = ObjCreate("MAPWINGIS.Shapefile")
 $Res = $oSf.Open($sFile, $oNil)
 $LayerHandle = $oMap.AddLayer($oSf, True)
 $Layer_count += 1
 $CurrentLayer = $LayerHandle
 $oMap.ShapeLayerLineColor($LayerHandle) = 0x000000
 $oMap.ShapeLayerFillColor($LayerHandle) = Random(0, 0x00FFFF, 1)
 $oMap.ShapeLayerFillStipple($LayerHandle) = 0
; $ShapeLayerLineWidth = $oMap.ShapeLayerLineWidth($LayerHandle)
; $ShapeLayerStippleTransparent = $oMap.ShapeLayerStippleTransparent($CurrentLayer)
 $oMap.ShapeLayerStippleTransparent($CurrentLayer) = True
; $ShapeLayerFillTransparency = $oMap.ShapeLayerFillTransparency($CurrentLayer)
 $oMap.ShapeLayerFillTransparency($CurrentLayer) = 0.5
 $oSf = 0
EndFunc   ;==>LoadShapefile

Func _Map_Events_FileDropped($sFile)
  ConsoleWrite("> _Map_Events_FileDropped = " & $sFile & @CRLF)
EndFunc   ;==>_Map_Events_FileDropped

Func _Map_Events_DblClick()
  ConsoleWrite("! _Map_Events_DblClick fired" & @CRLF)
EndFunc   ;==>_Map_Events_DblClick

But! Cursor doesn't change it's form. ShapeExplorer can do it by the same script.

You'll see cursor form changing in place of my note

; See the form of cursor here!

Before MsgBox appearing

Buttons is attached, too.

It's changing all right. You just have a sort of a glitch in your code. This thing:

Case $Selection
    $oMap.CursorMode = 3
;...

... should be:

Case $Select
    $oMap.CursorMode = 3

edit:

#AutoIt3Wrapper_UseX64=n
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include "AutoitObject.au3"

Global $Sh_Count = 0, $Layer_count = 0
Global $ZoomIn, $ZoomOut, $Pan, $Selection, $None
Global Enum $cmZoomIn = 0, $cmZoomOut, $cmPan, $cmSelection, $cmNone

; Error monitoring
Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")
Func _ErrFunc()
    ConsoleWrite("COM Error, ScriptLine(" & $oError.scriptline & ") : Number 0x" & Hex($oError.number, 8) & " - " & $oError.windescription & @CRLF)
EndFunc   ;==>_ErrFunc

_AutoItObject_Startup()

Global $oMap = CreateMap()

Global $hGUI = GUICreate("_Map Test", 640, 580, -1, -1, $WS_OVERLAPPEDWINDOW)

$AddLayer = GUICtrlCreateButton("Add Layer", 10, 10, 60, 25)
$Clear = GUICtrlCreateButton("Clear", 80, 10, 60, 25)
$None = GUICtrlCreatePic(@ScriptDir & "\Cursor_.bmp", 150, 10, 20, 20)
$ZoomIn = GUICtrlCreatePic(@ScriptDir & "\Plus_.bmp", 170, 10, 20, 20)
$ZoomOut = GUICtrlCreatePic(@ScriptDir & "\Minus_.bmp", 190, 10, 20, 20)
$Pan = GUICtrlCreatePic(@ScriptDir & "\Move_.bmp", 210, 10, 20, 20)
$Select = GUICtrlCreatePic(@ScriptDir & "\Select_.bmp", 230, 10, 20, 20)

$Preview = GUICtrlCreateObj($oMap, 10, 50, 620, 420)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $AddLayer
            LoadShapefile($oMap)
        Case $Clear
            ClearMap()
        Case $ZoomIn
            $oMap.CursorMode = $cmZoomIn
        Case $ZoomOut
            $oMap.CursorMode = $cmZoomOut
        Case $Pan
            $oMap.CursorMode = $cmPan
        Case $Select
            $oMap.CursorMode = $cmSelection
        Case $None
            $oMap.CursorMode = $cmNone
    EndSwitch
WEnd



;==============================
Func CreateMap()
    Local $oMap = _AutoItObject_ObjCreate("MAPWINGIS.Map.1")
    $oMap.BackColor = 0xAAFFFF
    $oMap.Redraw()
    $oMap.SendSelectBoxFinal = True
    $oMap.SendMouseUp = True
    $oMap.CursorMode = $cmNone
    ObjEvent($oMap, "_Map_Events_", "_DMapEvents")
    Return $oMap
EndFunc   ;==>CreateMap

;==============================
Func ClearMap()
    $oMap.RemoveAllLayers()
    $oMap.Redraw()
EndFunc   ;==>ClearMap

;==============================
Func LoadShapefile($oMap, $sFile = "")
    Local $Filter = "Shape Files (*.shp)"
    If Not $sFile Then $sFile = FileOpenDialog("Open Image", "", $Filter, 1)
    If @error Then Return

    Local $oSf = _AutoItObject_ObjCreate("MAPWINGIS.Shapefile", "{5DC72405-C39C-4755-8CFC-9876A89225BC}")
    _AutoItObject_WrapperAddMethod($oSf, "none", "Open", "bstr;idispatch;bool*", 19)

    $oSf.Open($sFile, 0, 0)
    $LayerHandle = $oMap.AddLayer($oSf, True)
    $Layer_count += 1
    $CurrentLayer = $LayerHandle
    $oMap.ShapeLayerLineColor($LayerHandle) = 0x000000
    $oMap.ShapeLayerFillColor($LayerHandle) = Random(0, 0x00FFFF, 1)
    $oMap.ShapeLayerFillStipple($LayerHandle) = 0
;~  $ShapeLayerLineWidth = $oMap.ShapeLayerLineWidth($LayerHandle)
;~  $ShapeLayerStippleTransparent = $oMap.ShapeLayerStippleTransparent($CurrentLayer)
    $oMap.ShapeLayerStippleTransparent($CurrentLayer) = True
;~  $ShapeLayerFillTransparency = $oMap.ShapeLayerFillTransparency($CurrentLayer)
    $oMap.ShapeLayerFillTransparency($CurrentLayer) = 0.5
EndFunc   ;==>LoadShapefile

Func _Map_Events_FileDropped($sFile)
    ConsoleWrite("> _Map_Events_FileDropped = " & $sFile & @CRLF)
    LoadShapefile($oMap, $sFile)
EndFunc   ;==>_Map_Events_FileDropped

Func _Map_Events_DblClick()
    ConsoleWrite("! _Map_Events_DblClick fired" & @CRLF)
EndFunc   ;==>_Map_Events_DblClick

Latest version of AutoItObject is 1.2.6.0. The difference is more subtile OLE control support.

Edited by trancexx
Link to comment
Share on other sites

Latest version of AutoItObject is 1.2.6.0. The difference is more subtile OLE control support.

Now CursorMode setting is working.

There is new Error:

COM Error, ScriptLine(65) : Number 0x80040200 -

in line with

ObjEvent($oMap, "_Map_Events_", "_DMapEvents")

This code have to open Image in Map:

#AutoIt3Wrapper_UseX64=n
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include "AutoitObject.au3"

Global $Im_Count = 0, $Layer_count = 0
Global $ZoomIn, $ZoomOut, $Pan, $Selection, $None
Global Enum $cmZoomIn = 0, $cmZoomOut, $cmPan, $cmSelection, $cmNone
; ImageType
Global $BITMAP_FILE = 0, $GIF_FILE = 1, $USE_FILE_EXTENSION = 2, $TIFF_FILE = 3, $JPEG_FILE = 4, $PNG_FILE = 5
Global $PPM_FILE = 7, $ECW_FILE = 8, $JPEG2000_FILE = 9, $SID_FILE = 10, $PNM_FILE = 11, $PGM_FILE = 12, $BIL_FILE = 13, $ADF_FILE = 14
Global $GRD_FILE = 15, $IMG_FILE = 16, $ASC_FILE = 17, $BT_FILE = 18, $MAP_FILE = 19, $LF2_FILE = 20, $KAP_FILE = 21

; Error monitoring
Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")
Func _ErrFunc()
    ConsoleWrite("COM Error, ScriptLine(" & $oError.scriptline & ") : Number 0x" & Hex($oError.number, 8) & " - " & $oError.windescription & @CRLF)
EndFunc   ;==>_ErrFunc

_AutoItObject_Startup()

Global $oMap = CreateMap()
Global $Nil = _AutoItObject_PtrToIDispatch(0)

Global $hGUI = GUICreate("_Map Test", 640, 580, -1, -1, $WS_OVERLAPPEDWINDOW)

$AddImage = GUICtrlCreateButton("Add Image", 10, 10, 60, 25)
$Clear = GUICtrlCreateButton("Clear", 80, 10, 60, 25)
$None = GUICtrlCreatePic(@ScriptDir & "\Cursor_.bmp", 150, 10, 20, 20)
$ZoomIn = GUICtrlCreatePic(@ScriptDir & "\Plus_.bmp", 170, 10, 20, 20)
$ZoomOut = GUICtrlCreatePic(@ScriptDir & "\Minus_.bmp", 190, 10, 20, 20)
$Pan = GUICtrlCreatePic(@ScriptDir & "\Move_.bmp", 210, 10, 20, 20)
$Select = GUICtrlCreatePic(@ScriptDir & "\Point_.bmp", 230, 10, 20, 20)

$Preview = GUICtrlCreateObj($oMap, 10, 50, 620, 420)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $AddImage
            LoadImagefile()
        Case $Clear
            $oMap.RemoveAllLayers()
            $oMap.Redraw()
        Case $ZoomIn
            $oMap.CursorMode = $cmZoomIn
        Case $ZoomOut
            $oMap.CursorMode = $cmZoomOut
        Case $Pan
            $oMap.CursorMode = $cmPan
        Case $Select
            $oMap.CursorMode = $cmSelection
        Case $None
            $oMap.CursorMode = $cmNone
    EndSwitch
WEnd

_AutoItObject_Shutdown()

Exit

;==============================
Func CreateMap()
    Local $oMap = _AutoItObject_ObjCreate("MAPWINGIS.Map.1")
    $oMap.BackColor = 0xAAFFFF
    $oMap.Redraw()
    $oMap.SendSelectBoxFinal = True
    $oMap.SendMouseUp = True
    $oMap.CursorMode = $cmNone
;   ObjEvent($oMap, "_Map_Events_", "_DMapEvents")
    Return $oMap
EndFunc   ;==>CreateMap
 
;==============================
Func LoadImagefile()
local $Filter = "Image Files (*.bmp;*.tif;*.jpg;*.gif;*.png;)"
local $oImage, $sFile, $Parts
local $oGridColorBreak, $oLegend
local $oImageDir  = "D:\Program Files\AutoIt3\My\AMapWrap\Images"

;Local $oImage = ObjCreate("MAPWINGIS.Image")
Local $oImage = _AutoItObject_ObjCreate("MAPWINGIS.Image", "{79C5F83E-FB53-4189-9EC4-4AC25440D825}")
 _AutoItObject_WrapperAddMethod($oImage, "none", "Open", "bstr;int;bool;idispatch;bool*", 7)

 $sFile = FileOpenDialog("Open Image", $oImageDir, $Filter, 1)
 
 if @Error then return
 $Parts = StringSplit($sFile,"\")
 $CurrentImageFileName = $Parts[$Parts[0]]
 Switch StringLower(StringRight($CurrentImageFileName,3))
 Case "bmp"
    $ImageType = $BITMAP_FILE
 Case "gif"
    $ImageType = $GIF_FILE
 Case "tif"
    $ImageType = $TIFF_FILE
 Case "jpg"
    $ImageType = $JPEG_FILE
 Case "png"
    $ImageType = $PNG_FILE
 Case Else
    return 
 EndSwitch
 $Im_Count += 1
 $oImage.Open($sFile, $ImageType, 0, 0, 0)
$LayerHandle = $oMap.AddLayer($oImage, True)
$Layer_count += 1
 $CurrentLayer = $LayerHandle
 ConsoleWrite('$LayerHandle = ' & $LayerHandle & " $CurrentLayer = " & $CurrentLayer & @CrLF)
 $oImage = 0
EndFunc   ;==>LoadPicture

How can I set $ivTableIndex in call of _AutoItObject_WrapperAddMethod for $oImage?

Is it true $ivTableIndex = 3 (IUnknown)+3(IDispatch)+1(Open method index) = 7?

Where is an error?

This file Buttons.zip has Point_.bmp, also.

buttons.zip

Edited by ValeryVal

The point of world view

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...