Jump to content

Remy Lebeau

  • Content Count

  • Joined

  • Last visited

  • Days Won


Remy Lebeau last won the day on April 19

Remy Lebeau had the most liked content!

Community Reputation

309 Excellent


Technical Information

  • Delphi-Version
    Delphi XE2

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Remy Lebeau

    Detect Windows shutdown?

    The WM_QUERYENDSESSION documentation clearly states that data saving should be deferred to the WM_ENDSESSION message, so you don't really need the MSG_SAVEDATA approach: And the WM_ENDSESSION documentation says: System shutdown can be aborted, in which case there would be no need to save any unsaved data, as long as your app has not been terminated yet. WM_QUERYENDSESSION is just asking for permission for the system to be shut down. The actual shutdown has not taken place yet. But, once an actual shutdown begins, unsaved data should be saved automatically. If you want to prompt the user whether unsaved data should be saved, do that in response to WM_CLOSE (or the TForm.OnCloseQuery event) instead: If you receive WM_ENDSESSION before receiving WM_CLOSE/OnCloseQuery then simply don't prompt the user.
  2. Remy Lebeau

    Destroying TList with Managed Types

    No, because the as operator forces the compiler to create a hidden variable for the interface, before it is then passed to the const parameter. Had the code been written like this instead, THEN there would have been a problem: List.Add(TItem.Create); Correct.
  3. Remy Lebeau

    Destroying TList with Managed Types

    That is not the reason. Your test functions may simply be holding a hidden local reference to the IItem that you create and add to the list, so the item is not fully released until after the list has been freed first. Try this instead to isolate that reference so it gets released sooner: procedure TestDestroyOnly; var List: TItemList; procedure AddItem; begin List.Add(TItem.Create as IItem); end; begin Writeln( 'Start Test - Destroy Only'); List := TItemList.Create; try AddItem; finally List.Free; end; Writeln( 'End Test - Destroy Only'); end; procedure TestWithExplicitClear; var List: TItemList; procedure AddItem; begin List.Add(TItem.Create as IItem); end; begin Writeln( 'Start Test - Explicit Clear'); List := TItemList.Create; try AddItem; List.Clear; finally List.Free; end; Writeln( 'End Test - Explicit Clear'); end;
  4. Remy Lebeau

    Mixed resources type 12

    All VCL TGraphic-derived classes have a SaveToFile() method, you don't need to save to a TFileStream manually: uses Vcl.Imaging.PngImage; procedure SaveBitmapToPNG(ABitmap: TBitmap; const AFileName: String; ACompresionLevel: Integer = 7); var img: TPngImage; begin img := TPngImage.Create; try img.CompressionLevel := ACompresionLevel; img.Assign(ABitmap); img.SaveToFile(AFileName); finally img.Free; end; end;
  5. Classes are reference types in Delphi: "Reference types can be forward declared because their size are always known (=SizeOf(pointer))."
  6. Remy Lebeau

    Return background to foreground

    When another user calls, display a notification, and when the receiving user clicks on the notification, the app can then come forward and complete the call.
  7. Remy Lebeau

    Rx10.4 new feature blogs

    That has been the case for several years now. Near the end of each beta, some testers (not all) are granted permission to publicly blog about their experiences in the beta. Note the disclaimers given at the top of each non-Embarcadero blog mentioned above (and others), eg: "I have been given permission from Embarcadero to blog about some of the new features and improvements." "Published with special permission from Embarcadero" "I’ve specifically been given permission to show updates and new features in the product" etc...
  8. Short answer - background tasks that want to stay awake and running need to be done in a background service, not in a thread in an app that moves between the foreground and background.
  9. Processes and Application Lifecycle Understand the Activity Lifecycle Android is the same way. Background apps have to let the OS know that they are still "running" and should not be killed off. The OS is still free to kill them if it NEEDS to, though (low resources, etc).
  10. Remy Lebeau

    TIdHTTP SSL and error 'HTTP/1.1 403 Forbidden'

    The data you are seeing is not *encrypted*, it is *compressed*. You are telling the server that you will accept responses in a compressed format (on top of encryption used by SSL/TLS), and the server is choosing to actually send a compressed response (you can verify that by looking at the TIdHTTP.Response.ContentEncoding property after the response arrives), however you have not setup TIdHTTP to actually decompress the compressed data for you, so you are seeing the compressed data as-is (well, after it has been String'ified, anyway). Get rid of that assignment to the TIdHTTP.Request.AcceptEncoding property (unless you really want to try your hand at decompressing the data manually). Instead, assign a TIdZLibCompressorBase-derived component, such as TIdCompressorZLib, to the TIdHTTP.Compressor property, and let TIdHTTP manage the AcceptEncoding property for you based on the compressor's capabilities. Don't call the TIdLogFile's Open() and Close() methods directly. Use its Active property instead, which will call Open()/Close() for you: IdLogFile1.Active := True; try LResp := IdHTTP1.Get('https://www.trivial.com.br/envia_arq3.php?senha=violeta&nome=tre'); finally IdLogFile1.Active := False; end; Calling Open() will open the log file you specify, but any sent/received data will not be logged to the file if Active is False.
  11. Remy Lebeau

    Mixed resources type 12

    VCL's TBitmap supports only the BMP format (and actual BMPs, not JPEG/PNG-encoded BMPs that recent Windows versions support). Saving a VCL TBitmap to a file with a ".png" extension DOES NOT create a PNG image, it creates a BMP image. PNG is compressed, whereas BMP is (usually) not (though VCL's TBitmap can load a compressed BMP - I think - but it does not produce compressed BMPs). FMX's TBitmap supports many formats, including BMP and PNG. Saving an FMX TBitmap to a file with a ".png" extension creates a real PNG image. Try saving your FMX TBitmap to a file with a ".bmp" extension and you will see a result closer to what VCL's TBitmap creates. BMP and PNG are both lossless formats. The pixel data in both formats may represent the same color arrangements to a viewer, but the way the data is stored in memory and in a file are very different.
  12. Yes, Sleep()/usleep() really does block the calling thread, stopping it at the OS level, yielding to other threads so they can run, for at least the specified time (may be more). TEvent.WaitFor() is waiting for its internal event/semaphore object to be signaled by TEvent.SetEvent(), up to the specified time. During that wait time, the calling thread is stopped in a blocking sleep, yes. It is just using a different API to accomplish that.
  13. Remy Lebeau

    TIdHTTP SSL and error 'HTTP/1.1 403 Forbidden'

    It is not ideal, but it is not a problem, since the server will just ignore the 'Content-Type' request header in a GET request. 'application/x-www-webform-urlencoded' would not be a valid media type for an 'Accept' request header.
  14. Remy Lebeau

    Mixed resources type 12

    There are numerous examples and tutorials online for how to work with webcams using the Win32 API. That information is accessible via webcam APIs. You don't need VCL or FMX for that. Or, you could simply take the screenshot using an in-memory GDI bitmap, and then copy the raw pixel data from that bitmap into an FMX TBitmap as needed. Look at CreateCompatibleDC(), CreateCompatibleBitmap(), GetObject(), and TBitmap.Canvas.MapBitmap()/UnmapBitmap().
  15. Remy Lebeau

    TIdHTTP SSL and error 'HTTP/1.1 403 Forbidden'

    The fact that you are even getting an HTTP 403 error at all means the SSL portion is working fine, since HTTPS is encrypted and you are able to see a decrypted response. So the problem has to be related to something else. Maybe you are not accessing the correct URL. Maybe you are not authenticated properly with the server. Maybe you are missing a client-side certificate. We don't know, since we don't know your setup or what the server is expecting. One thing you could try is capture the HTTP request the browser is sending (using your browser's built-in debugger, or an external HTTPS debug proxy like Fiddler), and then capture the HTTP request that TIdHTTP is sending (assign one of Indy's TIdLog... component to the TIdHTTP.Intercept property), and compare them for any differences. If you don't see anything apparent at the HTTP layer (cookies, login credentials, etc), then the issue could be at the SSL layer (ie, certificates, etc) You likely need to talk to the server admins about this, ask them what the server requires to get permission to access it. Have them look at the HTTPS requests on their end to see why the server is rejecting them. You should contact AToZed to double-check, but I do not believe that paid support is still provided, at least for Indy. Probably only for IntraWeb, if at all.