I was told that some of you didn�t get the attachment from my last e-mail.
Also, I ended up having problems with applying that code anyway because the
application I am using this for will create around 30 maps and layouts each
time.  I didn�t want to have to create a cartographic legend for each one,
resulting in 30 extra windows.  Because the legendinfo function doesn�t work
on the thematic legend window, only on cartographic legend windows, I came
up with a workaround in the form of two functions: one to get the desired
width and one to get the desired length.  Then I send that length and width
with the mapperID to a function that creates my layouts.

Hope some of you find this useful.  Thanks to all of you who gave me help
creating these functions!

'***************************************************************************
**************Function GetLegendFrameW(MapperID as integer) as float
'***************************************************************************
**************
onerror goto GLFW_Err

dim tmpWidth, LWidth as float
dim i, LegendID as integer

GetLegendFrameW = 0

Set Window MapperID Front

cmdstr = "Create Cartographic Legend From Window "+MapperID+" Behind"
For i = 1 to MapperInfo(MapperID, MAPPER_INFO_LAYERS)
   If LayerInfo(MapperID, i, LAYER_INFO_TYPE ) = LAYER_INFO_TYPE_THEMATIC
Then
      cmdstr = cmdstr + " Frame from Layer "+i
   End If
Next
run command cmdstr
LegendID = windowid(0)

for i = 1 to legendinfo(LegendID,LEGEND_INFO_NUM_FRAMES)
      tmpWidth = LegendFrameInfo(LegendID,i,FRAME_INFO_WIDTH)+.2
      if tmpWidth > LWidth then LWidth = tmpWidth end if
next
GetLegendFrameW = LWidth
Close Window LegendID

exit function

GLFW_Err:
      note "Get Legend Frame Width Error "+err()+": "+error$()

end function

'***************************************************************************
**************
Function GetLegendFrameH(MapperID as integer) as float
'***************************************************************************
**************

onerror goto GLFH_Err

dim tmpHeight, LHeight as float
dim i, LegendID as integer

GetLegendFrameH = 0

Set Window MapperID Front

cmdstr = "Create Cartographic Legend From Window "+MapperID+" Behind"
For i = 1 to MapperInfo(MapperID, MAPPER_INFO_LAYERS)
   If LayerInfo(MapperID, i, LAYER_INFO_TYPE ) = LAYER_INFO_TYPE_THEMATIC
Then
      cmdstr = cmdstr + " Frame from Layer "+i
   End If
Next
run command cmdstr
LegendID = windowid(0)

for i = 1 to legendinfo(LegendID,LEGEND_INFO_NUM_FRAMES)
      LHeight = LHeight + LegendFrameInfo(LegendID,i,FRAME_INFO_HEIGHT)
next
LHeight = LHeight + .2
GetLegendFrameH = LHeight
Close Window LegendID

exit function

GLFH_Err:
      note "Get Legend Frame Height Error "+err()+": "+error$()

end function


Amy Sabalesky

Conclusive Strategies, 713-436-3838

Market Analysis, Direct Marketing Research & Software Development
Visit us at  www.conclusivestrategies.com




_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.

Reply via email to