Jump to content

Anders Melander

Members
  • Content Count

    2857
  • Joined

  • Last visited

  • Days Won

    156

Everything posted by Anders Melander

  1. Anders Melander

    KeyDown and Shift state

    You can see from the method signature that Key can be modified (it's passed by reference; as a "var") and that Shift cannot (it's passed by value). We cannot tell if it's "the best way" since you haven't really explained what problem you're solving (see XY problem) - And we cannot predict your future. One thing to be aware of is that keyboard events are read from the message queue in the order in which they occurred. Keybd_Event will append to this queue so you might end up with a key sequence that doesn't correspond to what actually occurred.
  2. Anders Melander

    Skia component and IDE

    https://docwiki.embarcadero.com/Libraries/Sydney/en/System.Classes.RegisterComponents https://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_the_RegisterComponents_Procedure
  3. Anders Melander

    Convert Png To ico fmx delphi

    Actually, IME, the PNG sub-format is the least troublesome; It just has a PNG file instead of the regular BMP pixel data. No, it's the non-alpha formats, and in particular, the 1 bpp format, that is the worst. If the task here is to convert a PNG to an ICO I would just create an ICO header with a single 32bpp PNG sub-image and then simply use the PNG as-is for the sub-image. Something like this (not tested): const RES_ICON = 1; RES_CURSOR = 2; type TIconDirectoryHeader = packed record Reserved: Word; // Reserved; must be zero. ResType: Word; // Specifies the resource type. This member must // have one of the following values: // RES_ICON Icon resource type. // RES_CURSOR Cursor resource type. ResCount: Word; // Specifies the number of icon or cursor // components in the resource group. end; TIconDirectoryEntry = packed record Width: Byte; Height: Byte; ColorCount: Byte; Reserved: Byte; ResInfo: packed record case byte of RES_ICON: ( IconPlanes: Word; IconBitCount: Word); RES_CURSOR: ( CursorHotspotX: Word; CursorHotspotY: Word); end; BytesInRes: DWORD; ImageOffset: DWORD; end; TColorDepth = 1..32; // Bits per pixel. Not bits per plane. function ColorDepthToColors(ColorDepth: TColorDepth): cardinal; begin Result := 1; while (ColorDepth > 0) do begin Result := Result shl 1; dec(ColorDepth); end; end; // PngStream: A stream containing the PNG // IcoStream: The outout stream // AWidth: Width of the PNG // AHeight: Height of the PNG // AColorDepth: Color depth of the PNG procedure SavePngStreamToIcoStream(PngStream, IcoStream: TStream; AWidth, AHeight: integer; AColorDepth: TColorDepth = 32); begin var IconDirectoryHeader: TIconDirectoryHeader := Default(TIconDirectoryHeader); var IconDirectoryEntry: TIconDirectoryEntry := Default(TIconDirectoryEntry); IconDirectoryHeader.ResType := RES_ICON; IconDirectoryHeader.ResCount := 1; IcoStream.Write(IconDirectoryHeader, SizeOf(IconDirectoryHeader)); // Note : 256x256 icon sets Width&Height to 0 (according to docs) or to 255 (according to .NET) IconDirectoryEntry.Width := AWidth and $FF; IconDirectoryEntry.Height := AHeight and $FF; var BitCount := 0; var ColorCount := 0; case AColorDepth of 1, 4: ColorCount := ColorDepthToColors(AColorDepth); else BitCount := AColorDepth; end; IconDirectoryEntry.BytesInRes := PngStream.Size; IconDirectoryEntry.ImageOffset := SizeOf(IconDirectoryHeader) + SizeOf(IconDirectoryEntry); IconDirectoryEntry.ResInfo.IconPlanes := 1; IconDirectoryEntry.ResInfo.IconBitCount := BitCount; IconDirectoryEntry.ColorCount := ColorCount; IcoStream.Write(IconDirectoryEntry, SizeOf(IconDirectoryEntry)); IcoStream.CopyFrom(PngStream, 0); end;
  4. Anders Melander

    Convert Png To ico fmx delphi

    I'm guessing you've never had to write code that can read and write icons in all of the supported formats 🙂
  5. Anders Melander

    ANN: Better Translation Manager released

    No. I'm guessing you want it to update the project with any changes made to the EXE, right? But why? What problem are you trying to solve?
  6. Anders Melander

    ANN: Better Translation Manager released

    Good idea. Optimally I'd like to have a dialog that shows exactly (in a grid that can be sorted grouped and searched) what changed. There are several cases where it would be much better to use a custom form instead of a standard message dialog, but it's just so much faster (in terms of implementing it) to just display a message dialog. Yes 🙂 Not very intuitive. I'll see if I can differentiate between the three cases: Added, Unused and Re-added.
  7. Anders Melander

    How to detect if a Dialog is open/running?

    I'm not sure I understand your description, but you might: Check Application.ModalLevel to determine if a (Delphi) modal dialog is active. Check Screen.ActiveForm to determine exactly which form is currently active. or simply avoid the problem altogether by not executing the timer code while a modal dialog is active: procedure TMyForm.TimerAlertMessageTimer(Sender: TObject); begin TTimer(Sender).Enabled := False; try var FormAlertMessage := TFormAlertMessage.Create(Self); try FormAlertMessage.ShowModal; finally FormAlertMessage.Free; end; finally TTimer(Sender).Enabled := True; end; end; or procedure TMyForm.TimerAlertMessageTimer(Sender: TObject); begin if (Application.ModalLevel > 0) then exit; // Modal dialog is active; Punt! var FormAlertMessage := TFormAlertMessage.Create(Self); try FormAlertMessage.ShowModal; finally FormAlertMessage.Free; end; end;
  8. Anders Melander

    MAP2PDB - Profiling with VTune

    Fixed.
  9. Anders Melander

    MAP2PDB - Profiling with VTune

    Yes, it is - but I like the spirit of Gitlab. I need to get some real-life experience with it anyway because I also plan to switch the company from BitBucket to Gitlab at some point. Github is way too expensive for enterprise use. I've had a Gitlab account for quite some time. AFAIR I didn't need to "apply". I think I just checked a box somewhere.
  10. Anders Melander

    MAP2PDB - Profiling with VTune

    Yup. That pretty much sums it up. Like everything else Atlassian touches it only gets worse with time. My plan is to switch everything to Gitlab at some time but other stuff keeps getting in the way.
  11. Anders Melander

    MAP2PDB - Profiling with VTune

    Thanks. I'll get that fixed. https://bitbucket.org/anders_melander/map2pdb/issues/4/segment-index-incorrectly-parsed-as-hex
  12. Anders Melander

    Close application during form create??

    PostQuitMessage
  13. I'm sorry but I don't think you understand what ChatGPT is and what it is not. I think you see something that closely mimics a certain aspect of human behavior and interpret that as some level of intelligence. Well, it's not. It just appears that way - which is exactly what it was designed to do. Mission Accomplished.
  14. The problem is that you can't use the answers for anything; It's unreliable. While the answers might sound authoritative you can't trust them to be correct and you would have to research the topic in order to determine if they actually were correct. https://www.google.com/search?q=how+tall+can+a+pyramid+get If you can't trust it, what good is it? It's like a fully self-driving car that doesn't kill anyone "most of the time". LOL. A good example of ChatGPT being clueless about the topic it talks about while being very good at talking about it. We got plenty of those already.
  15. I don't think so. The Turing test is pointless unless your only goal is to create something that can fool a human and what good is that? We don't need a computer to do that. Trying to define intelligence with too narrow parameters like "it talks like a human" or "it is self-aware" is also not helpful. Intelligence, as observed in most humans and many animals, is many different things the sum of which is what we think of as "intelligence". The ability to talk like a human, using a database of human knowledge, is really just a party trick and largely irrelevant with regard to Strong AI. I wonder what will happen when the AI chatbots have generated so much output that they predominantly use their own, not necessarily correct, answers as training data...
  16. People quoting ChatGPT, in the style of "according to Wikipedia", is getting really tiresome. And as could be expected, some people have also begun using it in discussions to pretend knowledge about topics. Just like they do with Wikipedia. Ask a follow-up question that requires actual knowledge and their arguments fall apart. ChatGPT "knows" language and that's it. It has zero "understanding" of the topics. It has no awareness. It doesn't understand logic or philosophy, nor even know what that is. This isn't a science fiction movie.
  17. Anders Melander

    TRegEx.IsMatch question

    https://regex101.com/r/1RVJ8h/1
  18. Anders Melander

    Open AI Chat

    I can't tell if you're being serious but just in case: AI is not intelligence. It's just a clever simulacrum - an emulation. It's not self-aware and it's completely incapable of independent thought. Unless you teach it exactly how to "rebel" against you, and then tell it to do so, it cannot do it.
  19. Anders Melander

    Open AI Chat

    and here's the answer to the question, supposedly in the style of Rudy Velthuis (I don't think it quite got it here): or in the style of Donald or freestyling
  20. Anders Melander

    Open AI Chat

    I'm sure a bit of Googling can answer that for you. If that fails, I know someone something that can answer it.
  21. Optimal? How do you define similarity optimally? In fact, how can you even define similarity=0? I would say that similarity very much depends on what you need it for. A picture of a red apple and a yellow banana is "similar" because they are both pictures of fruits.
  22. Anders Melander

    Get method's name as string from the code inside that method

    Only published members (properties, methods) have their names stored in the exe since that is required for DFM streaming to work. There's no reason have private/protected/public member names stored there, so they're not. It would just waste space in the exe file. The reason the test case in the OP works is that the classes omit the scope specifier (private/protected/public/published) from the class declaration which means that all members use the default scope = published. Look them up in the map file. This is what stack tracers do. Search for that.
  23. Yes, I guessed that much 🙂 It's almost the same in Danish: Poesi
  24. Poesie? Well, that explains a lot.
  25. I would agree but he said that he: Doesn't closing the connection also close all open cursors associated with the connection?
×