Posts: 3146 Reputation: 43
32 / /
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.
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
RE: WriteDWORD - sending hex value from 3 decimal values
Noes! You do know that eval() is evil?
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.