Jump to content

Ondrej Kelle

Members
  • Content Count

    83
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Ondrej Kelle

  1. 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.
  2. 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! 😉
  3. 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)
  4. Ondrej Kelle

    Node modules with Delphi and Free Pascal

    ...just came across this visualisation. 🙂
  5. 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;
  6. 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.
  7. 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).
  8. 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).
  9. 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
  10. 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
  11. Ondrej Kelle

    How to check if parent menu item has "checked" child item?

    I meant 10.3 Rio, sorry. 🙂
  12. Ondrej Kelle

    How to check if parent menu item has "checked" child item?

    The following function HasCheckedSubItems(AMenuItem: TMenuItem): Boolean; var I: integer; begin Result := False; for I := 0 to AMenuItem.Count - 1 do if AMenuItem.Items[I].Checked then begin Result := True; Exit; end; end; produces no warnings, no hints for me with 10.3 Tokyo.
  13. Ondrej Kelle

    Forward declarations

    The scope of a forward declaration is the type declaration section (typically the unit, or the enclosing type declaration section of a nested class). If the classes directly reference each other you'll have to put them in the same declaration section (unit or enclosing type). There are workarounds, depending on what you need. For example, you could reference a generic ancestor (e.g. TTestBase, or even TObject) in the interface section, and typecast to the actual class in implementation, or use polymorphism. Circular unit references in the implementation section are allowed.
  14. Ondrej Kelle

    Feature request: "Show in Explorer"

    Sure. Also, enclose the path in quotes if it contains spaces.
  15. Ondrej Kelle

    Strange Behaviour of FillChar for Non Byte Array Arrays.

    FillChar expects a byte value as the last paramater. You're filling a memory block with byte value 4 and your results show it (67372036 decimal is $04040404).
  16. Ondrej Kelle

    Feature request: "Show in Explorer"

    FWIW, as a workaround I use external tool setting (to launch explorer to show the current editor file).
  17. Ondrej Kelle

    Is there an SVN client wrapper/library fro Delphi.

    Your memories might have been about delphisvn (now outdated and abandoned). "RAD Studio Version Insight" and "RAD Studio Version Insight Plus" developed further, try searching for a recent/maintained fork.
  18. The info is stored in .dct files: https://stackoverflow.com/questions/38672329/how-to-restore-or-copy-component-templates
  19. I've just pushed some updates to chakracore-delphi. A new feature worth mentioning is support for inheritance (I mean Javascript-style, "prototypical inheritance") in both directions. Suppose the following hierarchy: https://tondrej.blogspot.com/2018/11/inheritance-with-chakracore-delphi.html
  20. Ondrej Kelle

    ImageName vs. ImageIndex

    Great idea!
×