WindowHeight in Pixel ?

kiprep
10

Anyone suggest me how to get pixel value of main window height. I want to calculate y_distance from the bottom of the main window by the following method.

y_distance = (price-WindowPriceMin())/(WindowPriceMax()-WindowPriceMin())*WindowHeight

I need to get the value of WindowHeight in pixel in order to give y-distance in pixel.

kiprep
10
kiprep  

I found a solution !!!

I found a method to get window height as follows.

//

#import "user32.dll"

int GetWindowDC(int dc);

int ReleaseDC(int h, int dc);

bool GetWindowRect(int h, int& pos[4]);

//

.............................

//

int hWnd = WindowHandle(Symbol(), Period());

int hDC = GetWindowDC(hWnd);

int rect[4];

GetWindowRect(hWnd, rect);

int wW = rect[2] - rect[0]; // Window width

int wH = rect[3] - rect[1]; // Window height

//

Thank you !!!

CodeMeister
52
CodeMeister  

From the Experts

Here is a worked example of determining the height in pixels of each indicator window.

GetPaneHeights - MQL4 Code Base

ekud87
10
ekud87  

great code!

but, please close import...

#import "user32.dll"

int GetWindowDC(int dc);

int ReleaseDC(int h, int dc);

bool GetWindowRect(int h, int& pos[4]);

#import

.............................

//

int hWnd = WindowHandle(Symbol(), Period());

int hDC = GetWindowDC(hWnd);

int rect[4];

GetWindowRect(hWnd, rect);

int wW = rect[2] - rect[0]; // Window width

int wH = rect[3] - rect[1]; // Window height

//

Ovo
466
Ovo  
ekud87:
great code!

but, please close import...

#import "user32.dll"

int GetWindowDC(int dc);

int ReleaseDC(int h, int dc);

bool GetWindowRect(int h, int& pos[4]);

#import

.............................

//

int hWnd = WindowHandle(Symbol(), Period());

int hDC = GetWindowDC(hWnd);

int rect[4];

GetWindowRect(hWnd, rect);

int wW = rect[2] - rect[0]; // Window width

int wH = rect[3] - rect[1]; // Window height

//

I assume that the closing import was not required if compiled with the 509 compiler.

With the 600+ code it is easier to avoid the winapi and use

ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS);