Recent

Recent Posts

Pages: [1] 2 3 ... 10
1
RichMemo / Re: Where is TRichMemoInlinePicture?
« Last post by skalogryz on Today at 02:18:00 am »
But ... where is the code? I am only a simple code monkey but when I write code it does something. This is just a maze. Where is the thing that does the thing?
...
Why can't I find it like the compiler does?
it's not a maze, but an amazing back bone of LCL, known as VMT-hack. It's a very old solution (back from the days when FPC didn't support interfaces), that still works.
And in fact, the compiler doesn't find the proper implementation as well.

What's happening is a run-time construction of an additional virtual class, with a mix of methods from different classes. The mix is driven by the hierarchy you're trying to search through (TWSCustomRichMemoClass -> TWSCustomMemo -> TWSCustomEdit)
However, the actual implementation is being copied over from a selected widgetset.
For Win32, you might want to search TWin32WSCustomRichMemoClass (from richmemo package), TWin32WSCustomMemo (from LCL), TWin32CustomEdit (from LCL).
(one of those should have PasteFromClipboard method)

The VMT for the virtual classes is reconstructed based on the inheritance of TWin32WSxxx classes. (the same thing is explained here)

However, once you find Win32 PasteFromClipboard you might find it pretty boring and uninteresting:
Code: Pascal  [Select][+][-]
  1. imptype procedure TWin32WSCustomEdit.Paste(const ACustomEdit: TCustomEdit);
  2. begin
  3.   SendMessage(ACustomEdit.Handle, WM_PASTE, 0, 0)
  4. end;
  5.  

In other words, all the "fun part" of actually pasting an image into a rich edit is implemented within the system code, and is not available for the review.
2
Video demo of two client applications written in Lazarus syncing a basic "record" custom type using the network subscribed heap memory.

https://youtu.be/sdmfpWPVj8I

Video showing off the source code(a little over half an hour): https://youtu.be/BKq4yUP-9pU
3
Hi. I have modified the JUSSD component to work as an accessibility service which lists package name and all currently active screen content. I used this service together with jWindowManager . After a lot of testing and modifications now everything works perfectly as I imagined. Only one detail is missing: I want the application to open the accessibility setting so that I can activate the service on the first run. Thanks in advance.

PS: My intention with this one is to automate tasks. There are many, I know. But nothing like having a custom one. And with LAWM this is possible.
4
General / Re: Unexpected structure size
« Last post by 440bx on Today at 12:47:34 am »
Huh, alright, although I’d say just as it is a bad idea to keep unreachable code it’s a bad idea to include unnecessary declarations. It simply clutters your (generated) documentation.
It's a good idea to make it explicitly known the bits are unused.  That way the person who reads the code knows that, some bit definitions aren't missing, they are simply unused.  Knowing that also aids in future maintenance.

Have you tried using this data type? Like:
Code: Pascal  [Select][+][-]
  1. var
  2.         x:  TSome2_62;
  3. begin
  4.         x.B := 0;
I can’t even compile it without getting the internal error 2006081613. Interestingly, bitSizeOf(tSome2_62.B) is −1. I didn’t know this was even possible. I think this warrants a bug report.
I haven't tried your suggestion.  I noticed that if instead of having one field of one (1) bit and another of 63 bits, I have two fields of 1 bit each followed by a field of 62 bits then the size is correct. 

I would have reported it as a bug if I were using the latest version of FPC but, since I am not, I don't know if the problem exists in the current version.  Additionally, none of the FPC developers have said anything about this problem.

I believe it's a bug and, it's not the only "peculiar" behavior I've seen associated with bit fields.  If a developer confirms it is a bug then, I'll gladly create a bug report for it.
5
General / Re: Unexpected structure size
« Last post by Kays on Today at 12:35:45 am »
[…] The "Filler" fields are there for documentation purposes. […]
Huh, alright, although I’d say just as it is a bad idea to keep unreachable code it’s a bad idea to include unnecessary declarations. It simply clutters your (generated) documentation.

I would insert some safeguard though:
Code: Pascal  [Select][+][-]
  1.         {$if sizeOf(trtl_balanced_node) <> 3 * sizeOf(ptrUInt)}
  2.                 {$fatal size mismatch}
  3.         {$endIf}

[…] In 64bit, the first two sizes reported are ok but, the size of the third record being 1 is very "peculiar". […]
Have you tried using this data type? Like:
Code: Pascal  [Select][+][-]
  1. var
  2.         x:  TSome2_62;
  3. begin
  4.         x.B := 0;
I can’t even compile it without getting the internal error 2006081613. Interestingly, bitSizeOf(tSome2_62.B) is −1. I didn’t know this was even possible. I think this warrants a bug report.
6
Databases / Re: Question for IBX developers
« Last post by tonyw on Today at 12:14:22 am »
I have now implemented the requested feature. You can checkout a development snapshot using

svn co https://svn.mwasoftware.co.uk/public/ibx/trunk ibx

or just go to https://svn.mwasoftware.co.uk/ibx to view the update and download a tarball. Disabling stale reference checks is now included in the test suite as part of Test 16.
7
Database / Substrings in ZMSQL
« Last post by maurobio on Today at 12:13:08 am »
Dear ALL,

Many dialects of SQL (MySQL, SQLite, etc.) have a handy SUBSTR() function which extract a substring from a string (starting at any position), for example:

Code: Pascal  [Select][+][-]
  1. SELECT SUBSTR(CustomerName, 2, 5) AS ExtractString FROM Customers;

However, the ZMSQL library (https://wiki.freepascal.org/ZMSQL) offers two rather unusual variations of this function, as follows:

Quote
substr_after(source, substring) Returns the part of source that comes after substring. If substring is not found an empty string is returned.

substr_before(source, substring) Returns the part of source that comes before substring. If substring is not found an empty string is returned.
I do not understand how these functions work and have not been able to find any examples. Could some one provides me with a few hints?

Thanks in advance!

With best wishes,

8
Beginners / Re: [SOLVED] Generics.Collections TDictionary indexed access
« Last post by piola on September 20, 2021, 11:37:18 pm »
Yes, thanks for that point. But in my case, an indexed access is more important than a small decrease in speed. I do not expect you to do my work, but maybe you'd give me a hint on how to do it.

Currently I'm getting an iterator and throw the first i-1 elements away to get the i-th one. But I think there has to be a much more elegant solution, depending on how the data is managed internally. I already had a look into that but I'm not sure how to use it correctly.
9
General / Re: Zeroing the array.
« Last post by Seenkao on September 20, 2021, 11:23:22 pm »
FPC3.2.0/LAZ2.0.12 - 32-Bit
LibC Memset:   3.5183000564575195E+000
Build a 64-bit version for the test. Or find the msvcrt 32-bit version.

AMD Athlon II X2 240 (Linux)
FillChar:  7.7355908203125000E+002
Memset:   7.7813085937500000E+002 (assembler!!!)
LibC Memset:   1.0655258789062500E+003

As you can see, there is no absolute solution for different machines.
10
General / Re: TFPObjectHashTable more efficient way to filter objects
« Last post by ASerge on September 20, 2021, 11:14:47 pm »
But the Count property is read-only and FCount is private, so the only way to decrement is to call Delete().
Well, if you really need it :-X:
Code: Pascal  [Select][+][-]
  1. {$MODE OBJFPC}
  2. {$LONGSTRINGS ON}
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses Contnrs;
  6.  
  7. function GetAddressOfReadFieldForProperty(constref Prop: LongWord): PLongWord; inline;
  8. begin
  9.   Result := @Prop;
  10. end;
  11.  
  12. procedure Test;
  13. var
  14.   Hash: TFPObjectHashTable;
  15. begin
  16.   Hash := TFPObjectHashTable.Create;
  17.   try
  18.     Hash.Add('Some', nil);
  19.     Writeln('Hash count: ', Hash.Count);
  20.     GetAddressOfReadFieldForProperty(Hash.Count)^ := 0;
  21.     Writeln('Hash count: ', Hash.Count);
  22.   finally
  23.     Hash.Free;
  24.   end;
  25. end;
  26.  
  27. begin
  28.   Test;
  29.   Readln;
  30. end.
Pages: [1] 2 3 ... 10

TinyPortal © 2005-2018