Code: Select all
var scale = new Scale(0, hMainWnd);
hWndDialog = createWindowEx(
0, //dwExStyle
pClassName, //lpClassName
0, //lpWindowName
0x90CE0000, //WS_VISIBLE|WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_THICKFRAME
0, //x
0, //y
392, //nWidth
230, //nHeight
hMainWnd, //hWndParent
0, //ID
hInstanceDLL, //hInstance
DialogCallback //Script function callback. To use it class must be registered by WindowRegisterClass.
);
function createWindowEx(dwExStyle, lpClassName, lpWindowName, styles, x, y, w, h, hWndParent, id, hInstance, callback) {
return oSys.Call(
"user32::CreateWindowEx" + _TCHAR,
dwExStyle,
lpClassName,
lpWindowName,
styles,
scale.x(x),
scale.y(y),
scale.x(w),
scale.y(h),
hWndParent,
id,
hInstance,
callback
);
}
function Scale(hDC, hWnd) {
var hNewDC = hDC || oSys.Call("user32::GetDC", hWnd);
if(hNewDC) {
this._x = oSys.Call("gdi32::GetDeviceCaps", hNewDC, 88 /*LOGPIXELSX*/);
this._y = oSys.Call("gdi32::GetDeviceCaps", hNewDC, 90 /*LOGPIXELSY*/);
//Align to 16 pixel
this._x += this._x % 16;
this._y += this._y % 16;
if(!hDC) oSys.Call("user32::ReleaseDC", hWnd, hNewDC);
this.x = function(x) {
return oSys.Call("kernel32::MulDiv", x, this._x, 96);
};
this.y = function(y) {
return oSys.Call("kernel32::MulDiv", y, this._y, 96);
};
}
else {
this.x = this.y = function(n) {
return n;
};
}
}