Jump to content

Ondrej Kelle

Members
  • Content Count

    28
  • Joined

  • Last visited

  • Days Won

    1

Ondrej Kelle last won the day on January 21

Ondrej Kelle had the most liked content!

Community Reputation

23 Excellent

Recent Profile Visitors

113 profile views
  1. Ondrej Kelle

    Version Control System

    People have actually asked for blame as a feature, that's why I included it back then in delphisvn (before it became Version Insight). I find it useful myself to see who committed which lines and also when. This piece of metadata can be useful when trying to understand a code base and its evolution.
  2. Ondrej Kelle

    How to get position of Top-level TMenuItem of Main menu

    Just a thought... Sounds like the units in your uses clause are listed in a different order so the type declarations resolve differently.
  3. Ondrej Kelle

    How to get position of Top-level TMenuItem of Main menu

    Sorry, I've been vague. Here's the full code which works in Delphi XE, I hope it helps: GetWindowMenuItemRect example Cheers!
  4. Ondrej Kelle

    Measure Process Time

    On Windows, there's GetProcessTimes API if that's what you want...
  5. Ondrej Kelle

    How to get position of Top-level TMenuItem of Main menu

    I've checked it with Delphi XE. The declaration of TMenuBarInfo in Windows unit seems to be wrong (packed record, 29 bytes). Simply redeclare it in your unit: type {$A8} // default quadword-alignment PMenuBarInfo = ^TMenuBarInfo; tagMENUBARINFO = record cbSize: DWORD; rcBar: TRect; hMenu: HMENU; hwndMenu: HWND; { fBarFocused:1: BOOL;} { bar, popup has the focus } { fFocused:1: BOOL; } { item has the focus } FocusedBits: BYTE; end; TMenuBarInfo = tagMENUBARINFO; function GetMenuBarInfo(hend: HWND; idObject, idItem: Longint; var pmbi: TMenuBarInfo): BOOL; stdcall; external user32 name 'GetMenuBarInfo'; which makes the record size 32 bytes, then it works: BTW, it's already fixed in Rio.
  6. Ondrej Kelle

    How to get position of Top-level TMenuItem of Main menu

    Your fix looks fine to me. Apart from the var parameter declaration the rest should be the same. Pass it the form's Handle (like in my example, I'm passing it Self.Handle where Self is the instance of the form). Good luck with the Dentist! 😉
  7. Ondrej Kelle

    Node modules with Delphi and Free Pascal

    ...just came across this visualisation. 🙂
  8. Ondrej Kelle

    How to get position of Top-level TMenuItem of Main menu

    GetMenuBarInfo API should help. I have no Delphi at hand at the moment but the following quick test works in Lazarus: function GetWindowMenuItemRect(Handle: THandle; Index: Integer): TRect; var Info: MENUBARINFO; begin FillChar(Info, SizeOf(Info), 0); Info.cbSize := SizeOf(Info); Win32Check(GetMenuBarInfo(Handle, $FFFFFFFD, Index, @Info)); Result := Info.rcBar; end; function GetScreenCanvas: TCanvas; begin Result := TCanvas.Create; try Result.Handle := GetDC(0); Result.Pen.Style := psSolid; Result.Pen.Color := clRed; Result.Brush.Style := bsClear; except Result.Free; raise; end; end; procedure TForm1.Button1Click(Sender: TObject); var C: TCanvas; I: Integer; begin C := GetScreenCanvas; try for I := 0 to MainMenu1.Items.Count - 1 do C.Rectangle(GetWindowMenuItemRect(Handle, I + 1)); finally C.Free; end; end;
  9. Ondrej Kelle

    Node modules with Delphi and Free Pascal

    There's a lot implemented natively: C:\>node --version v11.0.0 C:\>node > require('module').builtinModules [ 'async_hooks', 'assert', 'buffer', 'child_process', 'console', 'constants', 'crypto', 'cluster', 'dgram', 'dns', 'domain', 'events', 'fs', 'http', 'http2', '_http_agent', '_http_client', '_http_common', '_http_incoming', '_http_outgoing', '_http_server', 'https', 'inspector', 'module', 'net', 'os', 'path', 'perf_hooks', 'process', 'punycode', 'querystring', 'readline', 'repl', 'stream', '_stream_readable', '_stream_writable', '_stream_duplex', '_stream_transform', '_stream_passthrough', '_stream_wrap', 'string_decoder', 'sys', 'timers', 'tls', '_tls_common', '_tls_wrap', 'trace_events', 'tty', 'url', 'util', 'v8', 'vm', 'zlib', 'v8/tools/splaytree', 'v8/tools/codemap', 'v8/tools/consarray', 'v8/tools/csvparser', 'v8/tools/profile', 'v8/tools/profile_view', 'v8/tools/logreader', 'v8/tools/arguments', 'v8/tools/tickprocessor', 'v8/tools/SourceMap', 'v8/tools/tickprocessor-driver', 'node-inspect/lib/_inspect', 'node-inspect/lib/internal/inspect_client', 'node-inspect/lib/internal/inspect_repl' ] > I believe (most of) those things are compiled and linked directly into Node executable as native code. I'm not sure. It does seem like a lot of work.
  10. Ondrej Kelle

    Node modules with Delphi and Free Pascal

    ChakraCore is a Javascript (and WebAssembly) engine, comparable to Google's V8, Mozilla's SpiderMonkey or other similar implementations. Node.js is much more - a runtime host environment (native executable for the target platform) embedding V8, it implements some (native code) services and exposes them to the engine through an API. For example, you can instantiate a simple web server from Javascript run by Node as described here. There's also Node.js on ChakraCore, a fork of Node, using ChakraCore instead of V8 (by providing a V8 API shim layer and delegating to the ChakraCore engine). Node comes with a huge online ecosystem of Javascript modules and a package manager (npm) to manage the dependencies. Node modules can reuse other modules through an established ("require") method - you could think of it as Node's runtime equivalent of Delphi's "uses" clause in Javascript. My example shows a way to implement this "require" mechanism in a Delphi or Free Pascal host application, reading npm's "package.json" files where the module metadata is declared and resolving the "require" clauses to full-path file names so they can be loaded and evaluated at runtime with ChakraCore. It doesn't provide any of Node's extra services, so modules relying on them won't work. For example, an attempt to call require('http'); from a script will raise an exception since my host application doesn't provide the "http" module and the implementation of its API (which could be done with some extra work, e.g. using Indy). A hint on how one might provide those services to the engine can be found in the NodeProcess unit which is an incomplete stub implementation of the 'process' module (I just wanted to satisfy graphql for the demo).
  11. https://tondrej.blogspot.com/2019/01/node-modules-with-delphi-and-free-pascal.html chakracore-delphi now comes with NodeSample, a new sample console application showing (as of now very limited) support for Node modules. Included are: - commonmark - graphql - json-query - lodash - moment The sample only shows how Node modules can be resolved and used in Delphi and Free Pascal applications. It doesn't implement Node's event loop or any of its internal modules or native bindings like path, fs or http; any scripts referencing them will - for now - raise an exception. Screencast (YouTube)
  12. Ondrej Kelle

    WebAssembly with Delphi and ChakraCore

    Thanks, I'm glad you like it. Of course, what the move to Chromium really means in practice remains to be seen. For now, ChakraCore still seems to be active, with bug fixes and new features, too. Quoting from their statement: As far as I know, ChakraCore is used in: Node-ChakraCore (e.g. also on Windows 10 IoT Core) Azure DocumentDb (not sure about CosmosDb) Outlook.com Cortana Minecraft scripting API Sphere game engine Reference FHIR server
  13. https://tondrej.blogspot.com/2019/01/webassembly-with-delphi-and-chakracore.html chakracore-delphi now contains WasmSample, a new sample project using ChakraCore to load and run a WebAssembly module (in this case, an implementation of Conway's Game of Life). It's based on Colin Eberhardt's blog post Writing WebAssembly By Hand (you can run the code in your browser here).
  14. Ondrej Kelle

    Scaled windows behave differently

    According to https://quality.embarcadero.com/secure/Dashboard.jspa you can "create an EDN account or recover your login credentials" at https://members.embarcadero.com/newuser.aspx
×