| Colour window | 
| Author: | Message: | 
| markee Veteran Member
 
      
 
  
 Posts: 1622
 Reputation: 50
 37 /
  /  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. | 
 | 
| 07-30-2006 11:41 PM |  | 
|  | 
| matty Scripting Guru
 
      
 
 Posts: 8327
 Reputation: 109
 40 /
  /  Joined: Dec 2002
 Status: Away
 
 | | RE: Colour window Do you mean this one? ![[Image: attachment.php?pid=705287]](http://shoutbox.menthix.net/attachment.php?pid=705287)
  Attachment: pickcolour.png (9.32 KB) This file has been downloaded 529 time(s).
 
 | 
 | 
| 07-31-2006 12:13 AM |  | 
|  | 
| deAd Scripting Contest Winner
 
      
 
  
 Posts: 1060
 Reputation: 28
 – /
  /  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 |  | 
|  | 
| matty Scripting Guru
 
      
 
 Posts: 8327
 Reputation: 109
 40 /
  /  Joined: Dec 2002
 Status: Away
 
 |  | 
| 07-31-2006 02:48 AM |  | 
|  | 
| markee Veteran Member
 
      
 
  
 Posts: 1622
 Reputation: 50
 37 /
  /  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. | 
 | 
| 07-31-2006 06:44 AM |  | 
|  | 
| Eljay Elite Member
 
      
 
  :O
 
 Posts: 2945
 Reputation: 77
 – /
  / – Joined: May 2004
 
 | | RE: Colour window code:MSDN: CHOOSECOLOR struct documentation//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);
 }
 
  for more information.This post was edited on 07-31-2006 at 09:09 AM by Eljay.
 | 
 | 
| 07-31-2006 09:04 AM |  | 
|  | 
| markee Veteran Member
 
      
 
  
 Posts: 1622
 Reputation: 50
 37 /
  /  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   | 
 | 
| 07-31-2006 09:59 AM |  | 
|  | 
| Jimbo Veteran Member
 
      
 
  
 Posts: 1649
 Reputation: 18
 33 /
  /  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  
  Attachment: Colour window.plsc (1.86 KB) This file has been downloaded 298 time(s).
 
 This post was edited on 07-31-2006 at 12:54 PM by Jimbo.
 | 
 | 
| 07-31-2006 12:48 PM |  | 
|  | 
| RaceProUK Elite Member
 
      
 
  
 Posts: 6070
 Reputation: 57
 40 /
  /  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. | 
 | 
| 07-31-2006 12:57 PM |  | 
|  | 
|  |