Jump to content

PeterBelow

Members
  • Content Count

    508
  • Joined

  • Last visited

  • Days Won

    13

Everything posted by PeterBelow

  1. PeterBelow

    Richedit printing code gets stuck in 11.3.

    Certainly. You can mix direct output to the printer canvas with rendering via EM_FORMATRANGE. By the way: do you know Code News Fast? It is an excellent source for Delphi code examples and it even has all the content of the long defunct Delphi newsgroups on hand. This old post may be a good starting point. By the way: the change in behaviour of your printing code from XE to Delphi 11 may be due to the fact that D11 uses a different version of the richedit common control (4.x) than XE did (2.x). There are suptle differences between these control versions.
  2. PeterBelow

    Richedit printing code gets stuck in 11.3.

    If your text fits into one page it may simply indicate that all text has been printed....
  3. PeterBelow

    Richedit printing code gets stuck in 11.3.

    First thing to do is to get rid of the with statement. That just confuses things. Be explicit, use Printer.Canvas.Handle instead of just Handle. And do you ever start a new page? I do not see a Printer.NewPage in your loop. If I look at the C example code here nextchar <= fmtRange.chrg.cpMin is possible and should be handled as an error.
  4. PeterBelow

    Upgrading from 11.2 to 11.3

    I had a few problems with freezeups or slowdown with 11.3 but they all went away after I deleted all entries for design-time packes related to refactoring and the welcome page (which I never used anyway) from the registry under HKEY_CURRENT_USER\SOFTWARE\Embarcadero\BDS\22.0\Known IDE Packages.
  5. Try to use @TMyForm.DoOnClick instead or @Self.DoOnClick, perhaps that works.
  6. An event reference you need for SetMethodProp is not a simple method address, it is a record of type TMethod, which holds a pair of pointers, the first (Code) is the address of the method and the second (Data) is the address of the class holding the method. You have to construct the value to pass like this, a typecast as you tried does not quite work for some reason: function TMyForm.CreateControl(AClass: TControlClass): TControl; var LEvent: TMethod; procedure SetEvent(const aEventName: string; aMethodAdr: Pointer); begin if IsPublishedProp(Result, aEventName) then begin LEvent.Code := aMethodAdr; SetMethodProp(Result, aEventName, LEvent); end; end; begin Result := AClass.Create(Self); Result.Parent := Self; LEvent.Data := self; SetEvent('OnClick', @DoOnClick); SetEvent('OnKeyDown', @DoOnKeyDown); [...] end;
  7. PeterBelow

    Radio Button and Check Box font color not changing with parent..

    See if the controls you use have a StyleElements property showing in the Object Inspector. This allows you to switch off styling for certain UI elements on a per control basis.
  8. PeterBelow

    search between two dates

    No data to provide any help on, sorry. We need more detail. If your UI view is populated from a database query just use an appropriate condition in the WHERE clause of the query. Most database engines support the BETWEEN operator for dates; just make sure to formulate the bounds using parameters and not date literals (which are sensitive to date formats, locales for client and server, great potential to cause a mess).
  9. PeterBelow

    Setting Font Color on certain controls

    This is the style support at work. You can disable/override it on a control basis using the StyleElements property.
  10. The TGestureEventInfo record does not have a ScaleFactor field, that is the cause of the error you get.
  11. PeterBelow

    App plugins

    The classical way to implement plugins in Delphi is to create packages for the plugins (run-time packages) for which the host app looks in a folder defined in the app's settings or hardcoded to a subfolder of the folder the app itself (the exe) is located in. At startup the app looks for packages (bpl files) in this plugin folder and loads each one in turn via LoadPackage. The package then registers its plugin class in a unit initialization section, for which it calls a method of a class registry singleton object that is implemented in another package that both the app and the plugin packages use (static link). The app then builds the plugin menu from the list of registered plugins. It can also offer an API through such a shared package to allow the plugins to access the host app UI (like the IDE OpenTools API). This is basically the same design the RAD Studio IDE itself uses to load components. The main drawback is that you need to build the app itself with run-time packages for the run-time library and the VCL (or FMX if you use that for the UI). This makes sure app and plugins use the same memory manager and other RTL and VCL/FMX classes but it complicates distribution of the app, since you also need to distribute the required run-time packages. It gets worse if you use 3rd-party components in app and plugins since you also need to install the run-time packages for those. Any class to be shared between host app and plugins has to be implemented in a run-time package this way. With this design you do not need to change the host app to make it use a new plugin, just copy the new plugin package to the app's plugin folder and it will be loaded on next app start.
  12. PeterBelow

    Form Creation

    Depends on where you do this check and where you free the form1. If you let the IDE autocreate the forms you add to the project then the first form you add will become the main form and closing it will terminate the application. If you need to show some form before the main form is created you have to edit the project DPR file. The typical scenario is a login form shown before the main form is even created. The DPR file then has to look like this: uses ... list of data module and form units {$R *.res} begin Application.Initialize; Application.MainFormOnTaskbar := True; ... Application.CreateForm calls for datamodules the login form may need if TLoginForm.Execute then begin Application.CreateForm(TMainForm, MainForm); ... more CreateForm statements for autocreated stuff Application.Run; end; end. TLoginForm is not autocreated, the Execute method is a public class method that internally creates an instance of the form and shows it modally, then gets any required user input from the form and stores it elsewhere if needed (e.g. in a datamodule or settings store). The Execute method is a function returning a boolean that returns true if the login was successful and false if it failed. This way the main form is not even created if login failed.
  13. The first thing I would try is to delete the DPROJ file (after making a backup, of course) and the open the DPR file for the project (with NO project group open) to force the IDE to recreate the DPROJ file. Unless you have exactly duplicated the folder structure on the new PC the project file may contain references to pathes that do not exist on your new PC. The error message seems to come from one of the layout components, perhaps a TGridPanel. If you get it when creating a new VCL project with an empty form it has to come from the IDE itself, perhaps from a loaded 3rd-party package or expert.
  14. PeterBelow

    Delphi Professional Database Connectivity

    FireDAC is available in the Pro edition, but the licence does not allow connection to server databases, only to local ones, as far as I remember. So you can use a local Interbase DB, for example but not write a program intended to allow multiple users to access an Oracle server, for example, if you access it via FireDAC. But there are other options, like using DbGo (OLE DB, for which you need to get the appropriate drivers for the target database from elsewhere, e.g. Microsoft) or 3rd-party solutions.
  15. PeterBelow

    Local variables broken when debugging .obj files?

    The obj files do not contain debug information so the IDE debugger is unable to work fully while the execution is inside code from the obj file.
  16. PeterBelow

    Can anyone spot the errors?

    Char (singular) is an ordinal type and can thus be used as index for an array but a string is not an ordinal type. The compiler will convert a single char to a string if required, e.g. if you assign a value/variable of type char to one of type string, but not vice versa. Even a string consisting of only a single character cannot be assigned directly to a variable of type char.
  17. PeterBelow

    Can anyone spot the errors?

    Char can be used as an index, but string cannot. Don't be confused by the fact that the syntax for declaring char and string literals is the same.
  18. Try to pass SW_HIDE as the last parameter.
  19. PeterBelow

    Label: Dashed Line Flow (animated) possible?

    Has it to be a label? Perhaps a TProgressbar would do in your case...
  20. You can use the post-build event in the project options to run a program after the project has been build, perhaps that satisfies your requirement.
  21. PeterBelow

    for i := X to Y inclusive... how?

    I see no other way to do this for vertical walls, since the memory locations of the pixels in question are not contiguous if the storage used has the typical bitmap layout. But you may be approaching the whole problem the wrong way. Instead of working directly with the bitmap image of the rendered scene you should build the scene as a list of objects, each of which represents an element of the scene. In this case the vertical wall would be one such object, storing its location and dimensions internally. You then walk over the list of objects and test whether the point (X,Y) falls inside such an object. This search can be sped up considerably by storing the objects in a tree or list sorted on coordinates. I have never worked in this area myself, but it is a common problem in game design, there should be plenty of literature around on the subject.
  22. PeterBelow

    for i := X to Y inclusive... how?

    That makes no sense, a variable can only have one value at a time. Of course it may be a complex "value", like an array or set, but that does not seem to be what you want.
  23. PeterBelow

    Assign KeyDown function to btnClick

    Just set the buttons Default property to true, it will then automatically "click" when the user presses Enter/Return and the active control does not handle the key itself. No code needed...
  24. PeterBelow

    TValueListEditor how to catch exception when key exist?

    Try to handle the OnSetEditText or OnValidate events.
  25. Basically you have to enumerate all classes defined in the application and check their classname and ancestry to find one that matches the criteria you pass to the function. So it is misnamed: it does not creaste a class, it searches for one and returns it. The enumeration can be done using the advanced run-time type information support provided by the System.Rtti unit. You start with a variable of type TRttiContext, which has a GetTypes method to enumerate all types that have advanced RTTI info available. You check with the individual types IsInstance property whether it describes a class type, use the AsInstance property to obtain a TRttiInstanceType and use its methods and properties to examine the class to see whether it matches your criteria. There are two drawbacks to be aware of: RTTI generation can be disabled for individual units or even the whole application through compiler switches ($RTTI), so may not be available for 3rd-party classes you use, and RTTI can be used to examine the compiled executable and thus be considered a security risk. If you need this funktionality only for a limited set of classes it may be better to just create your own class registry and register all relevant classes in it in the initialization sections of the relevant units.
×