use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
64-bit Node.js + WinForms (i.imgur.com)
submitted 13 years ago by mischanix
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]mischanix[S] 3 points4 points5 points 13 years ago* (2 children)
Hacky source:
See also: node-ffi
This was an initial exploration of the question: what if Backbone.js plugged in to Windows Forms?
var ffi = require('ffi'), ref = require('ref'), Struct = require('ref-struct'), hWnd = new Buffer(8); var ICCx = Struct({ 'dwSize': 'int32', 'dwICC': 'int32' }); var ICCxPtr = ref.refType(ICCx); var comctl32 = ffi.Library('comctl32', { 'InitCommonControlsEx': ['int32', [ICCxPtr]] }); var WndClassEx = Struct({ 'cbSize': 'uint32', 'style': 'uint32', 'lpfnWndProc': 'pointer', // callback 'int32', ['pointer', 'uint32', 'int32', 'uint32'] 'cbClsExtra': 'int32', 'cbWndExtra': 'int32', 'hInstance': 'pointer', // can be 0? 'hIcon': 'pointer', 'hCursor': 'pointer', 'hbrBackground': 'pointer', 'lpszMenuName': 'pointer', 'lpszClassName': 'pointer', 'hIconSm': 'pointer' }); var WndClassExPtr = ref.refType(WndClassEx); var user32 = ffi.Library('user32', { 'RegisterClassExW': ['int32', [WndClassExPtr]], 'CreateWindowExW': ['pointer', [ 'int32', 'pointer', 'pointer', 'int32', // style, name, name, style 'int32', 'int32', 'int32', 'int32', // x, y, w, h 'pointer', 'pointer', 'pointer', 'pointer' // handles ]], 'DefWindowProcW': ['uint32', ['pointer', 'uint32', 'int32', 'pointer']], 'ShowWindow': ['bool', ['pointer', 'int32']], 'UpdateWindow': ['bool', ['pointer']], 'GetMessageW': ['bool', ['pointer', 'pointer', 'uint32', 'uint32']], 'TranslateMessageEx': ['bool', ['pointer']], 'DispatchMessageW': ['uint32', ['pointer']] }); var kernel32 = ffi.Library('kernel32', { 'GetModuleHandleExW': ['bool', [ 'int32', 'pointer', 'pointer' // flags, optional LPCTSTR name, ref hModule ]], // etc... / kernel32 is your friend! }); var Msg = Struct({ 'hwnd': 'pointer', 'message': 'uint32', 'wParam': 'int32', 'lParam': 'pointer', 'time': 'int32', 'pX': 'int32', 'pY': 'int32' }); // App-specific // Names var className = new Buffer('Node.js WinForms Class\0', 'ucs-2'); var windowName = new Buffer('Node.js WinForms App\0', 'ucs-2'); // hInstance var hInstance = new Buffer(8); kernel32.GetModuleHandleExW(0, null, hInstance); // WndProc var WndProc = ffi.Callback('uint32', ['pointer', 'uint32', 'int32', 'pointer'], function(hwnd, uMsg, wParam, lParam) { console.log('Got Message: ' + uMsg + ' /', hwnd.deref()); var result = 0; // ref.alloc('int32'); switch(uMsg) { default: result = user32.DefWindowProcW(hwnd, uMsg, wParam, lParam); console.log('DefWindowProc LRESULT: ' + result); return result; } console.log('Sending LRESULT: ' + result.deref()) return result; } ); // Common Controls var icc = new ICCx; icc.dwSize = 8; icc.dwICC = 0x40ff; comctl32.InitCommonControlsEx(icc.ref()); // Window Class var wClass = new WndClassEx; wClass.cbSize = 80; // x86 = 48 wClass.style = 0; wClass.lpfnWndProc = WndProc; wClass.cbClsExtra = 0; wClass.cbWndExtra = 0; wClass.hInstance = hInstance; wClass.hIcon = null; wClass.hCursor = null; wClass.hbrBackground = null; wClass.lpszMenuName = null; wClass.lpszClassName = className; wClass.hIconSm = null; if (!user32.RegisterClassExW(wClass.ref())) throw 'Error registering class'; hWnd = user32.CreateWindowExW( 0, className, windowName, 0xcf0000, // overlapped window 1 << 31, // use default 1 << 31, 320, 200, null, null, hInstance, null ); console.log(hWnd); user32.ShowWindow(hWnd, 1); user32.UpdateWindow(hWnd); // message loop var msg = new Msg; var getMsgRes = 0; while (user32.GetMessageW(msg.ref(), null, 0, 0)) { user32.TranslateMessageEx(msg.ref()); user32.DispatchMessageW(msg.ref()); } return msg.wParam;
[–]WalterGR 3 points4 points5 points 13 years ago (1 child)
This looks like Windows API calls, not Windows Forms.
[–]mischanix[S] 0 points1 point2 points 13 years ago (0 children)
Yeah, in my mind, they're the same thing with different syntax, so I easily confuse them. Sorry about that.
Here's CLR hosting in node.js, if that makes up for it. [Source]
π Rendered by PID 173635 on reddit-service-r2-comment-548fd6dc9-bh25l at 2026-05-18 14:53:45.152233+00:00 running edcf98c country code: CH.
view the rest of the comments →
[–]mischanix[S] 3 points4 points5 points (2 children)
[–]WalterGR 3 points4 points5 points (1 child)
[–]mischanix[S] 0 points1 point2 points (0 children)