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

Colour window
Author: Message:
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
35 / Male / Flag
Joined: Jan 2006
O.P. Colour window
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.
[Image: markee.png]
07-30-2006 11:41 PM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Colour window
Do you mean this one?

[Image: attachment.php?pid=705287]

.png File Attachment: pickcolour.png (9.32 KB)
This file has been downloaded 451 time(s).
07-31-2006 12:13 AM
Profile E-Mail PM Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: Colour window
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.
07-31-2006 01:52 AM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Colour window
http://allapi.net/apilist/CHOOSECOLOR.shtml

A bit too lazy to convert it over but have a look.
07-31-2006 02:48 AM
Profile E-Mail PM Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
35 / Male / Flag
Joined: Jan 2006
O.P. RE: Colour window
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.
[Image: markee.png]
07-31-2006 06:44 AM
Profile PM Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
RE: Colour window
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.

This post was edited on 07-31-2006 at 09:09 AM by Eljay.
07-31-2006 09:04 AM
Profile PM Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
35 / Male / Flag
Joined: Jan 2006
O.P. RE: Colour window
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 :)
[Image: markee.png]
07-31-2006 09:59 AM
Profile PM Find Quote Report
Jimbo
Veteran Member
*****

Avatar

Posts: 1650
Reputation: 18
31 / Male / Flag
Joined: Jul 2006
RE: Colour window
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)


.plsc File Attachment: Colour window.plsc (1.86 KB)
This file has been downloaded 225 time(s).

This post was edited on 07-31-2006 at 12:54 PM by Jimbo.
07-31-2006 12:48 PM
Profile E-Mail PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Colour window
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.
[Image: spartaafk.png]
07-31-2006 12:57 PM
Profile 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