Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 09/21/24 in all areas

  1. I guess there are people with differing levels of ability. And while I don't intend to post links to all videos, today's video is a real-world example of adding code to a word search game and squashing those pesky bugs along the way! Hopefully, it will inspire you to tackle your own coding challenges and share your creations in the comments! https://youtu.be/K1iJIYtBPaw
  2. Ian Branch

    Multi Input Dialog..

    Hi Team, I do not recall where, when or how I came by the original of this Unit. If the origintor wants to speak up, I am happy to make the appropriate attribution and offer my thanks. I have made some enhancemants to the original. MultiInputDlg.rar I offer it as something to give back to the community, to learn some techniques from, and as a useful Dialog. Feel free to use/enhance as you wish. As usual, all care & no responsibility. 😉 Note: This was enhanced by me for use under D12+. I don't really know how far back in Delphi versions it will work. I make no apologies for any poor coding or coding style. Regards, Ian
  3. Anders Melander

    Scroll an image with mouse (Solved)

    No, don't do that; It would accumulate the various errors there is in coordinate system conversion, mouse imprecision, etc. Also, the example just doesn't work. Instead remember the starting mouse position and adjust the scrollbar position with the difference between the starting mouse position and the current position: type TForm1 = class(TForm) [...] private FStartPos: TPoint; end; procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin FStartPos.X := X; FStartPos.Y := Y; end; procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var DeltaMouse: TPoint; begin if (ssLeft in Shift) then begin // How much has the mouse moved since we started the drag? DeltaMouse := Point(FStartPos.X - X, FStartPos.Y - Y); // Reposition scrollbars (i.e. pan the image) ScrollBox1.HorzScrollBar.Position := ScrollBox1.HorzScrollBar.Position + DeltaMouse.X; ScrollBox1.VertScrollBar.Position := ScrollBox1.VertScrollBar.Position + DeltaMouse.Y; end; end;
  4. dummzeuch

    Multi Input Dialog..

    Interesting concept. Thanks for sharing it. I have never heard about this unit before, but I found this page by googling for "TInputRecArray" "Delphi" which looks a lot like your unit. It's a blog post from 2013 on a Chinese site. I think the concept could be improved on by using fluid programming like this: var Value1, Value2, Value3: Variant; // ... Success := MultiInputBox(Self) .AddField('Enter your age.: ' , 3, ftNumber, 0, Value1) .AddField('Enter a hex value.: ', 4, ftHexNumber, 0, Value2) .AddField('Enter a float value.: ', 10, ftFloatNumber, Value3) .ShowModal; That could be done by having MultiInputBox return an interface with an AddField function that returns that interface and a ShowModal function that returns the boolean. That interface then internally declares and manages the TInputRecArray. This saves the boilerplate code of declaring and filling the TInputRecArray and make the code (in my opinion) a lot more readable.
  5. dummzeuch

    Watch me coding in Delphi on YouTube

    GExperts did not have a Code Formatter in the 90ies. There was only DelForEx by Egbert van Nees (and later a code formatter as part of project JEDI which today is part of the Lazarus IDE). He donated that code to GExperts in the mid 2000ties and I integrated it into GExperts and over the years improved it (performance on large files more than doubled) and extended it to cover new language constructs that were added.
  6. Lajos Juhász

    Scroll an image with mouse (Solved)

    You would like to move the scrollbar by the ammount the user have move the mouse to do so you will need two variables (private fields) that stores the previous mouse coordinates: procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin fPRevX:=X; fPrevY:=Y; end; Now when the user moves the mouse while the left button is pressed we can calculate the new position for the scrollbars: procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if ssLeft in Shift then begin scrollbox1.vertScrollBar.Position := scrollbox1.vertScrollBar.Position+fPrevY-Y; scrollbox1.horzScrollBar.Position := scrollbox1.horzScrollBar.Position+fPRevX-X; fPrevX:=X; fPrevY:=y; end; end;
  7. I just posted another update for SVGIconViewer. This version increases the icon count to over 46,500 with the addition of the Bootstrap icon library, the ability to view a user specified folder containing .svg files and export those files as a Delphi TImageCollection with generated png versions of the files with a single click. https://github.com/skamradt/SVGIconViewer
  8. havrlisan

    When LSP fails

    In this post, I'll share all the workarounds I use when LSP fails, which have greatly helped me during coding. Hopefully, you'll find them useful before Embarcadero completely fixes the LSP Server, which I'm sure will be soon. I'll also mention GExperts throughout this post, as it includes some useful features that can speed up using the tools listed below. Delphi Uses Helper Link: https://delphisorcery.blogspot.com/2021/03/introducing-delphi-uses-helper.html Feature: proper replacement for the Find Unit... refactor (Ctrl+Shift+A) feature. Description This has been by far the most helpful plugin. It's as simple as typing the name of a type and pressing Ctrl+Shift+A to find the unit where it's declared. When the window pops up, you can press Enter to add the unit to the uses section (use the left/right arrows to switch between interface and implementation sections), or press Shift+Enter to open the unit and jump to the line where the type is declared. GExperts bonus: The IDE already has a similar feature under the Refactor menu with the same shortcut, Ctrl+Shift+A, but it doesn’t work well and is certainly not as fast as Delphi Uses Helper. However, sometimes the default feature will trigger instead of the plugin (e.g., when pressing the shortcut without any text at the caret position). To remove the default shortcut, use GExperts' IDE Menu Shortcuts: find the shortcut under Refactor > Find Unit... (it should be the last one), and assign it to another key. MMX - Show Related Classes Link: https://www.mmx-delphi.de/ Feature: shows ancestor class, implemented interfaces, and sibling classes for a given class. Description Want to quickly navigate to a class’s ancestor or interface, or find out which siblings it has? This feature gives you exactly that, neatly and efficiently. To use it, right-click and go to MMX Commands > Navigate and Move > Show Related Classes. Or even better, map a shortcut by going to MMX > Properties > Key Bindings and finding Show Related Classes. I’ve personally mapped it to Shift+Alt+3. MMX - Open Unit... Link: https://www.mmx-delphi.de/ Feature: displays searchable units based on set configuration. Description Quickly displays all units based on your configuration. The configuration allows for adding units from the currently opened project or project group, and the following paths: Project Search path, IDE Library path, and IDE Browsing path. Find Original Symbol Feature: additional help navigating to a unit, type, or method. Description Using Find Declaration (Ctrl+Click) is known to fail occasionally, especially on bigger projects. What I've found helpful at times is to try using the Find Original Symbol that's located under the Search > Find Symbols menu item. I've personally mapped the Find Declaration to Ctrl+< and the Find Original Symbol to Ctrl+Shift+< through the GExperts IDE Menu Shortcuts, and I spam them when needed. It does help sometimes. Add a shortcut to the Reload LSP Server menu item Link: https://github.com/havrlisan/zx-idetools/blob/main/Source/Zx.IT.KeyBinding.ReloadLSPServer.pas Description In Delphi 12.1, a menu item Reload LSP Server was added under the Tools menu. Before that, you could add a custom tool to manually kill the LSP, and the IDE would restart it automatically. Unfortunately, they didn't add a shortcut for the menu item, so your options are limited to mouse clicks or to clicking Alt > T > accelerated key. Note that the accelerated key will be automatically assigned, and it depends on your menu items under the Tools menu, which sucks because that's the most changeable menu (because of custom tools, or third-party plugins). Usually, I'd use GExperts IDE Menu Shortcuts to manually add the shortcut, but the Reload LSP Server menu item doesn't show up there. After some debugging, I realized that the menu item in question isn't registered on IDE startup, but is loaded sometime after all other packages are loaded. My best guess is that the GExperts remembers the menu items when loaded, and doesn't re-fetch them afterward (I'm too lazy to search through the source code, sorry). So I decided to implement an IDE notifier that listens to a "ProjectGroupOpen" notification and then tries to find the Reload LSP Server menu item and assigns the shortcut to it. I've set the default shortcut to Alt+Shift+W, but the code is quite simple and is easily portable to a package of your own. That's all I've got so far. If you have some other features or tips, feel free to share them in this post!
  9. Lars Fosdal

    Watch me coding in Delphi on YouTube

    It may LOOK like a ternary, but looks deceive. It does NOT behave like a ternary op. Both expressions will be evaluated/executed - and not one or the other. The only place I use it, is when I want to emit const values, dependant on an expression.
×