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:
OcuS
New Member
*

Avatar


Posts: 11
– / Male / –
Joined: Jul 2006
O.P. [Question] Enable/disable controls
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

This post was edited on 07-07-2006 at 10:00 PM by OcuS.
                                    Another french user
[Image: ocus-banner.gif]
[Bugs found: 1]
07-07-2006 09:58 PM
Profile E-Mail PM Find Quote Report
pollolibredegrasa
Full Member
***

Avatar
formerly fatfreechicken

Posts: 483
Reputation: 34
35 / Male / Flag
Joined: May 2005
RE: [Question] Enable/disable controls
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

This post was edited on 07-07-2006 at 10:13 PM by pollolibredegrasa.
;p

[Image: chickennana.gif] Vaccy is my thin twin! [Image: chickennana.gif]
07-07-2006 10:08 PM
Profile PM Find Quote Report
OcuS
New Member
*

Avatar


Posts: 11
– / Male / –
Joined: Jul 2006
O.P. RE: [Question] Enable/disable controls
Works for me too, thanks. :)

If someone knows an other way, tell.
                                    Another french user
[Image: ocus-banner.gif]
[Bugs found: 1]
07-07-2006 10:17 PM
Profile E-Mail PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: [Question] Enable/disable controls
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.
[Image: spartaafk.png]
07-07-2006 10:20 PM
Profile PM Web Find Quote Report
cooldude_i06
Full Member
***

Avatar
I'm so cool I worry myself.

Posts: 272
Reputation: 9
– / Male / –
Joined: Sep 2003
RE: [Question] Enable/disable controls
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.
[Image: clb2.jpg]
07-07-2006 10:29 PM
Profile E-Mail PM Web Find Quote Report
mathieumg
Full Member
***


Posts: 181
Reputation: 2
34 / Male / Flag
Joined: May 2004
RE: RE: [Question] Enable/disable controls
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()

This post was edited on 07-08-2006 at 05:48 AM by mathieumg.
Official MessengerPlus! Live French Translator
Official StuffPlug 3 French Translator

:)
07-08-2006 05:48 AM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
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 »


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