Shoutbox

Get window width... - 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: Get window width... (/showthread.php?tid=63988)

Get window width... by deAd on 07-25-2006 at 07:00 PM

How would I go about getting the width in pixels of a window? I've tried using GetWindowRect but I can't get it right...:(


RE: Get window width... by Eljay on 07-25-2006 at 07:17 PM

code:
var RECT = Interop.Allocate(16);
Interop.Call('User32', 'GetWindowRect', <window handle here>, RECT);
var left = RECT.ReadDWORD(0);
var right = RECT.ReadDWORD(8);
var width = right - left;

RE: Get window width... by deAd on 07-25-2006 at 07:30 PM

Oh...I didn't know which one was the right I guess :P Which ones are the Top/Bottom?


RE: Get window width... by Eljay on 07-25-2006 at 07:33 PM

quote:
typedef struct _RECT {
  LONG left;
  LONG top;
  LONG right;
  LONG bottom;
} RECT, *PRECT;

source: MSDN

so .ReadDWORD(4) = top
and ReadDWORD(12) = bottom
;)
RE: Get window width... by deAd on 07-25-2006 at 07:46 PM

I would've guessed that it went 1,2,3,4 ;) :P (or 0,1,2,3)


RE: Get window width... by matty on 07-25-2006 at 08:13 PM

quote:
Originally posted by deAd
I would've guessed that it went 1,2,3,4 ;) :P (or 0,1,2,3)
Before you can use Datablocs you should understand the amount of memory that needs to be allocated for each variable type.

Too lazy to type it all out so here is what Choli posted in the beta forum.

quote:
Originally posted by Choli
Long: 4
Integer: 2
Byte: 1
String: 4 (you need to create another datablock and in these 4 byte you write the pointer to the datablock)
String * n: 2*n (unicode) (n if ansi, i don't suggest using ansi)
Enum: 4
Boolean: 2
Double: 8
Single: 4
Variant: 16 (i don't think you'll ever use this)

RE: Get window width... by deAd on 07-25-2006 at 09:33 PM

Oh...I've used datablocs before but I've never seen this. Thanks (y)