WindowHeight in Pixel ?

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.

10

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 !!!

52

From the Experts

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

GetPaneHeights - MQL4 Code Base

10

great code!

#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

//

466

ekud87:
great code!

#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);