BmpButton - Image dont appear

 

Hi,


I'm not sure what I do wrong, and hope anyone can help me with this one.

I try to add a bmp button to a dialog/panel, but the bmp image isnt shown. I do see the button in the objects list on the Chart, but the image itself is not shown.

This is the code:

CAppDialog MyInterface;
CBmpButton ButtonActiveOrders;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   MyInterface.Create(0,"MyInterface",0,0,0,80,170);
   ButtonActiveOrders.Create(0,"ManagedOrders",0,0,80,70,140);
   ButtonActiveOrders.BmpNames("\\Image\NotSelected.bmp");
   MyInterface.Add(ButtonActiveOrders);
   MyInterface.Run();
//---
 
   return(INIT_SUCCEEDED);
   
  }

Anyone know what to do to make it work?

Thanks in advance!

Kind regards,

Victor

 
I think, what you need you find here: https://www.mql5.com/en/articles/261
Use of Resources in MQL5
Use of Resources in MQL5
  • www.mql5.com
MQL5 programs not only automate routine calculations, but also can create a full-featured graphical environment. The functions for creating truly interactive controls are now virtually the same rich, as those in classical programming languages. If you want to write a full-fledged stand-alone program in MQL5, use resources in them. Programs with resources are easier to maintain and distribute.
 
Carl Schreiber #:
I think, what you need you find here: https://www.mql5.com/en/articles/261

Thanks! This solved it indeed and it works now! Thanks again, appreciated!

 

Hi,

I do have a follow up question on this topic.

I would like to show a different image for the button after it has been pressed. (it should toggle between two images, to identify that the action for this button is active)

void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
    


   MyInterface.OnEvent(id,lparam,dparam,sparam);
     
   if(id==CHARTEVENT_OBJECT_CLICK && sparam=="ManagedOrders")
     {
      if(Dialog2.IsVisible()==true){
         Dialog2.Hide();
         ButtonActiveOrders.BmpOnName("\\Image\\NotSelected.bmp");
      }else{
         Dialog2.Show();
         ButtonActiveOrders.BmpOffName("\\Image\\Selected.bmp");
      }
//+------------------------------------------------------------------+
// chart event reset button state
//+------------------------------------------------------------------+
         ObjectSetInteger(0,sparam,OBJPROP_STATE,0);
         Sleep(100);
         ChartRedraw();
//+------------------------------------------------------------------+
     }
  }

It loads the button well, and if I press the button the other image will appear (Selected.bmp). However, it will not change back to NotSelected.bmp if I click on the button again. If I press the mouse button, and hold the mouse button, I see the NotSelected.bmp. However, as soon as I release the mouse button I get the Selected.bmp.


What do I need to do to make the Image switch between Selected.bmp and NotSelected.bmp in order to show that the Dialog is active?

 
Victor Christiaanse #:

Do not double post!

I have deleted your new topic.

 

Artyom Trishkin has written a series of articles about graphical interface - keyword WinForms: https://www.mql5.com/en/users/artmedia70/publications

Take his solution and look how he manages buttons that are changing when the mouse hovers is over the button: https://www.mql5.com/en/articles/11356

 
Carl Schreiber #:

Artyom Trishkin has written a series of articles about graphical interface - keyword WinForms: https://www.mql5.com/en/users/artmedia70/publications

Take his solution and look how he manages buttons that are changing when the mouse hovers is over the button: https://www.mql5.com/en/articles/11356

Thanks again! I will look into this tonight.

 
Keith Watford #:

Do not double post!

I have deleted your new topic.

as my question was a new question, and I got no responses, I created the new one.

 
Victor Christiaanse #:

as my question was a new question, and I got no responses, I created the new one.

You didn't create a new one, you repeated the same question!

Have you any idea how annoying it is to spend valuable time answering someone's question only to find that when you open another topic, you find the same question and it has already been answered?

The time spent answering the question was time wasted.

Double posting is inconsiderate and selfish.

 
Keith Watford #:

You didn't create a new one, you repeated the same question!

Have you any idea how annoying it is to spend valuable time answering someone's question only to find that when you open another topic, you find the same question and it has already been answered?

The time spent answering the question was time wasted.

Double posting is inconsiderate and selfish.

Well, then we both see it different. I see a question about a picture not showing on the chart, or how to handle the click event to change the picture as two different questions. For that reason, I reased a new topic as I wasnt sure if anyone was looking into my question as it was different (and I didnt got any responses yet). It was not done out of a selfish action, just because I found it different questions and I got no responses (which is very uncommon on this forum).

 
Carl Schreiber #:

Artyom Trishkin has written a series of articles about graphical interface - keyword WinForms: https://www.mql5.com/en/users/artmedia70/publications

Take his solution and look how he manages buttons that are changing when the mouse hovers is over the button: https://www.mql5.com/en/articles/11356

I appreciate your support, but I can't find what I do wrong. Any ideas?

Reason: