What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Question] Enable/disable controls

[Question] Enable/disable controls
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: RE: [Question] Enable/disable controls
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);

This post was edited on 07-08-2006 at 03:34 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
07-08-2006 03:03 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[Question] Enable/disable controls - by OcuS on 07-07-2006 at 09:58 PM
RE: [Question] Enable/disable controls - by pollolibredegrasa on 07-07-2006 at 10:08 PM
RE: [Question] Enable/disable controls - by OcuS on 07-07-2006 at 10:17 PM
RE: [Question] Enable/disable controls - by RaceProUK on 07-07-2006 at 10:20 PM
RE: RE: [Question] Enable/disable controls - by mathieumg on 07-08-2006 at 05:48 AM
RE: [Question] Enable/disable controls - by cooldude_i06 on 07-07-2006 at 10:29 PM
RE: RE: RE: [Question] Enable/disable controls - by CookieRevised on 07-08-2006 at 03:03 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On