What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Get information from pointer?

Get information from pointer?
Author: Message:
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: Get information from pointer?
I think this is an example of the kind of thing you want...

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);
    }

You need to use Interop.Allocate and ReadDWORD and so on
<Eljay> "Problems encountered: shit blew up" :zippy:
12-17-2006 04:37 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Get information from pointer? - by deAd on 12-17-2006 at 04:34 PM
RE: Get information from pointer? - by Spunky on 12-17-2006 at 04:37 PM
RE: Get information from pointer? - by deAd on 12-17-2006 at 04:39 PM
RE: Get information from pointer? - by Spunky on 12-17-2006 at 04:46 PM
RE: Get information from pointer? - by -dt- on 12-17-2006 at 04:47 PM
RE: Get information from pointer? - by deAd on 12-17-2006 at 05:02 PM


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