Discussion of article "Studying the CCanvas Class. How to Draw Transparent Objects" - page 2

 
denkir:

The question is this. What could be the best implementation on moving the kanvas around the graph? Something like method:

"canvas" - creates standard OBJ_BITMAP_LABEL or OBJ_BITMAP. In the help there are functions on how to place them on the chart

 //+------------------------------------------------------------------+
//|| Moves the "Graphic Label" object |
//+------------------------------------------------------------------+
bool BitmapLabelMove(const long   chart_ID=0,      // chart ID
                     const string name="BmpLabel", // tag name
                     const int    x=0,             // X-axis coordinate
                     const int    y=0)             // Y-axis coordinate
  {
//--- reset the error value
   ResetLastError();
//--- move the object
   if(!ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x))
     {
      Print(__FUNCTION__,
            ": failed to move the X-coordinate of the object! Error code = ",GetLastError());
      return(false);
     }
   if(!ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y))
     {
      Print(__FUNCTION__,
            ": failed to move the Y-coordinate of the object! Error code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }

I didn't notice the discussion above at once :) - actually the same as ZORDER, only X and Y

 
MigVRN:

"canvas" - creates standard OBJ_BITMAP_LABEL or OBJ_BITMAP. There are functions in the help to place them on the chart

I didn't notice the discussion above at once :) - actually the same as ZORDER, only X and Y

Aha, thanks, it worked... I tried using ObjectMove myself...

I am creating a panel using kanvas.... I need to move it as far as possible on the chart....
 
denkir:

Yep, thanks, it worked... I tried using ObjectMove myself...

I'm creating a panel with the help of kanvas... I need to move it as far as possible on the chart...
And if the panel is created on the basis of a standard dialogue? Then all elements created in the dialogue and added to it will be dragged together with the dialogue.
 
barabashkakvn:
What if the panel is created on the basis of a standard dialogue? Then all elements created in the dialogue and added to it will be dragged together with the dialogue.
Yes, it's a handy feature, I agree... I've been doing that until now... but there is a question how to add custom graphics to the panel.... in general it is necessary to make a kanvas-like control : public CWndObj. Now I'm thinking about this question...
 
denkir:
Yes, a handy feature, I agree..... I've been doing that until now... but there was a question how to add custom graphics to the panel.... in general it is necessary to make a kanvas-like control : public CWndObj. Now I'm thinking about this question...

Watch the video from the post.

After 15 March will be in the source code

 
denkir:
Yes, a handy feature, I agree..... I've been doing that until now... but there was a question how to add custom graphics to the panel.... in general it is necessary to make a kanvas-like control : public CWndObj. Now I'm thinking about this question...

What do you mean by"custom graphics":

  • I mean is it something you draw as a programmer?
  • I mean it takes a picture from the user of the programme and this picture should be displayed on the canvas?
 
barabashkakvn:

What do you mean, "custom graphics,"

  • as in it is something you draw as a programmer?
  • I mean, it takes a picture from the user of the programme and this picture should be displayed on the canvas?
Yes, I was vague..... I meant the ability to create dynamically different figures by means of methods of CCanvas class...
 

Vladimir, I wanted to ask you something else.

There is a panel of CAppDialog type. Let one of its elements be a graphical label of CBmpButtontype . So, is there any way to create a canvas and link it with the specified label? The goal is to have a controllable panel element with custom graphics capabilities...?

Thanks.

 
denkir:

Vladimir, I wanted to ask you something else.

There is a panel of CAppDialog type. Let one of its elements be a graphical label of CBmpButtontype . So, is there any way to create a canvas and link it with the specified label? The goal is to have a controllable panel element with custom graphics capabilities...?

Thanks...

You can create canvases (i.e. multiple canvases) without linking to a graphics object via the Create method, and then you assign these resources to the BmpButton. You can even try to make animation. By the way, I want to think about animation for a long time.
 

Vladimir, thanks for the tip, it all worked out!

Yes, canvasses are very powerful :-)

We are waiting for interesting articles from you!