What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Button_SetCheckState

Button_SetCheckState
Author: Message:
enoid
New Member
*


Posts: 6
Joined: May 2011
O.P. Button_SetCheckState
I'm having a problem with the rewriting of my script. I'm trying to implement as much as possible into my DLL and so far everything works without a problem. There's only one thing that doesn't seem to work, period. I'm talking about Button_SetCheckState.

The Checkbox we're talking about...
xml code:
<Control xsi:type="CheckBoxControl" Id="ChkTest">
    <Position Top="90" Width="300" Left="20"/>
    <Caption>Try to enable me...</Caption>
</Control>
...and how we set it @ enabled in JScript:
jscript code:
var Wnd = MsgPlus.CreateWnd("Preferences.xml","FormConfig");

Wnd.SetControlText("LblTestString", "It worked!");        // It works!

Wnd.Button_SetCheckState("ChkTest", true);            // It works too!

Everythings works. Now try to implement it in C++:
c++ code:
IDispatchPtr dispPlusWnd = pMsgPlus->CreateWnd("Preferences.xml", "FormConfig");
_IMPPlusWndPtr pPlusWnd;
acquireInterfacePtr(dispPlusWnd, pPlusWnd);

pPlusWnd->SetControlText("LblTestString", "It worked!");        // It works!

pPlusWnd->Button_SetCheckState("ChkTest", true);            // It does NOT work :(
It does NOT work :(
The strange thing is, SetControlText works (just a simple StaticControl for testing purposes), so one would asume that Button_SetCheckState should work aswell (and yes, I've tried switching them around). I've been trying loads of things, using the VARIANT_BOOLs instead of the normal true/false, trying to use the 'raw' version, trying to get the value with Button_IsChecked too see if it was changed but not visible, checking if the WindowId is correct, and too much other things too write down here...

Anyone got an idea what it could be, because it has been driving me insane for the last two days :@
05-26-2011 11:28 PM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Button_SetCheckState
Try passing 1 or 0 instead of true/false.
05-27-2011 01:38 AM
Profile E-Mail PM Find Quote Report
enoid
New Member
*


Posts: 6
Joined: May 2011
O.P. RE: RE: Button_SetCheckState
quote:
Originally posted by matty
Try passing 1 or 0 instead of true/false.
Same thing.

To be sure I'm not screwing it up elsewhere in my code, I just took the example code from Mnjul and only added the code it's all about. See the attachment.

See 'PlusScriptDLLExample.cpp' for the code and (if needed) change the import to build.

.rar File Attachment: Testsource.rar (10.14 KB)
This file has been downloaded 180 time(s).
05-27-2011 07:50 AM
Profile PM Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
RE: Button_SetCheckState
Changing it to use VARIANT_BOOL seems to work fine for me.

c++ code:
pPlusWnd->Button_SetCheckState("ChkTest", VARIANT_TRUE);
05-27-2011 08:06 AM
Profile PM Find Quote Report
enoid
New Member
*


Posts: 6
Joined: May 2011
O.P. RE: RE: Button_SetCheckState
quote:
Originally posted by Eljay
Changing it to use VARIANT_BOOL seems to work fine for me.

c++ code:
pPlusWnd->Button_SetCheckState("ChkTest", VARIANT_TRUE);

Yes it does,.. Thanks! I could have sworn I tried that in my original code too (I even mention it in my opening post...)
Now I feel like an idiot :(

This post was edited on 05-27-2011 at 08:34 AM by enoid.
05-27-2011 08:33 AM
Profile PM Find Quote Report
Mnjul
forum super mod
******

Avatar
plz wub me

Posts: 5396
Reputation: 58
– / Other / Flag
Joined: Nov 2002
Status: Away
RE: Button_SetCheckState
Good to know you got it solved :p 'cos I am pretty sure it should work...at least when I wrote the tutorial it worked. (It was Plus! 4 when I wrote the tutorial, and I didn't check if Plus! 5 broke things...so I was a little bit worried when I saw your post earlier today).

Anyway, to keep things a little bit more "geeky": while VARIANT_FALSE is usually defined 0, VARIANT_TRUE is usually defined as -1 (and it's a short -1, which is 0xffff), not 1. "true" in C++ usually translates into a positive 1 with common compiler implementation (of course, anything could work), FYI.

This post was edited on 05-27-2011 at 09:05 AM by Mnjul.
05-27-2011 08:47 AM
Profile PM Web Find Quote Report
enoid
New Member
*


Posts: 6
Joined: May 2011
O.P. RE: RE: Button_SetCheckState
quote:
Originally posted by Mnjul
Anyway, to keep things a little bit more "geeky": while VARIANT_FALSE is usually defined 0, VARIANT_TRUE is usually defined as -1 (and it's a short -1, which is 0xffff), not 1. "true" in C++ usually translates into a positive 1 with common compiler implementation (of course, anything could work), FYI.
Thanks for clearing that up. I just looked at some of my revisions and I saw that I never tried VARIANT_TRUE itself. I tried to cast a bool or int to a VARIANT_BOOL, assuming it would work. After your explanation now trying it with -1 it magically works. Ahh well, ternary operations to the resque.

Also, thanks for your tutorial, it motivated and helped me to get started on the project I'm currently working on and it sure helped me a lot!
05-27-2011 11:31 AM
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