Hi Matthew
As you know, MapInfo Pro uses ID to refer to windows.
The trick is to find the ID from the name.
WINDOWLib which is part of the MapBasic Common Libraries on GitHub has a function that allows you to get the ID from a window title/name: WINGetIDFromTitle.
You can know use this function to assign the ID to a couple of variables:
Dim nLayoutID, nEmbeddedMapID As Integer
nLayoutID = WINGetIDFromTitle("Layout")
nEmbeddedMapID = WINGetIDFromTitle("Map1")
We also have functions that can help you find frames with maps in a layout.
It could look like this:
nNumFrames = LayoutInfo(nLayoutID,LAYOUT_INFO_NUM_ITEMS)
For k = 1 to nNumFrames
If LayoutItemInfo(nLayoutID, k, LAYOUT_ITEM_INFO_TYPE) = LAYOUT_ITEM_TYPE_MAPPER then
nMID = LayoutItemInfo(nLayoutID, k, LAYOUT_ITEM_INFO_WIN) 'get mapper frame id
End If
Next
I hope this helps
Peter
From: mapi...@googlegroups.com <mapi...@googlegroups.com>
On Behalf Of Matthew Hirsch
Sent: 15. februar 2024 00:09
To: MapInfo-L <mapi...@googlegroups.com>
Subject: [MI-L] Making Layout Window Active via Mapbasic code?
Du får ikke ofte mails fra mrhr...@gmail.com. Få mere at vide om, hvorfor dette er vigtigt |
This message originated Externally. Use proper judgement and caution with attachments, links, or responses. |
--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en
---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
mapinfo-l+...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/mapinfo-l/1342c5d7-7c64-425a-9fd9-5285e144128dn%40googlegroups.com.
Hi Matthew
Ah, you are running this through the MapBasic window.
Well, in that case you can’t use the two methods I referred to. They can only be used through a compiled MapBasic application.
But…
If you make sure the layout, is the active window, you can get that ID using this statement:
nLayoutWID =
FrontWindow()
And when you have the ID of the layout, you can also get to the frame and the map window in that frame.
For this to work best I would recommand assigning a name to the fram with the map, as you can see below:
You can use a MapBasic function to get to a frame with a specific name:
The last parameter 1 equals LAYOUT_ITEM_TYPE_MAPPER
nFrameID = LayoutItemID(nLayoutWID, "Map-1", 1)
Once you have the ID of the frame with the map, you can also get to the Id of the map itself:
The last parameter 5 equals LAYOUT_ITEM_INFO_WIN which will give you the Window ID.
nMapWID = LayoutItemInfo(nLayoutWID, nFrameID, 5)
To view this discussion on the web visit https://groups.google.com/d/msgid/mapinfo-l/40aade17-bb90-4e05-9418-8d5110a585c5n%40googlegroups.com.