ImageEn Forum
ImageEn Forum
Profile | Join | Active Topics | Search | Forum FAQ
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn Support and Discussion Forum
 ImageEnVect.LayersMove does not work
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Kostas

Germany
6 Posts

Posted - Feb 26 2012 :  10:49:10  Show Profile  Reply
Greetings All,

here is a smal example to draw two vectorial boxes
The question is, how do I get the first box to the top?

procedure TForm1.Button1Click(Sender: TObject);
var LayerUp, LayerDown, h1, h2:integer;
    ObjectRect:TRect;
begin
  ImageEnVect1.LayersSync := true;

  //Create a blue box
  LayerDown := ImageEnVect1.LayersAdd;

  h1 := ImageEnVect1.AddNewObject;
  ObjectRect := Rect(10,10,110,110);

  ImageEnVect1.ObjKind[h1] := iekBOX;
  ImageEnVect1.SetObjRect(h1, ObjectRect);
  ImageEnVect1.ObjPenStyle[h1] := psClear;
  ImageEnVect1.ObjBrushStyle[h1] := bsSolid;
  ImageEnVect1.ObjGraphicRender := true;
  ImageEnVect1.ObjTransparency[h1] := 255;
  ImageEnVect1.ObjBrushColor[h1] := clBlue;
  ImageEnVect1.ObjStyle[h1]:=[ievsVisible];
  ImageEnVect1.ObjGripPen.Style := psClear;
  ImageEnVect1.ObjGripBrush.Style := bsclear;


  //Create a red box over the blue box
  LayerUp := ImageEnVect1.LayersAdd;

  h2 := ImageEnVect1.AddNewObject;
  ObjectRect := Rect(20,20,120,120);

  ImageEnVect1.ObjKind[h2] := iekBOX;
  ImageEnVect1.SetObjRect(h2, ObjectRect);
  ImageEnVect1.ObjPenStyle[h2] := psClear;
  ImageEnVect1.ObjBrushStyle[h2] := bsSolid;
  ImageEnVect1.ObjGraphicRender := true;
  ImageEnVect1.ObjTransparency[h2] := 255;
  ImageEnVect1.ObjBrushColor[h2] := clRed;
  ImageEnVect1.ObjStyle[h2]:=[ievsVisible];
  ImageEnVect1.ObjGripPen.Style := psClear;
  ImageEnVect1.ObjGripBrush.Style := bsclear;


  //to try invisible the LayerUp, but does not work
  ImageEnVect1.Layers[ LayerUp ].Visible := false;


  //to try brind to front the blue box, but does not work
  ImageEnVect1.LayersMove(LayerUp, LayerDown);



end;


What am I doing wrong?

Regards,
Kostas

fab

1310 Posts

Posted - Feb 26 2012 :  11:42:54  Show Profile  Reply
Hello,
please don't mix layers and vectorial objects if it isn't necessary (let me know if you actually need it).
Also never set LayersSync=true (repeat, if you don't actually it).

Try this code:

procedure TForm1.Button1Click(Sender: TObject);
var h1, h2:integer;
    ObjectRect:TRect;
begin
  //Create a blue box
  h1 := ImageEnVect1.AddNewObject;
  ObjectRect := Rect(10,10,110,110);

  ImageEnVect1.ObjKind[h1] := iekBOX;
  ImageEnVect1.SetObjRect(h1, ObjectRect);
  ImageEnVect1.ObjPenStyle[h1] := psClear;
  ImageEnVect1.ObjBrushStyle[h1] := bsSolid;
  ImageEnVect1.ObjGraphicRender := true;
  ImageEnVect1.ObjTransparency[h1] := 255;
  ImageEnVect1.ObjBrushColor[h1] := clBlue;
  ImageEnVect1.ObjStyle[h1]:=[ievsVisible];
  ImageEnVect1.ObjGripPen.Style := psClear;
  ImageEnVect1.ObjGripBrush.Style := bsclear;


  //Create a red box over the blue box
  h2 := ImageEnVect1.AddNewObject;
  ObjectRect := Rect(20,20,120,120);

  ImageEnVect1.ObjKind[h2] := iekBOX;
  ImageEnVect1.SetObjRect(h2, ObjectRect);
  ImageEnVect1.ObjPenStyle[h2] := psClear;
  ImageEnVect1.ObjBrushStyle[h2] := bsSolid;
  ImageEnVect1.ObjGraphicRender := true;
  ImageEnVect1.ObjTransparency[h2] := 255;
  ImageEnVect1.ObjBrushColor[h2] := clRed;
  ImageEnVect1.ObjStyle[h2]:=[ievsVisible];
  ImageEnVect1.ObjGripPen.Style := psClear;
  ImageEnVect1.ObjGripBrush.Style := bsclear;


  // to hide h1 object
  ImageEnVect1.ObjStyle[h1] := [];

  ...or...

  // to bring h1 over h2
  ImageEnVect1.SetObjFrontOf(h1, h2);

end;


If you need to anchor objects and layers use ObjLayer[] property.
Go to Top of Page

Kostas

Germany
6 Posts

Posted - Feb 26 2012 :  13:02:41  Show Profile  Reply
many thanks fabrizio,
SetObjFrontOf works fine.

Regards,
Kostas
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To: