codeboost / bea

Expose your C++ Libraries to Javascript with Google's V8
20 stars 4 forks source link

How can i handle HWND? #6

Closed ayapi closed 10 years ago

ayapi commented 10 years ago

Hi, codeboost, I like bea. Sorry newbie question, I'd like to handle Windows' HWND type. It appears on win32api, like this

HWND GetForegroundWindow()
long GetWindowRect(HWND hwnd, LPRECT lpRect)

So I wrote @type HWND and added template<>, I tried various things with it for 3 days, but it didn't work out :'( I think it's related to void* and v8::External, however I can't find a good way to deal with that... Any good method for this situation?

ayapi commented 10 years ago

Hi! Everything turned out all right in the end ;)

bea

@namespace
    @static Win32api
        HWND GetForegroundWindow()
        long GetWindowRect(HWND hwnd, LPRECT lpRect)
    @type HWND
    @type LPRECT
    @class HWND
        HWND()
    @class RECT
        RECT()
        @accessor left long
            @get _this->left
            @set
        @accessor top long
            @get _this->top
            @set
        @accessor right long
            @get _this->right
            @set
        @accessor bottom long
            @get _this->bottom
            @set

javascript

var win32api = require('win32api-node');
var hwnd = win32api.GetForegroundWindow();
var rect = new win32api.RECT();
win32api.GetWindowRect(hwnd, rect);
console.log(rect);

console

{ bottom: 1359, right: 2111, top: 416, left: 1354 }

I'm so glad! It was trivial matters, sorry for bringing issue up.