Login Page - Create Account

Support Board


Date/Time: Tue, 21 Jan 2025 10:50:24 +0000



Post From: Adding Text with GDI Function to Study

[2018-08-10 12:40:30]
Sierra Chart Engineering - Posts: 104368
Make sure you set the text align:


void DrawToChart(HWND WindowHandle, HDC DeviceContext, SCStudyInterfaceRef sc )
{
  //Create a Yellow brush
  HBRUSH Brush = CreateSolidBrush(RGB(255,255,0));

  //Select the brush into the device context
  HGDIOBJ PriorBrush = SelectObject(DeviceContext, Brush);

  //Draw a rectangle at the top left of the chart
  Rectangle(DeviceContext, 0,0 ,200, 200);

  //Remove the brush from the device context and put the prior brush back in. This is critical!
  SelectObject(DeviceContext,PriorBrush);

  //Delete the brush. This is critical! If you do not do this, you will end up with a GDI leak and crash Sierra Chart.
  DeleteObject(Brush);

  ::SetTextAlign(DeviceContext, TA_NOUPDATECP);
  ::TextOut(DeviceContext, 225, 225, "Hello.", 6);

  return;
}

Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing