cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

background colour change diagram

SVanSchoonlandt
Honored Contributor

Hi all,

 

It'm trying to set the background colour of a diagram when a new diagram is created. Anyone knows which function I can use for this and how to use it? I found drw.Prop(Background_Brush) but I'm not able to get it working.

 

Thanks

 

stijn

3 Replies

This error means that you are trying to read a property which is not valid for the current background type of the diagram.

For instance, if you have a background picture, you cannot access the brush property. You must first check the background type and only retrieve the relevant properties.

 

See this small sample.

 

Set oDiag = GetObjectFromId("~LIvGSqLzBHTC[Overviews - Overview of Applications]")
Set oDrw  = oDiag.Drawing("rw")

typeBkgn = oDrw.Prop("Background_Type")
Print typeBkgn
If typeBkgn=1 Or typeBkgn=2 Then
	Print oDrw.Prop("Background_PicturePath")
Elseif typeBkgn = 3 Then
  Set oBrush = oDrw.Prop("Background_Brush")
  Print oBrush.Type
  If oBrush.Type = 0 Then
    Print Hex(oBrush.Color)
  Else 
    Print Hex(oBrush.LinearGradientColor1)
    Print Hex(oBrush.LinearGradientColor2)
  End If
End If
Print oDrw.Prop("Background_RepeatOnEachPage")
Print oDrw.Prop("Background_DisplayOnScreen")
If oDrw.Prop("Background_DisplayOnScreen") Then
  Print "Display On Screen"
End If
Print oDrw.Prop("Background_DisplayOnPrint")
If oDrw.Prop("Background_DisplayOnPrint") Then
  Print "Display On Print"
End If
Print oDrw.Prop("Background_DisplayOnGenerated")
Print oDrw.Prop("Background_X")/4
Print oDrw.Prop("Background_Y")/4
Print oDrw.Prop("Background_Width")/4 
Print oDrw.Prop("Background_Height")/4

 

SVanSchoonlandt
Honored Contributor

Indeed same issue I have

ki6i
Trusted Contributor

I have the same issue.

 

According to the Mega documentation: http://community.mega.com/mega/attachments/mega/725/2/21/MEGA%20Exchange%20-%20API%20DE.pdf

 

The drw.Prop("Background_Type") works fine.

 

For the ''Background_Brush" I get invalid flag exception:

 

Thread(05c0);drw_bkgn.cpp(2652) : error Application: 0x01018007 12:25:21
              Invalid flag (492631000)
Thread(05c0);apidraw.cpp(8237) : error trace 12:25:21
Script Editor Default : MegaDrawing::Prop line 7, offset 1 :
Error(0x80020009) : Invalid flag (492631000)

 

I think that somebody from Mega support should update that documentation there.

 

There are also a lot of code examples in this document which starts with

 

diag.drawing

 

which doesn't work instead it should be

 

diag.drawing("RW")