0
Views
0
Downloads
0
Favorites
transparency
//+------------------------------------------------------------------+
//| transparency.mq4 |
//| Copyright © 2014, Vladimir Karputov |
//| http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2014, Vladimir Karputov"
#property link "http://wmua.ru/slesar/"
#property version "1.20"
#property strict
#import "user32.dll"
//+------------------------------------------------------------------+
//| GetAncestor. Retrieves the handle to the ancestor of the |
//| specified window. Èçâëåêàåò äåñêðèïòîð ïðåäêà çàäàííîãî îêíà |
//+------------------------------------------------------------------+
int GetAncestor(int hwnd,int gaFlags);
//+------------------------------------------------------------------+
//| GetWindowLongW. Retrieves information about the specified |
//| window. Ïîëó÷àåò èíôîðìàöèþ îá óêàçàííîì îêíå |
//+------------------------------------------------------------------+
int GetWindowLongW(
int hWnd,
int nIndex // GWL_EXSTYLE
);
//+------------------------------------------------------------------+
//| SetWindowLongW. Èçìåíÿåò àòðèáóò çàäàííîãî îêíà |
//+------------------------------------------------------------------+
int SetWindowLongW(
int hWnd,
char nIndex, // GWL_EXSTYLE
int dwNewLong // WS_EX_LAYERED
);
//+------------------------------------------------------------------+
//| SetLayeredWindowAttributes. Sets the opacity and transparency |
//| color key of a layered window. Óñòàíàâëèâàåò ñâåòîïðîíèöàåìîñòü |
//| è ïðîçðà÷íîñòü îêðàñêè ìíîãîñëîéíîãî îêíà |
//+------------------------------------------------------------------+
bool SetLayeredWindowAttributes(
int hwnd,// A handle to the layered window
int crKey, // 0
int bAlpha, // ñòåïåíü íåïðîçðà÷íîñòè 0-255
int dwFlags // 0x00000002
);
#import
#define GA_ROOT 0x0002 // Retrieves the root window by walking the chain of parent windows.
#define GWL_EXSTYLE -20 // Sets a new extended window style
#define WS_EX_LAYERED 0x00080000 // Style. The window is a layered window.
#define LWA_ALPHA 0x00000002 // Use bAlpha to determine the opacity of the layered window.
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//---
long mainChartID=ChartID(); // âîçâðàùàåò èäåíòèôèêàòîð òåêóùåãî ãðàôèêà
int hdlmainChartID=ChartWindowsHandle(mainChartID);
int hdlRoot=GetAncestor(hdlmainChartID,GA_ROOT);
int SetWindowLongW_func;
if(GetWindowLongW(hdlRoot,GWL_EXSTYLE)&WS_EX_LAYERED)
{
// Ó îêíà óæå åñòü ñòèëü WS_EX_LAYERED. Óäàëèì WS_EX_LAYERED èç ýòîãî îêíà ñòèëåé.
// Window already has a style WS_EX_LAYERED. Remove WS_EX_LAYERED from this window styles.
SetWindowLongW_func=SetWindowLongW(hdlRoot,GWL_EXSTYLE,
GetWindowLongW(hdlRoot,GWL_EXSTYLE)&~WS_EX_LAYERED);
return;
}
// Óñòàíàâëèâàåì WS_EX_LAYERED íà ROOT îêíî
SetWindowLongW_func=SetWindowLongW(hdlRoot,GWL_EXSTYLE,
GetWindowLongW(hdlRoot,GWL_EXSTYLE)|WS_EX_LAYERED);
SetLayeredWindowAttributes(hdlRoot,0,(255*70)/100,LWA_ALPHA);
return;
}
//+------------------------------------------------------------------+
//| The function gets the handle graphics |
//| Ôóíêöèÿ ïîëó÷àåò õýíäë ãðàôèêà |
//+------------------------------------------------------------------+
int ChartWindowsHandle(long chart_ID)
{
//--- prepare the variable to get the property value
//--- ïîäãîòîâèì ïåðåìåííóþ äëÿ ïîëó÷åíèÿ çíà÷åíèÿ ñâîéñòâà
long result=-1;
//--- reset the error value
//--- ñáðîñèì çíà÷åíèå îøèáêè
ResetLastError();
//--- receive the property value
//--- ïîëó÷èì çíà÷åíèå ñâîéñòâà
if(!ChartGetInteger(chart_ID,CHART_WINDOW_HANDLE,0,result))
{
//--- display the error message in Experts journal
//--- âûâåäåì ñîîáùåíèå îá îøèáêå â æóðíàë "Ýêñïåðòû"
Print(__FUNCTION__+", Error Code = ",GetLastError());
}
//--- return the value of the chart property
//--- âåðíåì çíà÷åíèå ñâîéñòâà ãðàôèêà
return((int)result);
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---