-
Content Count
120 -
Joined
-
Last visited
Everything posted by luebbe
-
Is anybody but me using monitors with different scaling?
luebbe replied to dummzeuch's topic in GExperts
not 4K, but two monitors with different resolutions HD and WQHD. Setting one of them to a scaling >100% screws up a lot of things in and around the IDE. -
Generics compiler Error "Incompatible Types"
luebbe posted a topic in Algorithms, Data Structures and Class Design
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. -
@Lajos Juhász Did you notice that the link that you posted actually goes through facebook?
-
Generics compiler Error "Incompatible Types"
luebbe replied to luebbe's topic in Algorithms, Data Structures and Class Design
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 😉 -
Generics compiler Error "Incompatible Types"
luebbe replied to luebbe's topic in Algorithms, Data Structures and Class Design
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? Project4.zip -
Generics compiler Error "Incompatible Types"
luebbe replied to luebbe's topic in Algorithms, Data Structures and Class Design
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 🙂 -
Generics compiler Error "Incompatible Types"
luebbe replied to luebbe's topic in Algorithms, Data Structures and Class Design
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. -
Generics compiler Error "Incompatible Types"
luebbe replied to luebbe's topic in Algorithms, Data Structures and Class Design
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; -
Generics compiler Error "Incompatible Types"
luebbe replied to luebbe's topic in Algorithms, Data Structures and Class Design
Thanks Lars, once again this is proof, that T(ea) makes you happy... -
Image32 - 2D graphics library (open source freeware)
luebbe replied to angusj's topic in I made this
I started my open source life on SF and contributed quite a lot to TortoiseSVN there.- 42 replies
-
- graphics
- cross-platform
-
(and 2 more)
Tagged with:
-
Image32 - 2D graphics library (open source freeware)
luebbe replied to angusj's topic in I made this
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.- 42 replies
-
- graphics
- cross-platform
-
(and 2 more)
Tagged with:
-
Image32 - 2D graphics library (open source freeware)
luebbe replied to angusj's topic in I made this
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. See: https://github.com/EtheaDev/SVGIconImageList- 42 replies
-
- graphics
- cross-platform
-
(and 2 more)
Tagged with:
-
Delphi Daily WTF / Antipattern / Stupid code thread
luebbe replied to Tommi Prami's topic in RTL and Delphi Object Pascal
for I := low to high do; begin ... end; falls into the same category. -
For loop does NOT go to the max
luebbe replied to Joe Sansalone's topic in Algorithms, Data Structures and Class Design
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. -
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
- 14 replies
-
- vcl styles
- drawing
-
(and 1 more)
Tagged with:
-
Lucky you 😉 10.4.2 + all patches (work laptop) 10.4.1 + all patches (work desktop) 10.3.x community edition (home)
- 14 replies
-
- vcl styles
- drawing
-
(and 1 more)
Tagged with:
-
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.
- 14 replies
-
- vcl styles
- drawing
-
(and 1 more)
Tagged with:
-
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.
- 14 replies
-
- vcl styles
- drawing
-
(and 1 more)
Tagged with:
-
I was half fearing @lars' answer :) Thanks to @dwrbudr for confirming it. This is my monitor setup with (1) being the laptop monitor as secondary screen and (2) the desktop monitor as primary screen.
- 14 replies
-
- vcl styles
- drawing
-
(and 1 more)
Tagged with:
-
Good morning Lars, Thank you. Here it is. Maximized.zip
- 14 replies
-
- vcl styles
- drawing
-
(and 1 more)
Tagged with:
-
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?
- 14 replies
-
- vcl styles
- drawing
-
(and 1 more)
Tagged with:
-
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
-
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 :)
-
Wasn't there also a series of aprintf which allocates the memory before doing the printf stuff? ;)
-
What is the best way to precisely time/trigger threaded events
luebbe replied to Yaron's topic in Windows API
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.