Jump to content

Remy Lebeau

Members
  • Content Count

    2319
  • Joined

  • Last visited

  • Days Won

    94

Everything posted by Remy Lebeau

  1. Remy Lebeau

    Help with Query at run time

    'group' is a reserved keyword in SQL. To use a reserved keyword in an object name, like a column field, you have to surround the name with square brackets, eg: FDQuery1.SQL.Text := 'SELECT record,name,meaning,pronounce,[group],period,size,lived,diet,factfile FROM dino Where name = :PName';
  2. Remy Lebeau

    Delphi 12 IDE, auto-formatter mutilates generics

    Please don't spread fake news. There is no such version. It is explicitly mentioned, in a roundabout way: Modeling is deprecated, and the current code formatter depends on it, so the formatter is also deprecated.
  3. Remy Lebeau

    Help with Query at run time

    It is raw RGB, use whatever values you want for the R, G, B channels. The code you showed is not using a dark brown, it's more like a red-ish brown. RGB(80,47,15) is actually #502F0F in paint programs (not to be confused with the '#xxxx' character constant notation in Pascal!). It is not. Completely different RGBs. TColor(#575) is decimal 575 is hex $23F (use any calculator to verify that), and TColor($0000023F) is R=63($3F) G=2($02) B=0($00). RGB(80,47,15) would be TColor($0F2F50). If you want to set that in code, you can use the actual RGB() function: edtLived.Font.Color := TColor(RGB(80,47,15)); BTW, you may want to have a look at the TControl.ParentFont property. Instead of setting the Font.Color on every control individually, you can set it once on their parent instead, and then have the controls inherit it via ParentFont.
  4. Remy Lebeau

    Help with Query at run time

    Yes. You can enter a custom color value directly into the property editor, you just have to use decimal notation (drop the #) or hex notation, ie use '575' or '$23F' (without the quotes). Even in your code, don't use '#' for color values. '#' is used to specify a Char constant, and a character is not a color. Use TColor(575) or TColor($23F) in code, or more expressive TColor(RGB(63, 2, 0)) or TColor(RGB($3F, $2, $0)). It is highlighted because that TEdit has the input focus at the time. Simply put the focus somewhere else, such as the Form itself. Also, make sure the Form's ActiveControl property is not set at design-time (or, set it to the UI control you actually want to have the focus initially).
  5. Remy Lebeau

    Help with Query at run time

    Where are you calling TfrmDino.getdbrecord() from? It is not in the code you have shown. You can't activate the query before you have configured it. Sounds like you hadn't defined the SQL for it yet before trying to use it. All of that setup stuff you are doing in the Form's OnCreate event should be done using the Object Inspector at design-time instead. Start with this: https://docwiki.embarcadero.com/RADStudio/en/FireDAC
  6. Remy Lebeau

    Help with Query at run time

    Obviously, you need to adjust the code for your particular setup, which you did not provide ANY details about, so I could only give you a GENERAL solution. What kind of database are you are trying to access? What component(s) are you are using to access that database? My example was meant to represent whatever Query component you are actually using on your Form, such as a TQuery, TFDQuery, etc. Use whatever the actual component name really is. Not a String variable. Have you read Delphi's documentation on working with Databases? There are whole books on this subject.
  7. Remy Lebeau

    Recent Menu partly hidden

    Yes, I see the same issue happen, the top of the Recent menu is WAY off screen:
  8. Remy Lebeau

    Help with Query at run time

    There should be no difference between setting up a query at design-time vs runtime. So, what are you REALLY having trouble with, exactly? Can you show the actual code that you are having trouble with? All you need is something like this: Query.SQL.Text := 'SELECT Name, OtherFieldsAsNeeded from dino where Name = :PName'; Query.ParamByName('PName').AsString := sName; Query.Open; edtName.Text := Query.FieldByName('Name').AsString;
  9. Remy Lebeau

    Indy components error

    No, I was actually referring to the compiler's Library and Browsing Paths, the debugger's Source Path, etc. There are multiple search paths in a project, make sure none of them are referring to Indy's source folder during compiling. You don't want the compiler finding Indy's source code if you want to use the pre-installed version. You said you re-installed the IDE and transferred over old projects. Do you have the same problem if you start a new project fresh? What IDE version were the old projects written in? It is generally a good idea to create a new project in the new IDE and then add your existing source files to the new project as needed, rather than just open an old project in the new IDE.
  10. Remy Lebeau

    Indy components error

    Is there more to the error message? I would think it would tell you WHY it can't compile the unit. In any case, it sounds like the project is trying to recompile Indy from its source code. Does the project refer to Indy's source code folder directly? It shouldn't, so if it does then remove that folder from the project's search directories. The project should only be using the pre-installed unit/package binaries that were already compiled for the IDE.
  11. Remy Lebeau

    Custom color not in color property list

    Assigning custom colors to properties via code at runtime is trivial, as shown earlier. But if you want to choose custom colors at design-time, that is possible but not trivial, as you have to write your own custom property editor and register it for TColor, overriding the default property editor. See webcolors and custom colors in Delphi's Object Inspector colorpicker at design-time Custom colors in Delphi 7
  12. Remy Lebeau

    Profile - currently no entry Delphi 12

    There is now.
  13. Remy Lebeau

    Delphi Version in profile

    It has been added. Oddly, it is listed as just "Delphi 12" instead of as "Delphi 12 Athens".
  14. Remy Lebeau

    Delphi 12: Install Packages inconsistency?

    Sure, but I shouldn't really have to go to that much trouble in the first place just to get basic behavior.
  15. Remy Lebeau

    random between a range

    And RandomFrom()
  16. Remy Lebeau

    random between a range

    RandomRange() has been around since Delphi 6.
  17. Remy Lebeau

    Indy components error

    Can you be a little more specific? What are the full error messages? Are you trying to use the version of Indy that ships preinstalled with the IDE (it should "just work" out of the box), or did you replace it with a newer version of Indy?
  18. Remy Lebeau

    random between a range

    One option would be to create 4 lists and fill them with the possible numbers, and then generate a random index for each list, where you remove each found number from subsequent lists before generating indexes for them. For example: var values1, values2, values3, values4: TList<Integer>; value1, value2, value3, value4, index: Integer; procedure populate(list: TList<Integer>; startValue, endValue: Integer); var value: Integer; begin list.Capacity := endValue - startValue + 1; for value := startValue to endValue do list.Add(value); end; procedure checkAndRemove(list: TList<Integer>; startValue, endValue, valueToRemove: Integer); begin if (valueToRemove >= startValue) and (valueToRemove <= endValue) then list.Remove(valueToRemove); end; begin values1 := TList<Integer>.Create; values2 := TList<Integer>.Create; values3 := TList<Integer>.Create; values4 := TList<Integer>.Create; populate(values1, 1, 300); populate(values2, 100, 550); populate(values3, 250, 750); populate(values4, 500, 1000); index := random(values1.Count); value1 := values1[index]; checkAndRemove(values2, 100, 550, value1); checkAndRemove(values3, 250, 750, value1); checkAndRemove(values4, 500, 1000, value1); index := random(values2.Count); value2 := values2[index]; checkAndRemove(values3, 250, 750, value2); checkAndRemove(values4, 500, 1000, value2); index := random(values3.Count); value3 := values3[index]; checkAndRemove(values4, 500, 1000, value3); index := random(values4.Count); value4 := values4[index]; values1.Free; values2.Free; values3.Free; values4.Free; end;
  19. Remy Lebeau

    How to remove C++ from RadStudio 12 after installation?

    Perhaps run $(BDS)\bin\LicenseManager.exe and remove your beta license if it's still listed?
  20. Remy Lebeau

    Delphi 12: Install Packages inconsistency?

    Agreed! Something that is really annoying me since installing 12.0 is when I double-click on a .pas/.cpp file outside of the IDE, and the IDE is not running yet, the IDE is started, but it wastes time loading all of its default packages and layouts, and then opens the .pas/.cpp file, and then finally goes to the Welcome screen instead of the .pas/.cpp file. Loading the packages, the Structure view, the Palette, etc is all completely unnecessary and the Welcome screen is completely unwelcomed when I just want to view a file. I expect the IDE to basically just present me with the code editor and nothing else. If I want the full IDE experience, I'll open the full IDE myself, or at least open/create a project and expect the IDE to (re)load everything it needs to support that task.
  21. Remy Lebeau

    Delphi 11, migrate or wait

    Better to use CompilerVersion (and RTLVersion) instead, then you don't need to update the defines every time a new version is released, only when you need to add a new define, eg: {$IF DEFINED(DCC) OR (CompilerVersion < 23)} {$DEFINE EC_DELPHI} {$IFEND} {$IF CompilerVersion >= 20} // Delphi 2009 {$DEFINE EC_UNICODE} {$IFEND} {$IF CompilerVersion >= 34} // Delphi 10.4 {$IF CompilerVersion < 35} {$DEFINE EC_VCL27} {$IFEND} {$DEFINE EC_VCL27_UP} {$IFEND} {$IF CompilerVersion >= 36} // Delphi 12 ... {$IFEND}
  22. Remy Lebeau

    How to break up an OnPaint event?

    Then you are likely doing too much work in your drawing code. Or you are doing other things besides just drawing. Painting should be a quick task. Draw only what can be seen for the current state of your existing data, nothing more. Do not manage your data/UI in any way other than drawing. If you need to manipulate your data/UI, that has to be done outside of a paint cycle. That is not how UI painting works. You have to draw whatever your current state represents. After the painting is finished, if a state change occurs, then you can trigger a repaint to draw the updated state. No. Every paint cycle is a complete redraw from scratch. For each window/control that is being painted, you have to draw it entirely in a single cycle. And then again in the next cycle. And so on. You can Invalidate() an individual form/control to trigger a new paint cycle for it, but that requires you to redraw it entirely from scratch when that next cycle begins,
  23. SafeSEH and CFG require compiler/linker support to setup additional data/code in the exe, so it's not enough to just enable their flags in the PE header. Delphi does not support SafeSEH or CFG at this time. But there is a SetProcessValidCallTargets() API you can call in your own code to implement CFG manually, at least.
  24. I don't really have an answer for you. All I can think of right now is either 1) maybe you still have old files on your system somewhere, or 2) maybe you didn't recompile/separate everything when switching between release and debug builds.
  25. Remy Lebeau

    Help to find database error

    REMOVE 'TfrmDatabaseTutorial.' from the DECLARATION! public { Public declarations } procedure ShowSelectResults; // <-- NO TfrmDatabaseTutorial here! end; It belongs only in the IMPLEMENTATION: procedure TfrmDatabaseTutorial.ShowSelectResults; // <-- ONLY here! var headline : TStringList; ... end;
×