Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation since 04/27/24 in Posts

  1. If you changed the interface section (bad idea, really) that means that every RTL and VCL unit using system.sysutils needs to be recompiled in addition to your own units and the resulting dcus need to be put in a folder where they replace the dcus that come with the Delphi installation. And remember that said installation has different dcus for debug and release and different platforms, something D7 did not have. Best reevaluate the original cause for this change in D7 and see wether you can avoid it in D11 completely.
  2. Unfortunately, since they broke the most truly useful feature of class helpers by removing the ability of the helper to access private members of the class, they don't work so great as an alternative to editing source files directly. Now you have to write a RTTI monstrosity to accomplish the same thing.
  3. There's no difference between Delphi 7 and 11 with regard to modifying sysutils that I can think of. You have most likely not specified the correct project search path. Where have you placed the modified sysutils.pas ?
  4. I presume you copied this altered version to your projects path...? And it is missing from the other project? Project requirements that require a change to a file which might in turn get changed with every patch/update of the IDE are at least worthy of discussion.
  5. That is true for strings, but nor for dynamic arrays.
  6. Sherlock

    A gem from the past (Goto)

    That reminds me:
  7. The activated option "Lock Controls" in the Edit menu is not restored when re-starting the IDE! This option is very important and helpful, as it prevents an unintentional repositioning of controls in the Form Designer! It also prevents the annoying file change in the FormDesigner that frequently (randomly) happens when switching from the Code Editor to the FormDesigner (with F12), caused by the automatic re-aligning of aligned controls in the Form Designer: The option "Lock Controls" should be restored automatically when re-starting the IDE to prevent this annoying behavior! Can anyone confirm this?
  8. The project search path has precedence. Post your .dproj file if you can. ...or you could explain what your end goal is; Why do you need to modify sysutils.pas? We might help you with a better solution.
  9. Mark-

    Desktop Icons

    I did that a few days ago out of curiosity. I did it a function at a time so it needs work to make it workable. procedure FindDesktopFolderView(riid: TGUID; var ppv: Pointer); var spShellWindows: IShellWindows; vtLoc: OleVariant; vtEmpty: OleVariant; lhwnd: LongInt; spdisp: IDispatch; spBrowser: IShellBrowser; spView: IShellView; begin spShellWindows := CoShellWindows.Create; vtLoc := CSIDL_DESKTOP; vtEmpty := VarEmpty; spShellWindows.FindWindowSW(vtLoc, vtEmpty, SWC_DESKTOP, lhwnd, SWFO_NEEDDISPATCH, spdisp); spBrowser := (spdisp as IServiceProvider).QueryService(SID_STopLevelBrowser, IShellBrowser) as IShellBrowser; spBrowser.QueryActiveShellView(spView); spView.QueryInterface(riid, ppv); end; ----------------- program DesktopFolderView; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, ActiveX, ComObj, ShlObj, ShellAPI; // CCoInitialize incorporated by reference function wmain(argc: Integer; argv: PWideChar): Integer; var init: IUnknown; // Equivalent to CCoInitialize spView: IFolderView; spFolder: IShellFolder; spEnum: IEnumIDList; spidl: PItemIDList; str: TStrRet; spszName: PWideChar; pt: TPoint; begin init := CreateComObject(CLSID_CoInitialize); FindDesktopFolderView(IID_IFolderView, spView); spView.GetFolder(IID_IShellFolder, spFolder); spView.Items(SVGIO_ALLVIEW, IID_IEnumIDList, spEnum); while spEnum.Next(1, spidl, nil) = S_OK do begin spFolder.GetDisplayNameOf(spidl, SHGDN_NORMAL, str); StrRetToStr(@str, spidl, spszName); spView.GetItemPosition(spidl, pt); Writeln(Format('At %4d,%4d is %s', [pt.x, pt.y, WideString(spszName)])); CoTaskMemFree(spidl); end; Result := 0; end; begin try CoInitialize(nil); wmain(ParamCount, PWideChar(ParamStr(0))); CoUninitialize; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end. --------------------------- program DesktopFolderRandomPosition; {$APPTYPE CONSOLE} uses System.SysUtils, ActiveX, ComObj, ShlObj, ShellAPI, Windows; function wmain(argc: Integer; argv: PWideChar): Integer; var init: IUnknown; // Equivalent to CCoInitialize spView: IFolderView; spEnum: IEnumIDList; spidl: PItemIDList; pt: TPoint; apidl: array[0..0] of PItemIDList; begin init := CreateComObject(CLSID_CoInitialize); FindDesktopFolderView(IID_IFolderView, spView); spView.Items(SVGIO_ALLVIEW, IID_IEnumIDList, spEnum); while spEnum.Next(1, spidl, nil) = S_OK do begin spView.GetItemPosition(spidl, pt); pt.x := pt.x + (Random(5) - 2); pt.y := pt.y + (Random(5) - 2); apidl[0] := spidl; spView.SelectAndPositionItems(1, @apidl[0], @pt, SVSI_POSITIONITEM); CoTaskMemFree(spidl); end; Result := 0; end; begin try CoInitialize(nil); Randomize; // Initialize random number generator wmain(ParamCount, PWideChar(ParamStr(0))); CoUninitialize; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end. ------------------------------------ procedure SavePositions(pView: IFolderView; pszFile: PWideChar); var spStream: IStream; spEnum: IEnumIDList; spidl: PItemIDList; pt: TPoint; begin SHCreateStreamOnFileEx(pszFile, STGM_CREATE or STGM_WRITE, FILE_ATTRIBUTE_NORMAL, True, nil, spStream); pView.Items(SVGIO_ALLVIEW, IID_IEnumIDList, spEnum); while spEnum.Next(1, spidl, nil) = S_OK do begin WritePidlToStream(spStream, spidl); // Custom function to write PIDL to stream pView.GetItemPosition(spidl, pt); WritePointToStream(spStream, pt); // Custom function to write POINT to stream ILFree(spidl); // Free the PIDL end; end; ----------------------------------- procedure RestorePositions(pView: IFolderView; pszFile: PWideChar); var spStream: IStream; spidl: PItemIDList; pt: TPoint; apidl: array[0..0] of PItemIDList; begin // Create a file stream SHCreateStreamOnFileEx(pszFile, STGM_READ, FILE_ATTRIBUTE_NORMAL, False, nil, spStream); // Read PIDLs and their positions from the stream and restore them while Succeeded(IStream_ReadPidl(spStream, spidl)) and Succeeded(spStream.Read(@pt, SizeOf(pt), nil)) do begin apidl[0] := spidl; pView.SelectAndPositionItems(1, @apidl[0], @pt, SVSI_POSITIONITEM); CoTaskMemFree(spidl); // Free the PIDL end; end; // Note: IStream_ReadPidl is a placeholder for the actual function you would use to read a PIDL from a stream. // You will need to implement this functionality in Delphi, as it is not provided by Delphi's standard libraries.
  10. Remy Lebeau

    TCP Port Check with timeout

    You are leaking the socket handle if connect() fails. You have to close the handle if socket() succeeds, regardless of whether connect() succeeds. You can't reduce (or even set) the timeout on a blocking connect(). You have to use a non-blocking connect() and then use select() or equivalent to implement the timeout. AFAIK, you can't disable SACK on a per-socket basis. You have to use the Registry or command-line netsh utility to disable it globally: https://superuser.com/questions/1808254/how-to-disable-tcp-sack-in-windows-xp https://www.linkedin.com/advice/3/how-can-tcp-selective-acknowledgment-sack-improve-heatc
  11. Dave Nottage

    Memo and html

    You might be able to modify this code to use TMemo instead of TLabel: https://github.com/grijjy/CodeRage2019/tree/master/HtmlLabel
  12. Remy Lebeau

    Memo and html

    The standard FMX TMemo simply does not support HTML (or even basic text formatting in general). You will have to use a 3rd party control (or make your own from scratch) to display rich/formatted text.
  13. Remy Lebeau

    File opening error C++ builder CE trivial program

    The C++ standard file library really sucks what it comes to error reporting. I would suggest using TFileStream or even CreateFile() directly to get better details about what the actual failure is. On a side note: kbhit() is a really old-school Borland function, it is not standard in either C or C++. Consider using C++'s standard std::cin.get() method instead. Try this: #include <iostream> #include <memory> #include <System.SysUtils.hpp> #include <System.Classes.hpp> int _tmain(int argc, _TCHAR* argv[]) { try { auto ifs = std::make_unique<TFileStream>(_D("C:\\Junk\\testfile.txt"), fmOpenRead); std::cout << "Opened OK\n"; } catch (const Sysutils::Exception &e) { std::wcout << L"Can't open input file. Error: " << e.Message.c_str() << "\n"; std::cin.get(); return 1; } std::cin.get(); return 0; } Or: #include <iostream> #include <windows.h> int _tmain(int argc, _TCHAR* argv[]) { HANDLE hFile = CreateFileW(L"C:\\Junk\\testfile.txt", GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); if (hFile == INVALID_HANDLE_VALUE) { DWORD dwError = GetLastError(); cout << "Can't open input file. Error: " << dwError << "\n"; std::cin.get(); return 1; } std::cout << "Opened OK\n"; CloseHandle(hFile); std::cin.get(); return 0; }
  14. That code works for me fine on 12.1, I guess the basic question is do you have a file the that input stream can load. If it doesnt exist it will fail
  15. Lajos Juhász

    Memo and html

    In that case you will have to implement it yourself.
  16. Alexander Sviridenkov

    Memo and html

    https://delphihtmlcomponents.com/editor.html
  17. Bill Meyer

    A gem from the past (Goto)

    There is a classic, if dusty, article from Donald Knuth: https://pic.plover.com/knuth-GOTO.pdf
  18. MarkShark

    Bug: Lock Controls is not restored at IDE start!

    As a possibly related note. I've created a bug report Lock Controls not visible initially regarding that menu item having some issues when placed on an IDE toolbar. I always do this when I customize the IDE after install. It's a very useful feature.
  19. Uwe Raabe

    Bug: Lock Controls is not restored at IDE start!

    Seems someone already filed a report 8 years ago: https://quality.embarcadero.com/browse/RSP-13448
  20. Alexander Sviridenkov

    WebUI framework: Technical preview. Part 1.

    Small example of using custom HTML/JS inside Report control. JS code send pallet and boxes params to Server (Delphi), receive calculated pallet loading and display it. pallet.mp4
  21. dummzeuch

    Delphi and "Use only memory safe languages"

    Since Delphi is kind of a legacy programming language nowadays, backwards compatibility is very important. You don't want to throw away millions lines of proven code because they don't work any more, or even worse, because they are now buggy. So trying to change strings to be zero based was a bad idea, even if it was "just for mobile platforms".
  22. Remy Lebeau

    Desktop Icons

    Raymond Chen's blog article on Manipulating the positions of desktop icons includes code "to enumerate all the desktop icons and print their names and locations."
  23. Rollo62

    New desktop FMX app - third party controls?

    My recommendation would be, to avoid 3rd Libraries as much as possible. Since FMX on Mobile is very volatile and Android/iOS change significantly every 6 months, it is very important not to rely on additional, possibly unstable, external components. My recommendation would be, to make as much as possible on your own. I can recommend DelphiWorlds-Kastri as a common life-saver, TMS FNC and other TMS components - since they are quite active, but I would still reduce any external reference as much as possible. Moreover, I would not directly try to port a desktop app to mobile. Better to start clean with a mobile-first app and then put your "desktop" functionality back step-by-step.
  24. Lajos Juhász

    Delphi 12: MessageDlg doesn't show icons

    MsgDlgIcons[TMsgDlgType.mtInformation]:=TMsgDlgIcon.mdiInformation; MessageDlg('Exiting the Delphi application.', mtInformation, [mbOk], 0, mbOk); You have to System.UITypes into the uses.
×