MapInfo Pro Developers User Group

 View Only
  • 1.  Getting number of frame within a layout?

    Posted 07-23-2020 17:48

    Hello,

    For my MapBasic 2019 code, I am having trouble figuring out how to identify the number of a window when it is a frame within a layout (designer). I have created a multi-page layout with various maps and other frames like legends, text, symbols, etc. Every time I add an item to the layout, I believe it has its own window number, but I can't seem to figure out how to identify/track the window numbers so I can do things like, for instance, set map window zoom entire for a mapper window in a particular frame . I have tried the frontwindow command, but that always just gives me the number of the layout window itself.

    Thanks,
    Sam



    ------------------------------
    S W
    Knowledge Community Shared Account
    ------------------------------


  • 2.  RE: Getting number of frame within a layout?

    Employee
    Posted 08-11-2020 05:05
    Hi Sam

    There are a few things to keep track of on the layout.

    First of all, you have the frames. They have their own IDs starting from 1. Every time you add a frame, it will be given the next number. MapBasic also has a function that will tell you how many frames a layout has.

    A few examples where we assume the front window is a layout.:

    '**Get the WindowID of the Layout
    nLayout_WID = FrontWindow()

    '**Get the number of frames on the Layout
    '**If your layout has multiple pages, this will only get the elements from the current page.
    nNumFrames = LayoutInfo(nLayout_WID, LAYOUT_INFO_NUM_ITEMS)

    When you know how many frames, you have, you can loop through these to find the frame you are looking for

    '**Looping thru the frames, searching for maps
    For nFrame = 1 To nNumFrames
       If LayoutItemInfo(nLayout_WID, nFrame, LAYOUT_ITEM_INFO_TYPE) = LAYOUT_ITEM_TYPE_MAPPER Then
          nMapper_WID = LayoutItemInfo(nLayout_WID, nFrame, LAYOUT_ITEM_INFO_WIN)
       End If
    Next

    MapBasic also has a function that helps you locate a frame by its name:

    '**Searching for a map frame named "TheMapFrame"
    nMapframe_ID = LayoutItemID(nLayout_WID, "TheMapFrame", LAYOUT_ITEM_TYPE_MAPPER)

    The ID of the frames or static once you have created the frame. They don't get renumbered if you for example delete the first frame. They do get renumbered when you save the layout to a workspace and reload the layout from the workspace.

    ------------------------------
    Peter Horsbøll Møller
    Distinguished Engineer
    Pitney Bowes Software & Data
    ------------------------------



  • 3.  RE: Getting number of frame within a layout?

    Posted 08-21-2020 14:25
    Thank you , Peter!

    ------------------------------
    S W
    Knowledge Community Shared Account
    ------------------------------