The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,313 other followers

Archive for the ‘Delphi XE7’ Category

Getting rid of [dcc32 Warning] W1029 Duplicate constructor ‘ClassName.ConstructorName’ with identical parameters will be inacessible from C++

Posted by jpluimers on 2017/11/30

Note that the below solution works for any project raising the W1029 warning (not just from projects using Delphi Mocks) like

[dcc32 Warning] W1029 Duplicate constructor 'ClassName.ConstructorName' with identical parameters will be inacessible from C++

From my original text at [WayBackGet rid of W1029 warning in Delphi compile mode · Issue #106 · VSoftTechnologies/Delphi-Mocks · GitHub:

By default the compiler will emit warnings like these for projects when using either of the Delphi.Mocks.Behavior or Delphi.Mocks.Expectation directly or indirectly:

[dcc32 Warning] W1029 Duplicate constructor ‘TExpectation.CreateOnceWhen’ with identical parameters will be inacessible from C++

They’re harmless as DUnitX doesn’t support C++. This particular warning type cannot be disabled on the unit or source line level which means you have to disable it on the project level by either:

  1. adding {$WARN DUPLICATE_CTOR_DTOR OFF} anywhere to your .dpr project file
  2. modifying the the Project Options for your project (easiest is in the All configurations - All platforms target):
    1. follow the path Delphi Compiler, Hints and Warnings in the treeview on the left
    2. expand the Output warnings node in the listview on the right
    3. set Duplicate constructor/destructor with identical parameters will be inacessible from C++ to Error

A screenshot of the second option is below.

Note that the spelling mistake in Duplicate constructor/destructor with identical parameters will be inacessible from C++ is how it is in the IDE, but that as Google search string it will give limited results, so here are some back-ground references:

 

Screenshot of the Project Options

Read the rest of this entry »

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | Leave a Comment »

delphi – VCL events with anonymous methods – what do you think about this implementation? – Stack Overflow

Posted by jpluimers on 2017/10/19

A long time ago, Pablo Vizcay a.k.a. [WayBackpragmatic_programmer wrote some cool code at [WayBackdelphi – VCL events with anonymous methods – what do you think about this implementation? – Stack Overflow.

I still think it’s a very neat solution to bind method references to events.

type
  TNotifyEventDispatcher = class(TComponent)
  protected
    FClosure: TProc<TObject>;

    procedure OnNotifyEvent(Sender: TObject);
  public
    class function Create(Owner: TComponent; Closure: TProc<TObject>): TNotifyEvent; overload;

    function Attach(Closure: TProc<TObject>): TNotifyEvent;
  end;

implementation

class function TNotifyEventDispatcher.Create(Owner: TComponent; Closure: TProc<TObject>): TNotifyEvent;
begin
  Result := TNotifyEventDispatcher.Create(Owner).Attach(Closure)
end;

function TNotifyEventDispatcher.Attach(Closure: TProc<TObject>): TNotifyEvent;
begin
  FClosure := Closure;
  Result := Self.OnNotifyEvent
end;

procedure TNotifyEventDispatcher.OnNotifyEvent(Sender: TObject);
begin
  if Assigned(FClosure) then
    FClosure(Sender)
end;

end.

And this is how it’s used for example:

procedure TForm1.FormCreate(Sender: TObject);
begin    
  Button1.OnClick := TNotifyEventDispatcher.Create(Self,
    procedure (Sender: TObject)
    begin
      Self.Caption := 'DONE!'
    end)
end;

–jeroen

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | 1 Comment »

ThreadBarrier/ThreadBarrier.pas at master · lordcrc/ThreadBarrier

Posted by jpluimers on 2017/10/12

I mentioned Asbjørn Heid on wiert.me before. While prepping for the Deadlock Empire workshop at EKON20, I needed a Delphi equivalent for the .NET [Way: Barrier Class (System.Threading)

The game uses that in level deadlockempire.github.io/#H4-Barrier [WayBack].

Edwin van der Kraan found the ThreadBarrier/ThreadBarrier.pas at master · lordcrc/ThreadBarrier implementation via [WayBack] Is there a way to create memory barriers in Delphi? Something like .NET’s System.Threading.Barrier class, java.util.concurrent.CyclicBarrier… – Horácio Filho – Google+

It’s from Asbjoørn who is known as lordcrc on GitHub. Cool stuff!

So yes, there is a Delphi version of If you thought you could do multi-threading, then play “The Deadlock Empire” games. You can find it at https://deadlockempire.4delphi.com/ There are two deadlockempire implementations there:

The workshop was great fun!

This is about a web game focussing on the concurrency issues in multi-threading environments. By the conference there will be a Delphi version of it. At the workshop we will play each round interactively: all attendees play the round followed by a short discussion. This is about collective learning, so the speakers will probably learn… Read More

Source: [Archive.isIf you thought you could do multi-threading, then play “The Deadlock Empire” games – Entwickler Konferenz

–jeroen

Posted in .NET, C#, Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | 1 Comment »

`Inc(I)` versus `I := I + 1;` in Delphi – they’re the same, but not atomic per se.

Posted by jpluimers on 2017/10/10

Given a variable I: Integer, some people like Inc(I); others like I := I + 1;.

You might think that part of that discussion nowadays should be multithreading.

In practice this does not matter: the compiler will use the same instructions for both statements.

TL;DR: This might make you think they are always atomic. But that’s not always true, as the below differences show. In addition, it can also depend on your processor archicture.

In the Win32 Delphi Compiler, this is how they look:

Read the rest of this entry »

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | 4 Comments »

Delphi TGridPanel – how to get all SizeStyle=ssPercent cells to get the same auto-calculated Value – via StackOverflow

Posted by jpluimers on 2017/08/31

If you want to set all columns to the same value, select all columns in the structure view and then (assuming SizeStyle [WayBack] is already set to ssPercent [WayBack]) set the Value [WayBack] to 0. This will trigger some automatism that makes all of the columns sized equal.

Great answer by Uwe Raabe [WayBack]

Source: Delphi How to use TGridPanel – Stack Overflow [WayBack]

–jeroen

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | Leave a Comment »

 
%d bloggers like this: