What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » WriteDWORD - sending hex value from 3 decimal values

WriteDWORD - sending hex value from 3 decimal values
Author: Message:
MeEtc
Patchou's look-alike
*****

Avatar
In the Shadow Gallery once again

Posts: 2200
Reputation: 60
38 / Male / Flag
Joined: Nov 2004
Status: Away
O.P. WriteDWORD - sending hex value from 3 decimal values
code:
CHOOSECOLOR.WriteDWORD(12, 0x00000000); //COLORREF rgbResult (COLORREF = 0x00bbggrr)

How can I pass RGB colour values in a string to this function?


I swear I'm not making all these posts to get a higher post count, honest!
[Image: signature/]     [Image: sharing.png]
I cannot hear you. There is a banana in my ear.
12-09-2007 09:04 PM
Profile PM Web Find Quote Report
ShawnZ
Veteran Member
*****

Avatar

Posts: 3146
Reputation: 43
32 / Male / Flag
Joined: Jan 2003
RE: WriteDWORD - sending hex value from 3 decimal values
var blue = 0xFF;
var green = 0xFF;
var red = 0xFF;

var color = (blue<<16)+(green<<8)+(red)

i think.

This post was edited on 12-09-2007 at 09:26 PM by ShawnZ.
Spoiler:
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
12-09-2007 09:23 PM
Profile PM Web Find Quote Report
MeEtc
Patchou's look-alike
*****

Avatar
In the Shadow Gallery once again

Posts: 2200
Reputation: 60
38 / Male / Flag
Joined: Nov 2004
Status: Away
O.P. RE: WriteDWORD - sending hex value from 3 decimal values
that doesn't help, if the values are coming from a string, like "#RRGGBB". So I use substr to separate the 3 colour values, but that doesn't turn it into a hex value

EDIT: mynetx provided me a solution
code:
CHOOSECOLOR.WriteDWORD(12, eval('0x00'+b+g+r));

This post was edited on 12-09-2007 at 10:12 PM by MeEtc.
[Image: signature/]     [Image: sharing.png]
I cannot hear you. There is a banana in my ear.
12-09-2007 09:56 PM
Profile PM Web Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: WriteDWORD - sending hex value from 3 decimal values
Noes! You do know that eval() is evil? :O
You can simply use parseInt() on the different parts and choose 16 as base. This way, JScript will convert the string itself from hexadecimal to a decimal number. ;)
code:
var sColor = "#001122";
var r = parseInt(sColor.substr(1, 2), 16);
var g = parseInt(sColor.substr(3, 2), 16);
var b = parseInt(sColor.substr(5, 2), 16);

var color = (b<<16) + (g<<8) + r;

CHOOSECOLOR.WriteDWORD(12, color);

This post was edited on 12-10-2007 at 12:14 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
12-10-2007 11:47 AM
Profile E-Mail PM Web Find Quote Report
Felu
Veteran Member
*****


Posts: 2223
Reputation: 72
30 / Male / Flag
Joined: Apr 2006
Status: Away
RE: WriteDWORD - sending hex value from 3 decimal values
quote:
Originally posted by Mattike
var color = (blue<<16) + (green<<8) + red;
Rather
code:
var color = (b<<16) + (g<<8) + r;

Just saw that both the methods give different results :S.
code:
var color = (b<<16) + (g<<8) + r; // #001122 => 1444608
var color = eval('0x00'+b+g+r); // #001122 => 139536

This post was edited on 12-10-2007 at 11:57 AM by Felu.
12-10-2007 11:52 AM
Profile E-Mail PM Web Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: WriteDWORD - sending hex value from 3 decimal values
Riiiiight!

We'll need a hexadecimal-to-decimal conversion instead of a multiply-by-one! :D
Now fixing post...

This post was edited on 12-10-2007 at 12:14 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
12-10-2007 12:10 PM
Profile E-Mail PM Web 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