-
Content Count
119 -
Joined
-
Last visited
Posts posted by luebbe
-
-
Thanks Stefan,
in the debugger I saw in ItemCallback(..) that the addresses of FItem and AItem were similar but not equal, so I suspected that there was something wrong with the interface being passed around instead of the object.
I put a breakpoint on the first line of
procedure TestIntfItem.ItemCallback(AItem: IMyIntfItem); begin Assert.IsNotNull(AItem); FCallbackResult := AItem.Caption; end;
with TOnMyIntfItemSelected<T: IMyIntfItem> = procedure(AItem: T) of object; I see:
Name Wert Self (TMyIntfItemA<List.Intf.IMyIntfItem>($3AA2840) as IMyIntfItem, '') AItem Pointer($3AA2828) as IMyIntfItem
This told me that something was wrong, but I couldn't understand what.
with TOnMyIntfItemSelected<T: IMyIntfItem> = procedure(AItem: IMyIntfItem) of object; I see:
Name Wert Self (TMyIntfItemA<List.Intf.IMyIntfItem>($3AC38D8) as IMyIntfItem, '') AItem TMyIntfItemA<List.Intf.IMyIntfItem>($3AC38D8) as IMyIntfItem
That's an evil trap. Thanks for shedding light on it. So if something is wrong I have to watch out for $18 byte address offsets 😉
-
Back from vacation...
Thanks for further feedback, I probably oversimplified the interface in order to produce a minimal example. In fact I do have stuff in the interface. The attached project contains two different implementations, one interface based and one skeleton based, with a few unit tests.
You need TestInsight installed and the path to DUnitX in the $(DUNITX) variable to run it.
I needed a callback for a list item (selection) and for the list itself (changed). The skeleton based implementation works as expected, but the interface based callback for the list item fails with an A/V and I don't understand why. I'm probably still doing something wrong with the generic definition.
Could someone please enlighten me what my mistake is? -
Meanwhile I prefer interfaces over abstract classes. It was the other way round 20 years ago.
Still struggling with the data passed in the callback, but I'll look into it again ten days from now. Finally a bit of vacation 🙂 -
Arggh, same thing again. Thanks again. Hopefully this time it sticks in my brain.
It's not that I'm not working with generics a lot. It's just that I rarely build generics from scratch. -
I think the skeleton is what I'm heading towards.
Next question. How can I implement a callback with the list itself? I tried different variations, but this is as far as I can get.
type IMyIntf = interface; TMyList<T: IMyIntf> = class; TOnListItemSelected = procedure(AItem: IMyIntf) of object; TOnListUpdated = procedure(AList: TMyList<IMyIntf>) of object; IMyIntf = interface ['{FCAFF2E8-5F8E-4473-8795-89BD41C89D57}'] end; TMyList<T: IMyIntf> = class FItems: TList<T>; FOnListUpdated: TOnListUpdated; procedure ListUpdated; end; { TMyList<T> }procedure TMyList<T>.ListUpdated; begin if Assigned(FOnListUpdated) then FOnListUpdated(Self); // E2010 Inkompatible Typen: 'Project4.TMyList<Project4.IMyIntf>' und 'Project4.TMyList<Project4.TMyList<T>.T>' end;
-
Thanks Lars,
once again this is proof, that T(ea) makes you happy...
- 1
-
Hi Folks,
I'm banging my head against the wall trying to understand, why the compiler throws "E2008 Incompatible Types" errors at the marked lines. I must be missing something completely...
program Project4; {$APPTYPE CONSOLE} {$R *.res} uses System.Generics.Collections, System.SysUtils; type IMyIntf = interface ['{FCAFF2E8-5F8E-4473-8795-89BD41C89D57}'] end; TMyList<IMyIntf> = class FItems: TList<IMyIntf>; procedure AddItem(AItem: IMyIntf); function GetItem: IMyIntf; end; TMyType = class end; TMyTypeList<TMyType> = class FItems: TList<TMyType>; procedure AddItem(AItem: TMyType); function GetItem: TMyType; end; { TMyList<IMyIntf> } procedure TMyList<IMyIntf>.AddItem(AItem: IMyIntf); var Value: IMyIntf; begin FItems.Add(AItem); // E2008 Incompatible Types FItems.Add(Value); // Compiler is happy end; function TMyList<IMyIntf>.GetItem: IMyIntf; begin Result := FItems[0]; // E2008 Incompatible Types end; { TMyTypeList<TMyType> } procedure TMyTypeList<TMyType>.AddItem(AItem: TMyType); var Value: TMyType; begin FItems.Add(AItem); // E2008 Incompatible Types FItems.Add(Value); // Compiler is happy end; function TMyTypeList<TMyType>.GetItem: TMyType; begin Result := FItems[0]; // E2008 Incompatible Types end; begin try { TODO -oUser -cConsole Main : Code hier einfügen } except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end.
- 1
-
16 minutes ago, Vincent Parrett said:I see SF is using git now.. that's a plus - but that site hurts my with a bunch of other irrelevant rubbish on each page - won't be signing up (can't remember if I ever did before)
I started my open source life on SF and contributed quite a lot to TortoiseSVN there.
-
9 hours ago, Vincent Parrett said:Pity it's not hosted on Github - would make forking, pull request etc so much easier 😉
He's one of the guys who tries to prevent Sourceforge from dying ;)
Admittedly I forgot my SF password, since I haven't logged in for years.- 1
-
Additional Info: SVGIconImageList has a wrapper for Image32, so Image32 can be used as one of four rendering engines for SVG icons. Since it proved to be the best of the four, @Carlo Barazzetta has made it the default.
- 4
-
3 hours ago, Tommi Prami said:if A > B then; ... if A > B then A := B else;
Semicolon right after the then or else is legal syntax, and can be used rightly, but I think those are possible point of errors and not easy to spot
for I := low to high do; begin ... end;
falls into the same category.
- 1
-
13 minutes ago, Joe Sansalone said:Hi,
I've encountered something weird. Delphi 10.4.2
I loop through the items in a list.
But also may add to that list in the loop.
Thus, extend the loop iterations.
Ouch. Are you sure you want to do this? How are you going to ensure that your loop terminates when you keep adding items inside the loop?
Consider
list.count-1
to be a constant while the loop is executed. This ensures termination.
If you really want to change the list content while iterating over the list, use a while loop and ensure termination yourself. -
Lucky you 😉
10.4.2 + all patches (work laptop)
10.4.1 + all patches (work desktop)
10.3.x community edition (home)
-
Yes, immediately reproducible on my home PC
Screen layout:
Monitor 1: 1920x1080 (24")
Monitor 2: 2560x1440 (27")
When both monitors align at the top, everything is fine.
This is also sufficient.
You have to toggle the app between normal and maximized mode after you change the screen alignment. If you leave the app maximized while changing the screen alignment, everything will stay ok.
-
Sorry for the late reply. It was a very busy week.
Monitor 1: 1920x1080 (??" Laptop screen)
Monitor 2: 2560x1440 (27")
Both set to 100% font scaling
It also happens on my desktop PC at work, which has two 24" monitors with different resolutions
Monitor 1: 2560x1440 (24")
Monitor 2: 1920x1080 (24")
Both set to 100% font scaling
They have a slight vertical offset IIRC (working from home, desktop is in the office)
May be driver antics, but our IT department keeps everything as up-to-date as possible.
I'll compile it with the community edition on my home PC and try what happens there.
-
-
-
I didn't touch anything knowingly in the manifest. Just dropped a menu on the form and activated a VCL style.
The minimal app has "per monitor v2"
Our standard app has "none"
So I guess it doesn't have anything to do with dpi awareness?
-
Hi Folks,
I have a strange bug when a VCL styled application is maximized in a dual monitor configuration.
Steps to reproduce:
1. Set your windows task bar position to "top"
2. Create a minimal application and activate a VCL style (add a main menu if you like)
3. Run the application and:
* maximize it on the primary monitor (fine)
* maximize it on the secondary monitor (The top part of the application, probably the height of the windows task bar, becomes transparent)
left: maximized on primary monitor
right: maximized on secondary monitor
Additional Info:
* My two monitors have different resolutions and they have a vertical offset
* This bug doesn't seem to affect many people (no customer has reported it so far ;-))
* This is not a new bug. I've seen for years (three to four) it in several Delphi versions, but I can't put a date on it
Today I tried to find out if it is a problem with our main form's settings, but since it also happens with a minimal application, it probably isn't.
Has anybody encountered this as well?
Does anyone know how to fix it?
Do I have to wait for Emba to fix it?
Cheers & thanks
Lübbe
-
Thanks for the pointers. In the end I solved it by searching and copy/pasting the code snippets that I needed to compare into a diff tool.
You're right Uwe, but I didn't need working code. I just needed something which is easy to compare :) -
Hi Folks,
I am trying to compare two huge .pas files created by the xml data binding wizard from two different xsd files. Each xsd file represents a different version of the same standard. Now I'd like to spot the differences in the created .pas files. Unfortunately the order in which the classes are created are so different, that I see 99% diffs.
So I thought: MMX Code Explorer has some sort functions. I'll sort the interface and implementation parts of both files alphabetically and compare the result. Up to now I only managed to sort inside classes.
I set the two options in "Default class sorting" to "Unsorted and in "Default Mode procedure sorting" to "Name". Then I tried my luck with "Default sort classes and module" from the MMX window, but it had no visible effect on the sources. I can sort stuff inside the classes by changing the options in "Default class sorting", but that's not what I want.
How can I sort a .pas file alphabetically in the interface by class name and in the implementation section by class name and method name?
MMX version 15.0.38.2440
-
Wasn't there also a series of aprintf which allocates the memory before doing the printf stuff? ;)
-
The grijjy timer queue works fine. I'm using it to draw on screen in regular intervals. You shouldn't allow VCL style changes while drawing, It got me into all kinds of trouble.
-
Oops, sorry, so let's ping @FPiette instead
C++ Code Insight in 10.4.2
in General Help
Posted · Edited by luebbe
@Lajos Juhász Did you notice that the link that you posted actually goes through facebook?