2

I used Mapbasic to create tables. I create only table's structure without any objects inside.
How i want make styles for tables. I tried something like:

Dim b1 As Brush,
p1 As Pen
b1 = Makebrush (1, 0, 16777215)
p1 = MakePen(1, 2, 16776960)

select * from myTable
into __TO__UPDATE NoSelect

Update __TO__UPDATE
Set OBJ = ChangeColor(OBJ, p1, b1)


Function ChangeColor( ByVal oRegion As Object
            , ByVal penNew As Pen
            , ByVal brsNew As Brush) As Object

  Alter Object oRegion
  Info OBJ_INFO_BRUSH, brsNew 
  Alter Object oRegion 
  Info OBJ_INFO_PEN, penNew 

  ChangeColor = oRegion

End Function

But styles still defaults.
After i tried to add point to table and used MakeSymbol() to add symbol style, and its worked.

So MapInfo idialogy means that i gonna have a objects in table to create styles or i just do something wrong?

2 Answers 2

2

Basically yes, the code you have used would update all the objects that are already in the table with a new pen and brush style. If there are no existing objects in the table then there would be no records to change. It sounds like you maybe want to change the current pen and brush styles so that any new objects you draw use that new style? If so, you can do that using the Set Style statement.

e.g.

Dim b1 As Brush,
p1 As Pen

b1 = Makebrush (1, 0, 16777215)
p1 = MakePen(1, 2, 16776960)

Set Style Brush b1
Set Style Pen p1

You can also query what the current style settings are using the CurrentBrush(), CurrentPen(), etc. functions alongside the StyleAttr() function which pulls out individual style attributes (e.g. Pattern, Forecolor, Backcolor, etc...). Take a look in the reference guide for examples on all of the above, it's really well documented.

Also, just to clarify, you can't add a style to a table in MapInfo. Individual objects have a style, but a table does not. There is however a way to override the object styles for a map layer using the style override functionality. In MapBasic that comes under the broad umbrella of the Set Map statement.

0

You can via the Layer properties dialog set the styles for new objects inserted with the standard drawing tools in MapInfo Pro.

enter image description here

Notice that the layer must be editable for this button to show in the Layer Properties dialog.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.