Support Board
Date/Time: Mon, 25 Nov 2024 11:43:15 +0000
Post From: GDI Flickering
[2024-03-15 21:47:48] |
TPH_Main - Posts: 13 |
// #pragma once void DrawToChart(HWND WindowHandle, HDC DeviceContext, SCStudyInterfaceRef sc); SCSFExport scsf_Test_GDILabels(SCStudyInterfaceRef sc) { int inputNum = -1; SCInputRef Input_FontxPOS = sc.Input[++inputNum]; SCInputRef Input_FontyPOS = sc.Input[++inputNum]; SCInputRef Input_FontAlignment = sc.Input[++inputNum]; SCInputRef Input_FontSize = sc.Input[++inputNum]; SCInputRef Input_FontColorCSS = sc.Input[++inputNum]; SCInputRef Input_BgColorCSS = sc.Input[++inputNum]; SCInputRef Input_InvalidBgColorCSS = sc.Input[++inputNum]; if (sc.SetDefaults) { sc.GraphName = "Test"; sc.GraphRegion = 0; // sc.AutoLoop = 1; // sc.UpdateAlways = 1; sc.HideDLLAndFunctionNames = 1; sc.HideStudy = 0; sc.IncludeInStudySummary = 0; sc.IncludeInSpreadsheet = 0; sc.AlertConditionEnabled = 0; sc.DisplayStudyInputValues = 0; sc.DisplayStudyName = 0; sc.GlobalDisplayStudySubgraphsNameAndValue = 0; sc.ProtectStudy = 1; sc.CalculationPrecedence = STD_PREC_LEVEL; Input_FontxPOS.Name = "Label x Position"; Input_FontxPOS.SetInt(100); Input_FontxPOS.SetIntLimits(1, 100); Input_FontyPOS.Name = "Label y Position"; Input_FontyPOS.SetInt(3); Input_FontyPOS.SetIntLimits(1, 100); Input_FontAlignment.Name = "Label Alignment"; Input_FontAlignment.SetCustomInputStrings("Left;Center;Right"); Input_FontAlignment.SetCustomInputIndex(2); Input_FontSize.Name = "Font Size"; Input_FontSize.SetInt(10); Input_FontSize.SetIntLimits(6, 36); Input_FontColorCSS.Name = "Font Color"; Input_FontColorCSS.SetColor(255, 255, 255); Input_BgColorCSS.Name = "Background Color"; Input_BgColorCSS.SetColor(90, 100, 113); Input_InvalidBgColorCSS.Name = "Invalid Background Color"; Input_InvalidBgColorCSS.SetColor(255, 0, 255); } // Hook drawing function sc.p_GDIFunction = DrawToChart; } void DrawToChart(HWND WindowHandle, HDC DeviceContext, SCStudyInterfaceRef sc) { // Inputs int inputNum = -1; SCInputRef Input_FontxPOS = sc.Input[++inputNum]; SCInputRef Input_FontyPOS = sc.Input[++inputNum]; SCInputRef Input_FontAlignment = sc.Input[++inputNum]; SCInputRef Input_FontSize = sc.Input[++inputNum]; SCInputRef Input_FontColorCSS = sc.Input[++inputNum]; SCInputRef Input_BgColorCSS = sc.Input[++inputNum]; SCInputRef Input_InvalidBgColorCSS = sc.Input[++inputNum]; // Set drawing font n_ACSIL::s_GraphicsFont GraphicsFont; GraphicsFont.m_FaceName = sc.ChartTextFont(); GraphicsFont.m_Height = Input_FontSize.GetInt(); GraphicsFont.m_Weight = FW_BOLD; sc.Graphics.SetTextFont(GraphicsFont); // Set colors n_ACSIL::s_GraphicsColor fontColor; fontColor.SetColorValue(Input_FontColorCSS.GetColor()); sc.Graphics.SetTextColor(fontColor); n_ACSIL::s_GraphicsColor GraphicsColor; GraphicsColor.SetColorValue(Input_BgColorCSS.GetColor()); sc.Graphics.SetBackgroundColor(GraphicsColor); // Set position int width = sc.ChartRegion1RightCoordinate - sc.ChartRegion1LeftCoordinate; int height = sc.ChartRegion1BottomCoordinate - sc.ChartRegion1TopCoordinate; int xPosition = width * Input_FontxPOS.GetInt() / 100.00; int yPosition = height * Input_FontyPOS.GetInt() / 100.00; switch (Input_FontAlignment.GetIndex()) { case 0: sc.Graphics.SetTextAlign(TA_LEFT); break; case 1: sc.Graphics.SetTextAlign(TA_CENTER); break; case 2: sc.Graphics.SetTextAlign(TA_RIGHT); break; default: sc.Graphics.SetTextAlign(TA_CENTER); break; } // Draw sc.Graphics.DrawTextAt("testing 123", xPosition, yPosition); // Debug // SCString typeString; // typeString.Format("TEST:%d", // Input_FontxPOS.GetInt()); // sc.AddMessageToLog(typeString, 0); } So this is working correctly it just seems strange to define inputs twice...idk maybe Sierra Chart Engineers could explain why to help clarify. Thank you. |