Support Board
Date/Time: Sun, 02 Feb 2025 13:03:31 +0000
Post From: sc.SetChartWindowState is active across workbooks
[2019-09-05 13:10:29] |
User462086 - Posts: 196 |
Hello, I'm trying to bring 2 background charts to the foreground with a hotkey. The code below works fine unless there's more than one chartbook open that's using the code and has the same chart numbers, in which case it will cycle through the other open chartbooks' charts. Edit: The documentation states: "The sc.SetChartWindowState function is used to minimize, restore or maximize the chart specified by the ChartNumber parameter in the same Chartbook containing the chart the study instance is applied to." How do I restrict this function and the keypress to only the active chartbook? Many thanks!! #include "sierrachart.h" SCDLLName("ShowCharts") bool keydown(int key){ return (GetKeyState(key) & 0x100) != 0; } SCSFExport scsf__ShowCharts(SCStudyInterfaceRef sc) { SCInputRef chartNum_1 = sc.Input[0]; SCInputRef chartNum_2 = sc.Input[1]; if (sc.SetDefaults) { sc.GraphName = "ShowCharts"; sc.GraphRegion = 0; // main price graph sc.AutoLoop = 0; //Automatic looping is disabled. chartNum_1.Name = "Chart number to show"; chartNum_1.SetInt(2); chartNum_2.Name = "Chart number to show"; chartNum_2.SetInt(3); return; } // show charts when 'CTRL' is pressed bool pressed = keydown(VK_CONTROL); if( pressed ){ if(chartNum_1.GetInt()>0){ sc.SetChartWindowState(chartNum_1.GetInt(),CWS_MINIMIZE); sc.SetChartWindowState(chartNum_1.GetInt(),CWS_RESTORE); } if(chartNum_2.GetInt()>0){ sc.SetChartWindowState(chartNum_2.GetInt(),CWS_MINIMIZE); sc.SetChartWindowState(chartNum_2.GetInt(),CWS_RESTORE); } } } Date Time Of Last Edit: 2019-09-05 13:13:13
|