/*
* -----
* Screenshot Sender - interface.js
* -----
* Functions for loading interface windows.
* -----
*/
var objWindows = {};
var objChildWindows = {};
var objControls = {};
var objPrefTemp = {};
var InterfacePath = MsgPlus.ScriptFilesPath + '\\Languages\\';
/*
Name: FileExists
Purpose: Check whether a file exists or not.
Parameters: sFilePath - The path to the file that we want to check the existence of.
Return: Boolean, whether the file exists.
*/
function FileExists(sFilePath) {
_debug.getfuncname(arguments);
var nFilePtr = _win32.CreateFileW(sFilePath, 0x80000000, 1, 0, 3, 0, 0)
_win32.CloseHandle(nFilePtr);
return nFilePtr !== -1;
}
/*
Name: OpenWindow
Purpose: Open an interface window in the current language.
Parameters: Name - The name of the window.
Return: pPlusWnd object.
*/
function OpenWindow(Name, ShowCode, SetIcon) {
_debug.getfuncname(arguments);
if (typeof objWindows[Name] === TYPE_OBJECT &&
typeof objWindows[Name].Handle === TYPE_NUMBER &&
_win32.IsWindow(objWindows[Name].Handle)) {
_win32.SetForegroundWindow(objWindows[Name].Handle);
return false;
}
if (typeof ShowCode === TYPE_UNDEFINED) ShowCode = 0;
if (typeof SetIcon === TYPE_UNDEFINED) SetIcon = 0;
if (_lang.IsRtl == true) ShowCode |= WNDOPT_RTL;
if (IsWinVista() == true) ShowCode |= 0x100;
// If the file exists in the current translation, load it
var FilePath = InterfacePath + (typeof objPreferences['cLanguage'] === TYPE_UNDEFINED ? MsgPlus.UILangCode : objPreferences['cLanguage']) + '\\' + Name + '.xml';
if (FileExists(FilePath) == false) {
// Otherwise, load the default translation(en)
FilePath = InterfacePath + 'en\\' + Name + '.xml';
}
objWindows[Name] = MsgPlus.CreateWnd('\\' + FilePath, Name, ShowCode);
if (SetIcon !== false && hScriptIcon !== 0) SetWndIcon(objWindows[Name].Handle);
if (IsWinVista() === false) _win32.SetWindowLongW(objWindows[Name].Handle, _win32._const._GWL_STYLE, _win32.GetWindowLongW(objWindows[Name].Handle, _win32._const._GWL_STYLE) &~ _win32._const._WS_CAPTION &~ _win32._const._WS_BOARDER);
return objWindows[Name];
}
function RegisterWindowHooks(pPlusWnd, nHooks, bHook) {
_debug.getfuncname(arguments);
if (typeof pPlusWnd === TYPE_STRING) {
if (typeof objWindows[pPlusWnd] !== TYPE_UNDEFINED) pPlusWnd = objWindows[pPlusWnd];
else if (typeof objChildWindows[pPlusWnd] !== TYPE_UNDEFINED) pPlusWnd = objChildWindows[pPlusWnd];
else return false;
}
if (typeof bHook === TYPE_UNDEFINED) bHook = true;
if (typeof nHooks === TYPE_OBJECT && nHooks.length) {
var i = nHooks.length, val;
while (i--) {
val = 1*nHooks[i];
if (!isNaN(val) && val > 0) pPlusWnd.RegisterMessageNotification(val, bHook);
}
}
else if (typeof nHooks === TYPE_NUMBER) {
pPlusWnd.RegisterMessageNotification(nHooks, bHook);
}
}
/*
Name: OpenChildWindow
Purpose: Open an child interface window in the current language.
Parameters: Name - The name of the child window.
Parent - The pPlusWnd object of the parent window
X + Y - the position of the child window on the parent.
Visible - Boolean : if the child window should be shown by default or not
FileName - String : file name of the XML file(without file extension)
Return: pPlusWnd object.
*/
function OpenChildWindow(Name, Parent, X, Y, Visible, FileName) {
_debug.getfuncname(arguments);
if (typeof Visible === TYPE_UNDEFINED) Visible = true;
if (typeof FileName === TYPE_UNDEFINED) FileName = Parent.WindowId + '-' + Name;
// If the file exists in the current translation, load it
var FilePath = InterfacePath + (typeof objPreferences['cLanguage'] === TYPE_UNDEFINED ? MsgPlus.UILangCode : objPreferences['cLanguage']) + '\\' + FileName + '.xml';
if (FileExists(FilePath) == false) {
// Otherwise, load the default translation(en)
FilePath = InterfacePath + 'en\\' + FileName + '.xml'
}
objChildWindows[Name] = MsgPlus.CreateChildWnd(Parent, '\\' + FilePath, Name, X, Y, Visible);
return objChildWindows[Name];
}
/*
Name: CloseWindow
Purpose: Closes the specified window and removes its reference from the object
Parameters: Name - The name of the window.
Return: True suceeded / False failed
*/
function CloseWindow(Name) {
_debug.getfuncname(arguments);
if (typeof objWindows[Name] !== TYPE_OBJECT) return false;
objWindows[Name].Close(6);
delete objWindows[Name];
return true;
}
/*
Name: EnumControls
Purpose: Enum the controls from a specified window
Parameters: File - The name of the file
pPlusWnd - The Plus! window object
Return: None
*/
function EnumControls(File, pPlusWnd) {
_debug.getfuncname(arguments);
// Load the XML from the specified file
var XML = new ActiveXObject('MSXML.DOMDocument');
XML.load(File);
// Loop through all of the controls
var Controls = XML.selectNodes('/Interfaces/Window[@Id=\'' + pPlusWnd.WindowId + '\']/Controls/Control');
for (i=0; i<Controls.length; i ++) {
var Id = Controls[i].getAttribute('Id');
var Type = Controls[i].getAttribute('xsi:type');
// Controls starting with _ are options but not stired in the registry (ie Debug info is in the ScriptInfo.xml)
if (Id.charAt(0) !== '_') {
// Get the value depending on the control's type
objControls[Id] = {};
objControls[Id].XsiType = Type;
objControls[Id].Value = pPlusWnd_GetControlvalue(pPlusWnd, Id, Type);
}
}
}
/*
Name: pPlusWnd_GetControlvalue
Purpose: Get the values for each control on the window
Parameters: pPlusWnd - The Plus! window object
Id - The id of the control
XsiType - The type of the control
Return: The controls value
*/
function pPlusWnd_GetControlvalue(pPlusWnd, Id, XsiType) {
_debug.getfuncname(arguments);
switch (XsiType) {
case 'RichEditControl':
case 'EditControl':
return pPlusWnd.GetControlText(Id);
case 'CheckBoxControl':
case 'RadioControl':
return pPlusWnd.Button_IsChecked(Id);
case 'SliderControl':
return pPlusWnd.SendControlMessage(Id, _win32._const._TBM_GETPOS, 0, 0);
case 'ComboBoxControl':
return pPlusWnd.Combo_GetCurSel(Id);
default :
delete objControls[Id]; // We don't use all of the controls therefore lets remove any from the object so they dont present errors
}
}
/*
Name: pPlusWnd_SetControlvalue
Purpose: Set the values for each control on the window
Parameters: pPlusWnd - The Plus! window object
Id - The id of the control
XsiType - The type of the control
Value - The value to set for the control
Return: The controls value
*/
function pPlusWnd_SetControlvalue(pPlusWnd, Id, XsiType, Value) {
_debug.getfuncname(arguments);
switch (XsiType) {
case 'RichEditControl':
case 'EditControl':
return pPlusWnd.SetControlText(Id, Value);
case 'CheckBoxControl':
case 'RadioControl':
return pPlusWnd.Button_SetCheckState(Id, Value);
case 'SliderControl':
return pPlusWnd.SendControlMessage(Id, _win32._const._TBM_SETPOS, true, Value);
case 'ComboBoxControl':
return pPlusWnd.Combo_SetCurSel(Id, Value);
}
}
/*
Name: OpenPreferences
Purpose: Opens the preferences window
Parameters: None
Return: The preferences window
*/
function OpenPreferences() {
_debug.getfuncname(arguments);
var pPlusWnd = OpenWindow('Preferences', 1, true);
if (!pPlusWnd) return;
LoadChildWindows();
var PrefSize = GetWindowSize(pPlusWnd.Handle);
if (PrefSize !== false) {
var PrefWidthSmall = PrefSize.Width;
var ChildSize = GetWindowSize(objChildWindows['PrefGeneral'].Handle);
var DashSize = GetWindowSize(objChildWindows['PrefDashboard'].Handle);
objPrefTemp['WidthLarge'] = PrefWidthSmall + ChildSize.Width - DashSize.Width;
objPrefTemp['WidthSmall'] = PrefWidthSmall;
} else {
objPrefTemp['WidthLarge'] = 618;
objPrefTemp['WidthSmall'] = 317;
}
objPrefTemp['ChildOpen'] = 'PrefDashboard';
Preferences_ShowChild('PrefDashboard');
_win32.ShowWindow(pPlusWnd.Handle, _win32._const._SW_SHOW);
return pPlusWnd;
}
/*
Name: LoadChildWindows
Purpose: Load our child windows to the main container Preferences
Parameters: None
Return: None
*/
function LoadChildWindows() {
_debug.getfuncname(arguments);
var Pos = {
x: objWindows['Preferences'].GetElementPos('PosChild', POSINFO_X) || 7,
y: objWindows['Preferences'].GetElementPos('PosChild', POSINFO_Y) || 87
}
OpenChildWindow('PrefDashboard', objWindows['Preferences'], Pos.x, Pos.y, false, 'Preferences');
OpenChildWindow('PrefGeneral', objWindows['Preferences'], Pos.x, Pos.y, false, 'PrefGeneral');
with (objChildWindows['PrefGeneral']) {
RegisterWindowHooks('PrefGeneral', [
_win32._const._WM_PARENTNOTIFY,
_win32._const._WM_NOTIFY
]);
//Fill the file types combo box
SendControlMessage('cFileType', _win32._const._CB_RESETCONTENT, 0, 0);
Combo_AddItem('cFileType', 'BMP', 0);
Combo_AddItem('cFileType', 'JPEG', 1);
Combo_AddItem('cFileType', 'GIF', 2);
Combo_AddItem('cFileType', 'PNG', 3);
SetControlText('lblQualityPercent', objPreferences['sldrQuality']+ '%');
//Create the up-down control for the time delay edit control
var hWndUpDown = CreateUpDownControl(GetControlHandle('tTimeDelay'),[0, 3600]);
//File the countdown position combo box
SendControlMessage('cCountdownPos', _win32._const._CB_RESETCONTENT, 0, 0);
for (var i=0; i<5; i ++) Combo_AddItem('cCountdownPos', _lang.text['CountdownTimerPos_' + i], i);
}
OpenChildWindow('PrefFtp', objWindows['Preferences'], Pos.x, Pos.y, false, 'PrefFtp');
with (objChildWindows['PrefFtp']) {
for (var i=0;i<3;i ++) Combo_AddItem('cUploadOptions', _lang.text['FtpOverlayCondition_' + i], i);
}
OpenChildWindow('PrefFtpTestSettings', objWindows['Preferences'], Pos.x, Pos.y, false, 'PrefFtp');
OpenChildWindow('PrefLanguage', objWindows['Preferences'], Pos.x, Pos.y, false, 'PrefLanguage');
OpenChildWindow('PrefLanguageDownload', objWindows['Preferences'], Pos.x, Pos.y, false, 'PrefLanguage');
OpenChildWindow('PrefHotkeys', objWindows['Preferences'], Pos.x, Pos.y, false, 'PrefHotkeys');
OpenChildWindow('PrefHkAddEdit', objWindows['Preferences'], Pos.x, Pos.y, false, 'PrefHotkeys');
OpenChildWindow('PrefAdvanced', objWindows['Preferences'], Pos.x, Pos.y, false, 'PrefAdvanced');
OpenChildWindow('PrefOlAddEdit', objWindows['Preferences'], Pos.x, Pos.y, false, 'PrefAdvanced');
OpenChildWindow('PrefOlSelectContacts', objWindows['Preferences'], Pos.x, Pos.y, false, 'PrefAdvanced');
for (var objChildWindow in objChildWindows) {
EnumControls(MsgPlus.ScriptFilesPath + '\\Languages\\'+objPreferences['cLanguage']+'\\' + objChildWindow + '.xml', objChildWindows[objChildWindow]);
for (var objControl in objControls) {
pPlusWnd_SetControlvalue(objChildWindows[objChildWindow], objControl, objControls[objControl].XsiType, objPreferences[objControl]);
}
if (objChildWindow === 'PrefLanguage') {
LoadAvailableLanguages(objChildWindows[objChildWindow]);
if (objPreferences['cSameLanguage'] == true) {
var LangCode = MsgPlus.UILangCode;
var bShowCode = FileExists(MsgPlus.ScriptFilesPath + '\\Languages\\' + LangCode + '\\' + LangCode + '.xml');
objChildWindows[objChildWindow].Button_SetCheckState('cSameLanguage', bShowCode);
_win32.EnableWindow(objChildWindows[objChildWindow].GetControlHandle('cSameLanguage'), bShowCode);
_win32.EnableWindow(objChildWindows[objChildWindow].GetControlHandle('LvLanguages'), !bShowCode);
}
} else if (objChildWindow === 'PrefAdvanced') {
objChildWindows[objChildWindow].Button_SetCheckState('_cDebug', _debug.enabled);
}
if (objChildWindow === 'PrefFtp') {
if (objPreferences['cPreviews'] == true) {
_win32.EnableWindow(objChildWindows[objChildWindow].GetControlHandle('cUploadScreenshots'), false);
_win32.EnableWindow(objChildWindows[objChildWindow].GetControlHandle('lblLink'), false);
}
if (objPreferences['cUploadFilesWhenIdle'] == true) {
_win32.EnableWindow(objChildWindows['PrefFtp'].GetControlHandle('cSendUploadLink'), false);
}
}
// Clear Object
objControls = {};
}
OnPrefGeneralEvent_ComboSelChanged(objChildWindows['PrefGeneral'], 'cFileType');
LoadLanguageDetails(objChildWindows['PrefLanguage'], 'en');
_hotkey.LoadConfiguredHotkeys(objChildWindows['PrefHotkeys'], 'LvHotkeys');
LoadOverlayTextRules(objChildWindows['PrefAdvanced'], 'LvOverlayRules');
_win32.ShowWindow(objWindows['Preferences'].Handle, _win32._const._SW_SHOW);
}
/*
Name: OpenAbout
Purpose: Opens the about window
Parameters: None
Return: The about window
*/
function OpenAbout() {
_debug.getfuncname(arguments);
var AboutWnd = OpenWindow('About', WNDOPT_INVISIBLE, true);
AboutWnd.SetControlText('lblVersion', CompileVersion());
_win32.ShowWindow(AboutWnd.Handle, _win32._const._SW_SHOW);
_win32.DeleteUrlCacheEntryW('http://screenshotsender.com/usercounter.php');
var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
xmlhttp.open('GET', 'http://screenshotsender.com/usercounter.php', true);
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState === 4) {
AboutWnd.SetControlText('lblUserCount', _lang.text['UserCounter_Text'] + ': ' + xmlhttp.responseText);
}
}
xmlhttp.send('');
return AboutWnd;
}
function Preferences_ShowChild(Name) {
_debug.getfuncname(arguments);
//Hide the other childs
HideChildWindows();
//Do the breadcrumb
Preferences_Breadcrumb(Name);
//Expand or contract the window
if (objPrefTemp['ChildOpen'] === 'PrefDashboard' && Name !== 'PrefDashboard') {
//Expand
ResizeWindow(objWindows['Preferences'].Handle, objPrefTemp['WidthLarge']);
} else if (objPrefTemp['ChildOpen']!== 'PrefDashboard' && Name === 'PrefDashboard') {
//Contract
ResizeWindow(objWindows['Preferences'].Handle, objPrefTemp['WidthSmall']);
}
//Disable the hotkeys while adding/editing a hotkey
if (Name === 'PrefHkAddEdit') {
_hotkey.PauseHotkeyHandling(true);
} else if (objPrefTemp['ChildOpen'] === 'PrefHkAddEdit' && Name !== 'PrefHkAddEdit') {
_hotkey.PauseHotkeyHandling(false);
}
//Show the new child
objChildWindows[Name].Visible = true;
objPrefTemp['ChildOpen'] = Name;
}
function Preferences_Breadcrumb(ChildName) {
_debug.getfuncname(arguments);
ChildName = ChildName || objPrefTemp['ChildOpen']|| 'PrefDashboard';
var ChildInfo = objChildInfo[ChildName];
var bRtl = _lang.IsRtl;
if (ChildInfo.isMainPanel) {
//Dashboard, only show first item
objWindows['Preferences'].SetControlText('btnBread1', _lang.text['Breadcrumb_Preferences']);
for (var i=1; i<=4; i ++) {
var bShow = (i === 1);
_win32.ShowWindow(objWindows['Preferences'].GetControlHandle('btnBread' + i), bShow*5);
_win32.ShowWindow(objWindows['Preferences'].GetControlHandle('btnBread' + i + 'Arrow'), bShow*5);
}
objPrefTemp['Breadcrumb'] =['Preferences'];
} else {
//Other panels, show 2 or more items
var WinPos = GetWindowPos(objWindows['Preferences'].Handle);
var BtnPos = GetWindowPos(objWindows['Preferences'].GetControlHandle('btnBread1'));
var Left = bRtl ? WinPos.Left + WinPos.Width - BtnPos.Left - BtnPos.Width : BtnPos.Left - WinPos.Left;
Nav = GetBread(ChildName);
var nItems = Nav.length;
var nBtnWidth = GetWindowSize(objWindows['Preferences'].GetControlHandle('btnBread2Arrow')).Width;
for (var i=1; i<=4; i ++) {
var bShow = (i <= nItems);
var NameCtrl = objWindows['Preferences'].GetControlHandle('btnBread' + i);
var ArrowBtn = objWindows['Preferences'].GetControlHandle('btnBread' + i + 'Arrow');
if (i <= nItems) {
//Set the text
var Title = _lang.text['Breadcrumb_' + Nav[i-1]];
objWindows['Preferences'].SetControlText('btnBread' + i, Title);
var BBox = GetTextBBox(Title);
if (BBox.Width < 60) BBox.Width += 10;
ResizeWindow(NameCtrl, BBox.Width, -1, false);
//Move the item after the previous
if (i !== 1) {
MoveControl(ArrowBtn, Left);
Left += nBtnWidth + 5;
}
MoveControl(NameCtrl, Left);
Left += BBox.Width + 5;
}
//Show the items
_win32.ShowWindow(NameCtrl, bShow*5);
_win32.ShowWindow(ArrowBtn, bShow*5);
}
objPrefTemp['Breadcrumb'] = Nav.concat();
}
}
function GetBread(child) {
_debug.getfuncname(arguments);
var returns =[child];
if (objChildInfo[child].isMainPanel == true) return['Preferences'];
for (var i in objChildInfo) {
if (objChildInfo[i].childs.join().indexOf(child) !== -1) {
var bread = GetBread(i);
returns = bread.concat(returns);
break;
}
}
return returns;
}
function GetTextBBox(str) {
_debug.getfuncname(arguments);
//Get the device context to test the drawing in
var hWnd = objWindows['Preferences'].GetControlHandle('btnBread1');
var hDC = _win32.GetDC(hWnd);
//Test the drawing
var RECT = Interop.Allocate(16);
_win32.SetBkMode(hDC, 1);
_win32.DrawTextW(hDC, str, str.length, RECT, _win32._const._DT_CALCRECT);
//Release the device context
_win32.ReleaseDC(hWnd, hDC);
//Get the required width and height
var Width = RECT.ReadDWORD(8) - RECT.ReadDWORD(0);
var Height = RECT.ReadDWORD(12) - RECT.ReadDWORD(4);
RECT.Size = 0;
//Return the results
var returns = new Array();
returns.push(Width, Height);
returns.Width = Width;
returns.Height = Height;
return returns;
}
function Preferences_Save(Child) {
_debug.getfuncname(arguments);
if (typeof Child === TYPE_STRING) {
SaveChild(Child);
} else if (typeof Child === TYPE_OBJECT) {
for (var Id in Child) SaveChild(Child[Id]);
} else {
for (var Id in objChildWindows) SaveChild(Id);
}
UpdatePreferences();
LoadPreferences();
_hotkey.LoadHotkeys();
}
function SaveChild(ChildId) {
_debug.getfuncname(arguments);
EnumControls(MsgPlus.ScriptFilesPath + '\\Languages\\en\\' + ChildId + '.xml', objChildWindows[ChildId]);
for (var objControl in objControls) {
objPreferences[objControl] = pPlusWnd_GetControlvalue(objChildWindows[ChildId], objControl, objControls[objControl].XsiType);
}
// Clear Object
objControls = {};
}
function GetWindowPos(hWnd) {
_debug.getfuncname(arguments);
var RECT = Interop.Allocate(16);
if (_win32.GetWindowRect(hWnd, RECT) !== 0) {
var X = RECT.ReadDWORD(0);
var Y = RECT.ReadDWORD(4);
var Width = RECT.ReadDWORD(8) - X;
var Height = RECT.ReadDWORD(12) - Y;
RECT.Size = 0;
var returns = new Array();
returns.push(X, Y, Width, Height);
returns.Left = X;
returns.Top = Y;
returns.Width = Width;
returns.Height = Height;
return returns;
} else {
RECT.Size = 0;
return false;
}
}
function GetWindowSize(hWnd) {
_debug.getfuncname(arguments);
var RECT = Interop.Allocate(16);
if (_win32.GetClientRect(hWnd, RECT) !== 0) {
var Width = RECT.ReadDWORD(8);
var Height = RECT.ReadDWORD(12);
var returns = new Array();
returns.push(Width, Height);
returns.Width = Width;
returns.Height = Height;
return returns;
} else {
RECT.Size = 0;
return false;
}
}
function MoveControl(hWnd, Left, Top) {
_debug.getfuncname(arguments);
if (typeof Left === TYPE_UNDEFINED) Left = -1;
if (typeof Top === TYPE_UNDEFINED) Top = -1;
var RECT = Interop.Allocate(16);
var ParentRECT = Interop.Allocate(16);
var hWndParent = _win32.GetParent(hWnd);
if (_win32.GetWindowRect(hWnd, RECT) && _win32.GetWindowRect(hWndParent, ParentRECT)) {
var Width = RECT.ReadDWORD(8) - RECT.ReadDWORD(0);
var WinWidth = ParentRECT.ReadDWORD(8) - ParentRECT.ReadDWORD(0);
if (Left === -1) Left = RECT.ReadDWORD(0) - ParentRECT.ReadDWORD(0) - 10;
if (Top === -1) Top = RECT.ReadDWORD(4) - ParentRECT.ReadDWORD(4);
ParentRECT.Size = 0;
RECT.Size = 0;
} else {
ParentRECT.Size = 0;
RECT.Size = 0;
return false;
}
var x = 1*Left;
var y = 1*Top;
return(_win32.SetWindowPos(hWnd, 0, x, y, 0, 0, _win32._const._SWP_NOZORDER | _win32._const._SWP_NOSIZE) !== 0);
}
function ResizeWindow(hWnd, Width, Height, RTL) {
_debug.getfuncname(arguments);
if (typeof Width === TYPE_UNDEFINED) Width = -1;
if (typeof Height === TYPE_UNDEFINED) Height = -1;
if (typeof RTL === TYPE_UNDEFINED) RTL = _lang.IsRtl;
var RECT = Interop.Allocate(16);
if (_win32.GetWindowRect(hWnd, RECT) !== 0) {
if (RTL) {
var Right = RECT.ReadDWORD(8);
var Top = RECT.ReadDWORD(4);
}
if (Width === -1) var curWidth = RECT.ReadDWORD(8) - RECT.ReadDWORD(0);
if (Height === -1) var curHeight = RECT.ReadDWORD(12) - RECT.ReadDWORD(4);
RECT.Size = 0;
} else {
RECT.Size = 0;
return false;
}
Width = (Width === -1) ? curWidth : 1*Width;
Height = (Height === -1) ? curHeight : 1*Height;
var x = 0, y = 0;
var Flags = _win32._const._SWP_NOZORDER | _win32._const._SWP_NOMOVE;
if (RTL) {
x = Right - Width;
y = Top;
Flags = Flags &~ (_win32._const._SWP_NOMOVE);
}
return(_win32.SetWindowPos(hWnd, 0, x, y, Width, Height, Flags) !== 0);
}
function CreateUpDownControl(hWndBuddy, Range) {
_debug.getfuncname(arguments);
if (typeof Range !== TYPE_OBJECT) Range =[0, 100];
var ExtStyle = _lang.IsRtl ? /*WS_EX_LAYOUTRTL*/ 0x400000 : 0;
var Style = /*WS_CHILD*/ 0x40000000 | /*WS_VISIBLE*/ 0x10000000 | /*UDS_ALIGNRIGHT*/ 0x4 | /*UDS_ARROWKEYS*/ 0x20 | /*UDS_NOTHOUSANDS*/ 0x80 | /*UDS_SETBUDDYINT*/ 0x2;
var hWndParent = _win32.GetParent(hWndBuddy);
var hWndUpDown = _win32.CreateWindowExW(ExtStyle, /*UPDOWN_CLASS*/ 'msctls_updown32', '', Style, 0, 0, 0, 0, hWndParent, 0, _win32.GetCurrentProcess(), 0);
_win32.SendMessageW(hWndUpDown, /*UDM_SETBUDDY*/ 0x400 + 105, hWndBuddy, 0);
_win32.SendMessageW(hWndUpDown, /*UDM_SETRANGE32*/ 0x400 + 111, Range[0], Range[1]);
//Set the spin control's acceleration
var UDACCEL = Interop.Allocate(10*4);
with (UDACCEL) {
//0 secs -> inc 1
WriteDWORD(0*4, 0); //nSec
WriteDWORD(1*4, 1); //nInc
//2 secs -> inc 5
WriteDWORD(2*4, 2); //nSec
WriteDWORD(3*4, 5); //nInc
//4 secs -> inc 20
WriteDWORD(4*4, 4); //nSec
WriteDWORD(5*4, 20); //nInc
//6 secs -> inc 100
WriteDWORD(6*4, 6); //nSec
WriteDWORD(7*4, 100); //nInc
}
_win32.SendMessageW(hWndUpDown, /*UDM_SETACCEL*/ 0x400 + 107, 4, UDACCEL);
UDACCEL.Size = 0;
return hWndUpDown;
}
/*
Name: LoadIcon
Purpose: Loads the window icon
Parameters: None
Return: Handle to the icon loaded.
*/
function LoadIcon() {
_debug.getfuncname(arguments);
return _win32.LoadImageW(_win32.GetCurrentProcess(),
MsgPlus.ScriptFilesPath + '\\Images\\ss5.ico',
1 /* IMAGE_ICON */, 0, 0,
0x10 /* LR_LOADFROMFILE */ | 0x20 /* LR_LOADTRANSPARENT */);
}
/*
Name: SetWndIcon
Purpose: Sets the window icon
Parameters: None
Return: None
*/
function SetWndIcon(hWnd) {
_debug.getfuncname(arguments);
_win32.SendMessageW(hWnd, 0x80 /* WM_SETICON */, 0 /* ICON_SMALL */, hScriptIcon);
_win32.SendMessageW(hWnd, 0x80 /* WM_SETICON */, 1 /* ICON_BIG */, hScriptIcon);
}
/*
Name: CloseChildWindows
Purpose: Close all child windows
Parameters: None
Return: None
*/
function CloseChildWindows() {
_debug.getfuncname(arguments);
for (var objChildWindow in objChildWindows)
CloseWindow(objChildWindow);
}
/*
Name: HideChildWindows
Purpose: Hides all child windows
Parameters: None
Return: None
*/
function HideChildWindows() {
_debug.getfuncname(arguments);
for (var objChildWindow in objChildWindows)
_win32.ShowWindow(objChildWindows[objChildWindow].Handle, 0 /* SW_HIDE */);
}
/*
Name: IsWinVista
Purpose: Checks if the current operating system is Windows Vista
Parameters: None
Return: true if running Windows Vista, false if not.
*/
function IsWinVista() {
_debug.getfuncname(arguments);
return _win32.GetVersion() % 256 === 6;
}