87 lines
No EOL
8.2 KiB
Text
87 lines
No EOL
8.2 KiB
Text
// モニターの解像度による表示差を調整するコード
|
|
|
|
// グローバル変数
|
|
// DPI換算
|
|
double DPIAdjust;
|
|
|
|
|
|
int OnInit()
|
|
{
|
|
//+------------------------------------------------------------------+
|
|
// DPI換算
|
|
double USERdpi = TerminalInfoInteger(TERMINAL_SCREEN_DPI);
|
|
double DevPCdpi = 144;
|
|
DPIAdjust = USERdpi / DevPCdpi;
|
|
//+------------------------------------------------------------------+
|
|
// 必ず、チャートコメント表示等の上に挿入
|
|
}
|
|
|
|
|
|
//以下、仕様のx/y部分に、
|
|
x = (int)NormalizeDouble(x * DPIAdjust, 0); // 別途DPI換算コードで調整
|
|
y = (int)NormalizeDouble(y * DPIAdjust, 0); // 別途DPI換算コードで調整
|
|
//などと、係数をかけたものをint型にして代入
|
|
|
|
//| ボタン仕様
|
|
void Button(string name, string text, int x, int y ,color clr, int a)
|
|
{
|
|
x = (int)NormalizeDouble(x * DPIAdjust, 0); // 別途DPI換算コードで調整
|
|
y = (int)NormalizeDouble(y * DPIAdjust, 0); // 別途DPI換算コードで調整
|
|
|
|
ObjectCreate(0,name,OBJ_BUTTON,ChartWindowFind(),0,0); // ボタンの作成をする(この段階ではデザインや場所が指定されていない枠だけのボタン
|
|
ObjectSetInteger(0,name,OBJPROP_COLOR,clrWhite); // ボタンの文字色を設定する
|
|
ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false); // ボタンを選択して移動したり消したりしないようにするための設定
|
|
ObjectSetInteger(0,name,OBJPROP_HIDDEN,true); // ボタンがオブジェクトのリストに表示されないようにするための設定
|
|
ObjectSetString (0,name,OBJPROP_TEXT,text); // ボタンに表示するテキストを設定する
|
|
ObjectSetString (0,name,OBJPROP_FONT,"Segoe UI"); // ボタンの文字のフォントを設定する
|
|
ObjectSetInteger(0,name,OBJPROP_FONTSIZE,8); // ボタンの文字サイズを設定する
|
|
ObjectSetInteger(0,name,OBJPROP_CORNER,a); // ボタンの基準位置をきめる(右上・左上・左下・右下)
|
|
ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x); // ボタンの基準位置からのX座標を設定
|
|
ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y); // ボタンの基準位置からのY座標を設定
|
|
ObjectSetInteger(0,name,OBJPROP_XSIZE,18); // ボタンの横幅の設定
|
|
ObjectSetInteger(0,name,OBJPROP_YSIZE,16); // ボタンの縦幅の設定
|
|
ObjectSetInteger(0,name,OBJPROP_BGCOLOR,clr); // ボタンの色の設定
|
|
//ObjectSetInteger(0,name,OBJPROP_BORDER_COLOR,clrGray); // ボタンの枠線の色を設定 基本的にはボタン色と一緒で問題なくて、枠線を付けたい時だけ別にする
|
|
//ObjectSetInteger(0,name,OBJPROP_STATE,false); // ボタンの状態を設定(押されている状態か、押されていない状態か) 最初は押されていない状態で大丈夫
|
|
ObjectSetInteger(0,name,OBJPROP_BACK,false); // オブジェクトの背景表示設定
|
|
//ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_RIGHT_UPPER);
|
|
ObjectSetInteger(0,name,OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
|
|
}
|
|
|
|
void EA_label(string text, color clr)
|
|
{
|
|
int x = (int)NormalizeDouble(26 * DPIAdjust, 0); // 別途DPI換算コードで調整
|
|
int y = (int)NormalizeDouble(18 * DPIAdjust, 0); // 別途DPI換算コードで調整
|
|
|
|
ObjectCreate(0, "EA_label", OBJ_LABEL, 0, 0, 0);
|
|
ObjectSetString(0, "EA_label", OBJPROP_TEXT, text);
|
|
ObjectSetInteger(0, "EA_label", OBJPROP_COLOR, clr);
|
|
ObjectSetInteger(0, "EA_label", OBJPROP_XDISTANCE, x);
|
|
ObjectSetInteger(0, "EA_label", OBJPROP_YDISTANCE, y);
|
|
ObjectSetInteger(0, "EA_label", OBJPROP_FONTSIZE, 10);
|
|
ObjectSetInteger(0, "EA_label", OBJPROP_SELECTABLE, false);
|
|
ObjectSetInteger(0, "EA_label", OBJPROP_HIDDEN, true);
|
|
ObjectSetString(0, "EA_label", OBJPROP_FONT, "Segoe UI");
|
|
ObjectSetInteger(0, "EA_label", OBJPROP_CORNER, CORNER_RIGHT_UPPER);
|
|
ObjectSetInteger(0, "EA_label", OBJPROP_ANCHOR, ANCHOR_RIGHT_UPPER);
|
|
ObjectSetInteger(0, "EA_label", OBJPROP_BACK, false);
|
|
}
|
|
|
|
// チャートコメントの仕様
|
|
void CommentLabel(string ComName, string ComText, int ComPos_x, int ComPos_y, int ComSize, color ComClr= clrBlack)
|
|
{
|
|
ComPos_x = (int)NormalizeDouble(ComPos_x * DPIAdjust, 0); // 別途DPI換算コードで調整
|
|
ComPos_y = (int)NormalizeDouble(ComPos_y * DPIAdjust, 0); // 別途DPI換算コードで調整
|
|
|
|
ObjectCreate(ComName, OBJ_LABEL, 0, 0, 0);
|
|
ObjectSetString (0, ComName, OBJPROP_TEXT, ComText);
|
|
ObjectSetInteger(0, ComName, OBJPROP_XDISTANCE, ComPos_x);
|
|
ObjectSetInteger(0, ComName, OBJPROP_YDISTANCE, ComPos_y);
|
|
ObjectSetInteger(0, ComName, OBJPROP_FONTSIZE, ComSize);
|
|
ObjectSetInteger(0, ComName, OBJPROP_COLOR, ComClr);
|
|
ObjectSetString (0, ComName, OBJPROP_FONT, "Segoe UI");
|
|
ObjectSetInteger(0, ComName, OBJPROP_BACK, true);
|
|
ObjectSetInteger(0, ComName, OBJPROP_SELECTABLE, false);
|
|
ObjectSetInteger(0, ComName, OBJPROP_CORNER, CORNER_RIGHT_UPPER);
|
|
ObjectSetInteger(0, ComName, OBJPROP_ANCHOR, ANCHOR_RIGHT_UPPER);
|
|
} |