[Question] Enable/disable controls - Printable Version
-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [Question] Enable/disable controls (/showthread.php?tid=62778)
[Question] Enable/disable controls by OcuS on 07-07-2006 at 09:58 PM
Hi,
I'm just not able to find how to enable or disable buttons...
I've tried this, like someone suggested me (more or less) :
code: var WM_ENABLE = 0x000A;
myWindow.SendControlMessage('myButtonControl', WM_ENABLE, 0, 1);
What's wrong with that (finally, it does nothing...) ?
Do I send the good message (0x000A) ?
Do I correctly set the third and fourth parameters ?
What's the fourth parameter for ?
Thank you
RE: [Question] Enable/disable controls by pollolibredegrasa on 07-07-2006 at 10:08 PM
Hi,
I also wondered about this.
At the moment I'm using the following code to enable a button:
code: var btnReplyWnd;
btnReplyWnd = wndResp.GetControlHandle("BtnReply"); //get the buttons handle
Interop.Call("User32","EnableWindow", btnReplyWnd, 1); //enable button
(change the 1 to 0 to disable)
Don't know if this is the correct way of doing it but it seems to work for me
RE: [Question] Enable/disable controls by OcuS on 07-07-2006 at 10:17 PM
Works for me too, thanks.
If someone knows an other way, tell.
RE: [Question] Enable/disable controls by RaceProUK on 07-07-2006 at 10:20 PM
WM_ENABLE is a notification: it's sent by the system after something has happened. It doesn't actually control anything. It also doesn't help you got the third and fourth parameters wrong. The third should be 0 for disabled, nonzero for enabled. The fourth is ignored, and should be 0.
fatfreechicken's code is actually a good workaround. To be honest, Patchou should have included an EnableControl() in the scripting engine: it's a common enough task.
Note: Different window messages have different WPARAM and LPARAM uses. Use MSDN to check for each message.
RE: [Question] Enable/disable controls by cooldude_i06 on 07-07-2006 at 10:29 PM
quote: Originally posted by fatfreechicken
H
At the moment I'm using the following code to enable a button:
code: var btnReplyWnd;
btnReplyWnd = wndResp.GetControlHandle("BtnReply"); //get the buttons handle
Interop.Call("User32","EnableWindow", btnReplyWnd, 1); //enable button
(change the 1 to 0 to disable)
Yes, I use this method as well and it does work on all controls.
RE: RE: [Question] Enable/disable controls by mathieumg on 07-08-2006 at 05:48 AM
quote: Originally posted by RaceProUK
Patchou should have included an EnableControl() in the scripting engine: it's a common enough task.
code: function EnableControl(Control)
{
var ControlHandle = null;
ControlHandle = wndResp.GetControlHandle(Control);
Interop.Call("User32","EnableWindow", ControlHandle, 1);
}
function DisableControl(Control)
{
var ControlHandle = null;
ControlHandle = wndResp.GetControlHandle(Control);
Interop.Call("User32","EnableWindow", ControlHandle, 0);
}
Possibly there is a way to improve it by making ToggleEnableControl()
RE: RE: RE: [Question] Enable/disable controls by CookieRevised on 07-08-2006 at 03:03 PM
quote: Originally posted by mathieumg
Possibly there is a way to improve it by making ToggleEnableControl()
You don't always want to 'toggle' the control. In most cases you want to set the enabled state (after some event or in a certain case).
Anways, you could use something like this:
code: function ControlEnable(pPlusWnd, sControlId, bState) {
// Get handle of the specified control on the specified window
var hCtrl = pPlusWnd.GetControlHandle(sControlId);
// If function is called with a 3rd parameter, set the state of the control
if (arguments.length === 3) Interop.Call("User32", "EnableWindow", hCtrl, bState);
// Return the current state of the control
return Interop.Call("User32", "IsWindowEnabled", hCtrl);
}
Usage:
example 1: Disable control:
ControlEnable(mywindow, "mycontrol", 0);
example 2: Enable control:
ControlEnable(mywindow, "mycontrol", 1);
example 3: Get current state of control:
var TheState = ControlEnable(mywindow, "mycontrol");
---------
Or even (to add the toggle functionality):
code: function ControlEnable(pPlusWnd, sControlId, bState) {
// Get handle of the specified control on the specified window
var hCtrl = pPlusWnd.GetControlHandle(sControlId);
// If function is called with a 3rd parameter, set the state of the control
if (arguments.length === 3) {
// If bState doesn't equal 0 or 1, toggle the state of the control
if (bState != 0 && bState != 1) bState = Interop.Call("User32", "IsWindowEnabled", hCtrl) ^ 1;
Interop.Call("User32", "EnableWindow", hCtrl, bState);
}
// Return the current state of the control
return Interop.Call("User32", "IsWindowEnabled", hCtrl);
}
Additional usage to the above examples:
example 4: Toggle control:
ControlEnable(mywindow, "mycontrol", 2);
|