Any possibility to get the status of the crosshair?

 

I didn't find any ChartGetInteger() function showing if the crosshair is enabled. Are there other possibilites?

 
Marbo: Are there other possibilites?
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.

What are you trying to do?

 
William Roeder:
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.

What are you trying to do?

Sorry, I had never thought that my question could lead to misunderstandings. What I want to do is really simple: if the key "A" is pressed, my indicator should check if the crosshair is active/enabled. If yes, a horizontal line should be drawn right where the mouse pointer is. And if the crosshair is inactive, nothing should be done. Simple, but I don't know how to check if the crosshair is active/inactive.

Files:
crosshair.PNG  3 kb
 
Marbo:but I don't know how to check if the crosshair is active/inactive.

You originally stated that "you didn't find any function." So you already know, it isn't possible.

Marbo: Sorry, I had never thought that my question could lead to misunderstandings.

Since it isn't possible, you asked for alternatives. Without knowing what you are trying to do, no alternatives can be guessed.

 
William Roeder:

You originally stated that "you didn't find any function." So you already know, it isn't possible.

Since it isn't possible, you asked for alternatives. Without knowing what you are trying to do, no alternatives can be guessed.

Got your point. The only possibility is to offer a job that somebody can solve this problem with a DLL. I hope it's possible to check if the crosshair symbol is clicked. But that's beyond my coding-knowledge.

 
Marbo:

 if the key "A" is pressed, my indicator should check if the crosshair is active/enabled. If yes, a horizontal line should be drawn right where the mouse pointer is. And if the crosshair is inactive, nothing should be done. Simple, but I don't know how to check if the crosshair is active/inactive.

Why do you need to check if the crosshair is active?

Why not have the code draw the line when the "A" is pressed? There would be no reason to press the "A" unless you want the line drawn.

 
Keith Watford:

Why do you need to check if the crosshair is active?

Why not have the code draw the line when the "A" is pressed? There would be no reason to press the "A" unless you want the line drawn.

My indicator does the following: when I press 'A' a horizontal line is automatically printed at the high or the low of the candle where the mouse is at the moment. If the mousepointer is closer to the high of the candle the line is printed at the high and if the mousepointer is closer to the low it will be printed at the candle's low.  That's pretty useful for me because most of the time I place lines at the highs and lows of candles.

But sometimes I place lines "somewhere" in the chart which have nothing to do with with the candle position I receive with ChartXYToTimePrice().

And if I have a bool-function which shows me if the crosshair is enabled I know which line should be printed. Of course I could also use other keys but I already use lots of them in my indicator and I hoped it's possible to check the crosshair's status easier.

 
Marbo:

My indicator does the following: when I press 'A' a horizontal line is automatically printed at the high or the low of the candle where the mouse is at the moment. If the mousepointer is closer to the high of the candle the line is printed at the high and if the mousepointer is closer to the low it will be printed at the candle's low.  That's pretty useful for me because most of the time I place lines at the highs and lows of candles.

But sometimes I place lines "somewhere" in the chart which have nothing to do with with the candle position I receive with ChartXYToTimePrice().

And if I have a bool-function which shows me if the crosshair is enabled I know which line should be printed. Of course I could also use other keys but I already use lots of them in my indicator and I hoped it's possible to check the crosshair's status easier.

I just found a piece of code which changes the current chartwindow's timeframe by using the user32.dll's PostMessageA function.

So if I can virtually press these window-buttons (M1-MN1) I think there could also be a user32.dll function to check which window-buttons are enabled/disabled/pressed. Is that possible?

#import "user32.dll"
   int   PostMessageA(int hWnd, int Msg, int wParam, int lParam);
   int   GetWindow(int hWnd, int uCmd);
#import

void switchPeriod (int period) {
   if (period==_Period) return;
   int winTF=0;
   switch (period) {
      case PERIOD_MN1: winTF = 33334;  break;
      case PERIOD_W1 : winTF = 33141;  break;
      case PERIOD_D1 : winTF = 33134;  break;
      case PERIOD_H4 : winTF = 33136;  break;
      case PERIOD_H1 : winTF = 35400;  break;
      case PERIOD_M30: winTF = 33140;  break;
      case PERIOD_M15: winTF = 33139;  break;
      case PERIOD_M5 : winTF = 33138;  break;
      case PERIOD_M1 : winTF = 33137;  break;
   }

   int window = GetWindow (WindowHandle(_Symbol, _Period), 0); 
   PostMessageA(window, 0x0111, winTF, 0);
   PostMessageA(window, 0x0100, 0x23, 0);
}
 
Marbo:

I didn't find any ChartGetInteger() function showing if the crosshair is enabled. Are there other possibilites?

You can try bottom to came ctrl+F or   Mouse.PressScroll(); and set static variable to know crosshair active;///

Globla scoop///>>>>static bool  crosshair_active=false;////

///////>>>>i had this issue >>>> after Press key  ctrl+F how to  know (get) if key pressed??>>>>

may   keybd_event(int bVk,int bScan,int dwFlags,int dwExtraInfo);>>>>


can Scan>>>   int bScan>>>>>  ctrl+F  >>>is pressed......>>>> true ==keybd_event( 0,VK_CONTROL, 0, 0);// 

///===========================================================

keybd_event( VK_F, 0, KEYEVENTF_KEYUP, 0);////unpress

          keybd_event( VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);////unpress

          keybd_event(VK_CONTROL, 0, 0, 0);

          keybd_event(VK_F, 0, 0, 0);

          keybd_event( VK_F, 0, KEYEVENTF_KEYUP, 0);////unpress

          keybd_event( VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);////unpress

         crosshair_active=true;

//=============================================================

///////////////////////////////////////////////////////////////

check on event controller mouse move ////   if(true !=keybd_event( 0,VK_CONTROL, 0, 0)) crosshair_active=false; ;// 
Reason: