Window ID var set in a workspace but cannot reference in MBX

36 views
Skip to first unread message

Matthew Hirsch

unread,
May 14, 2024, 5:43:46 PMMay 14
to MapInfo-L

I have an MBX file that calls a workspace to open tables and set up a layout with a map. 
In the MBX (I tried in the WOR too) I have   Dim MapWindowID As Integer

When the map is created in the code I define the MapWinID

Map From Custom_Zones
  Position (0.25,0.75) Units "in"
  Width 10.5 Units "in" Height 7.5 Units "in"
  Brush (2,16777215,16777215)  Pen (1,2,0)  Name "No Content"
Priority 1 Into Window uniqueLayoutWin
    MapWindowID= FrontWindow()

I have it tell me the Note MapWindowID with a 
Note Note MapWindowID
at the end of the WOR so it pops up the id number.

Once the WOR is open the MB code should use the MapWindowID, but it is not and giving errors.
The command is 
Set Window MapWindowID Front

I get Invalid window identifier: 0

Why isn't the MapWindowID  being remembered from the code in the WOR to the MBX code?  
Is there a way to pass the ID from the WOR to the MBX?     I tried creating a table to store the ID in then call, but that causes other issues in the code. 

When I use this code
Set Map Window MapWindowID Zoom Entire layer 1
I get the error 
Error" expecting Mapper Window

Note, this all because the MBX code I had that worked perfectly by calling the right windowid on my computer did not work on another person's computer using the same exact MBX, WOR and version of MIP.  Why that is happening is another question.

Thank you.
Matthew

Peter Horsbøll Møller

unread,
May 16, 2024, 8:17:50 AMMay 16
to mapi...@googlegroups.com

I think the issue relates to scope.

You may have two variables with the same name but I think to MapInfo Pro and your MapBasic application these may be different variables.

 

I would use this approach instead:

1. Keep a variable with the number of windows open, nNumWindows

2. Run the workspace

3. Check if there now are more open windows, if not, the workspace failed to open the layout and map

4. Else find the layout window that has been opened. You can loop over the windows opend by the workspace: For nWin = (nNumWindows+1) To NumWindows.

5. Once you have fun the layout, you can dig into this to find the map window(s) embedded here.

If you name your frames, you can use ths function to get their ID: LayoutItemID( window_id, frame, frame_type )

Say you named your frame “mapframe”, you can find the ID like this:

nFrameMap = LayoutItemID(nLayoutWID, "mapframe", LAYOUT_ITEM_TYPE_MAPPER)

Once you have the frame, you can also get to the ID of the map window:

nMapWID = LayoutItemInfo(nLayoutWID, nFrameMap, LAYOUT_ITEM_INFO_WIN)

 

I hope this helps

Peter

 

Peter Horsbøll Møller
Principal Sales Engineer - Distinguished Engineer

 

From: mapi...@googlegroups.com <mapi...@googlegroups.com> On Behalf Of Matthew Hirsch
Sent: 14. maj 2024 23:44
To: MapInfo-L <mapi...@googlegroups.com>
Subject: [MI-L] Window ID var set in a workspace but cannot reference in MBX

 

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/b50d7676-7ae2-424e-a828-e2fcd4271380n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages