Shoutbox

Colour window - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Colour window (/showthread.php?tid=64260)

Colour window by markee on 07-30-2006 at 11:41 PM

I was wondering if someone could help me make a window that shows the colour chooser like from the select colour of text button next to the plus menu button in the chat window.  I need it to kind of pop-up like the browse in the background changer script if that is alright.  If anyone could help that would be greatly appreciated, thanks.


RE: Colour window by matty on 07-31-2006 at 12:13 AM

Do you mean this one?

[Image: attachment.php?pid=705287]


RE: Colour window by deAd on 07-31-2006 at 01:52 AM

The only way I think you can do that (what Matty shows) is with the MsComDlg.CommonDialog ActiveXObject, and I believe that's one of the objects that only comes with certain programs (like Visual Studio)...however I may be wrong.


RE: Colour window by matty on 07-31-2006 at 02:48 AM

http://allapi.net/apilist/CHOOSECOLOR.shtml

A bit too lazy to convert it over but have a look.


RE: Colour window by markee on 07-31-2006 at 06:44 AM

Thanks that's exactly what I was after Matty, I'll try to work out what to do but if you can help me with it's implementation that would be awsome (though I do understand you are probably quite busy).  Thanks heap for that much anyway.


RE: Colour window by Eljay on 07-31-2006 at 09:04 AM

code:
//Show color picker common dialog

//Create our CHOOSECOLOR data block
var CHOOSECOLOR = Interop.Allocate(36);
CHOOSECOLOR.WriteDWORD(0, 36); //DWORD lStructSize
CHOOSECOLOR.WriteDWORD(4, 0); //HWND hwndOwner
CHOOSECOLOR.WriteDWORD(8, 0); //HWND hInstance
CHOOSECOLOR.WriteDWORD(12, 0x000000FF); //COLORREF rgbResult (COLORREF = 0x00bbggrr)
var CustColors = Interop.Allocate(64); //Create an array of 16 COLORREFs for CustColors
CHOOSECOLOR.WriteDWORD(16, CustColors.DataPtr); //COLORREF *lpCustColors (pointer to our array)
CHOOSECOLOR.WriteDWORD(20, 3); //DWORD Flags (3 = 2 (CC_FULLOPEN) + 1 (CC_RGBINIT) )
CHOOSECOLOR.WriteDWORD(24, 0); //LPARAM lCustData
CHOOSECOLOR.WriteDWORD(28, 0); //LPCCHOOKPROC lpfnHook
CHOOSECOLOR.WriteDWORD(32, 0); //LPCTSTR lpTemplateName

//Open the dialog box
var result = Interop.Call('comdlg32.dll', 'ChooseColorA', CHOOSECOLOR);
//If the user pressed ok convert it to hex
if(result == 1){
  //Get decimal values
  var r = CHOOSECOLOR.ReadDWORD(12) & 0xFF;
  var g = (CHOOSECOLOR.ReadDWORD(12) / 0x100) & 0xFF;
  var b = (CHOOSECOLOR.ReadDWORD(12) / 0x10000) & 0xFF;
  Debug.Trace('RGB: ' + r + ',' + g + ',' + b)
  //Get hex values
  var hexchars="0123456789ABCDEF";
  var r = hexchars.charAt((r >> 4) & 0xf) + hexchars.charAt(r & 0xF);
  var g = hexchars.charAt((g >> 4) & 0xf) + hexchars.charAt(g & 0xF);
  var b = hexchars.charAt((b >> 4) & 0xf) + hexchars.charAt(b & 0xF);
  Debug.Trace('HEX: ' + r + g + b);
}

MSDN: CHOOSECOLOR struct documentation for more information.
RE: Colour window by markee on 07-31-2006 at 09:59 AM

quote:
Originally posted by eljelly
//Show color picker common dialog

//Create our CHOOSECOLOR data block
var CHOOSECOLOR = Interop.Allocate(36);
CHOOSECOLOR.WriteDWORD(0, 36); //DWORD lStructSize
CHOOSECOLOR.WriteDWORD(4, 0); //HWND hwndOwner
CHOOSECOLOR.WriteDWORD(8, 0); //HWND hInstance
CHOOSECOLOR.WriteDWORD(12, 0x000000FF); //COLORREF rgbResult (COLORREF = 0x00bbggrr)
var CustColors = Interop.Allocate(64); //Create an array of 16 COLORREFs for CustColors
CHOOSECOLOR.WriteDWORD(16, CustColors.DataPtr); //COLORREF *lpCustColors (pointer to our array)
CHOOSECOLOR.WriteDWORD(20, 3); //DWORD Flags (3 = 2 (CC_FULLOPEN) + 1 (CC_RGBINIT) )
CHOOSECOLOR.WriteDWORD(24, 0); //LPARAM lCustData
CHOOSECOLOR.WriteDWORD(28, 0); //LPCCHOOKPROC lpfnHook
CHOOSECOLOR.WriteDWORD(32, 0); //LPCTSTR lpTemplateName

//Open the dialog box
var result = Interop.Call('comdlg32.dll', 'ChooseColorA', CHOOSECOLOR);
//If the user pressed ok convert it to hex
if(result == 1){
  //Get decimal values
  var r = CHOOSECOLOR.ReadDWORD(12) & 0xFF;
  var g = (CHOOSECOLOR.ReadDWORD(12) / 0x100) & 0xFF;
  var b = (CHOOSECOLOR.ReadDWORD(12) / 0x10000) & 0xFF;
  Debug.Trace('RGB: ' + r + ',' + g + ',' + b)
  //Get hex values
  var hexchars="0123456789ABCDEF";
  var r = hexchars.charAt((r >> 4) & 0xf) + hexchars.charAt(r & 0xF);
  var g = hexchars.charAt((g >> 4) & 0xf) + hexchars.charAt(g & 0xF);
  var b = hexchars.charAt((b >> 4) & 0xf) + hexchars.charAt(b & 0xF);
  Debug.Trace('HEX: ' + r + g + b);
}
Thanks heaps for that, it works a treat :)
RE: Colour window by Jimbo on 07-31-2006 at 12:48 PM

For all you lazy people out there i have packaged this script into a *.plsc file so all you have to do is download it and import it.

I did not make this script so i give full credit to eljelly


I think this script is wicked.

Well done eljelly(Y)


RE: Colour window by RaceProUK on 07-31-2006 at 12:57 PM

quote:
Originally posted by deAd
The only way I think you can do that (what Matty shows) is with the MsComDlg.CommonDialog ActiveXObject, and I believe that's one of the objects that only comes with certain programs (like Visual Studio)...however I may be wrong.
A version of COmmon Controls is built into all versions of Windows, and the Scripting Host has full access to it. It's just the headers and lib files that come with Visual Studio, as part of Platform SDK.