Add intellimouse support to a TMemo or TRichEdit component - delphi

How i can add intellimouse support to a TMemo or TRichEdit component
i am using Delphi XE

You must set the ScrollBars property to ssHorizontal, ssVertical or ssBoth and add the IMouse unit to your project.
UPDATE
To avoid the memory leak caused by the IMouse unit you must add this code before you application exit (for example in the finalization part of your main unit).
if Assigned(Mouse.PanningWindow) then
Mouse.PanningWindow := nil;

Related

Delphi 11 TShellTreeView causes access violation on Win64 platform at application startup

TShellTreeView component in Vcl.Shell.ShellCtrls unit causes an access violation in TWinControl.DefaultHandler() on Win64 platform at application startup when the form initializes.
To reproduce the bug:
Create a new VCL Forms application and put a TShellTreeView component onto the form. Or, alternatively paste this minimal project source into a file named 'ShellTreeViewTest.dpr' and open the project with the Delphi IDE:
program ShellTreeViewTest;
uses
Vcl.Forms, Vcl.Controls, Vcl.Shell.ShellCtrls;
var
Form: TForm;
begin
Application.Initialize;
Application.CreateForm(TForm, Form);
with TShellTreeView.Create(Form) do
Parent := Form;
Application.Run;
end.
Then add platform "Windows 64 bit" to the project.
Compile and run.
I use Delphi 11.1 Alexandria.
The access violation raises only if "Support high-entropy 64-bit address space layout randomization (ASLR)" is enabled in the Project options/Linking tab. It is enabled by default, so the bug is reproducible in Delphi 11.
But in Delphi XE2 there is no such checkbox in the project options.
The AV is caused by the TCustomShellTreeView.FImages field being declared as an Integer; it is initialized by a call to SHGetFileInfo(), which returns a DWORD_PTR. Replacing FImages: Integer with FImages: DWORD_PTR solves the problem.
The TCustomShellComboBox.FImages, TCustomShellListView.FLargeImages, and TCustomShellListView.FSmallImages fields also need to be changed accordingly.

Firemonkey Assign TPanel to TPanel doesnt work XE10.1 Berlin

I'm trying to use assign on a TPanel configured in the designer but it doesn't work.
var
LPanel : TPanel;
begin
LPanel := TPanel.Create(nil);
LPanel.Assign(Panel1); // Panel1 is a panel made in the form designer
end;
The error message is something like "TPanel cannot be assigned to TPanel." (I have the german version of RAD Studio... The exact error message on german is "TPanel kann nicht zu TPanel zugewiesen werden.")
I designed a TPanel with other components in it using the Form Designer. Now I want to add new TPanel instances to a TLayout which should be the same as the TPanel I want to assign from, including all child controls.
Most VCL and FMX components, including TPanel, DO NOT implement Assign() at all. Typically only utility classes that are used for component properties implement Assign() for use in their property setters.
For what you are attempting, you should use a Frame instead of TPanel. You can design a Frame at design-time, just like a Form or DataModule, and then create instances of it at run-time as needed.
See Embarcadero's documentation for more details:
Frames in FireMonkey
Unfortunately I don't currently have access to Delphi to confirm. But it seems Assigning TPanel is deliberately blocked by the framework.
That said, what you're trying to achieve seems more appropriately handled with TFrame
Once you've created your frame, you should be able to use the following code to create a new instance at run-time.
uses
...
frMyFrame;
...
var
LNewFrame : TFrame;
begin
LNewFrame := TMyFrame.Create(nil); //Are you sure you don't want to assign an owner?
LNewFrame.Parent := Self; //Assuming you want to position the frame directly on the form
//Otherwise you could place it on a simple panel.
//Set attributes for positioning
//Don't forget resource management (see ownership comment)
...
end;

Why SendToBack is not working with Delphi XE4

I'm using Delphi XE4 and trying to create 2nd form and set it as a background while the first form is transparent (AlphaBlend = true; AlphaBlendValue = 220)
uses Unit2;
procedure TForm1.Button1Click(Sender: TObject);
begin
Form2.Show;
Form2.SendToBack;
end;
The codes above are working with Delphi 7, but not with Delphi XE4 (Form2 still over on the Form1). Can anyone tell me why the codes are not working with XE4? And how to make it working?
Thanks in advance.
Check the setting of Form2's PopupMode property. It is likely set in a way that cause's Form1's window to become the parent of Form2's window, which would prevent Form2 from moving behind Form1. The PopupMode (and PopupParent) property did not exist in D7, it was introduced in a later version to address z-order bugs that the VCL suffered from in earlier versions.
Read the following blob article for more details:
PopupMode and PopupParent

Problem with Splash Screen in Lazarus app

I am porting a Delphi application to FPC/Lazarus and this application shows info in splash screen. When unit has initialization section then this initialization section calls something like:
Splash.Info(unit_name)
This works in Delphi, but when I compiled this using FPC/Lazarus then I got exception when I create form with splash screen:
Failed to create win32 control, error 1407 : Cannot find window class
I found, that forms can be created after Application.Initialize; was called, so my workaround is to create splash form when ScreenInfo.Initialized=true. It works, but does not show all info. Is there any way to show splash form from unit initialization section, before Application.Initialize;?
Apparantly the FPC/Lazarus implementation of the VCL differs enough from the Delphi VCL to not allow form initialization before the Application object has been initialized.
So the best you can do to make it work in both Delphi and FPC/Lazarus is either
Delay the initialization until you are sure that both the Delphi VCL and FPC/Lazarus VCL are ready for it
Duplicate your code with conditional defines to generate optimum implementations for both Delphi VCL and FPC/Lazarus VCL
--jeroen
In SplashScreen initialization code that is called for every string I want to show on this splash I finished with:
...
{$IFDEF FPC}
if not ScreenInfo.Initialized then
exit;
{$ENDIF}
if not splash_inititialized then begin
SplashScreen := TSplashScreen.Create(Application);
splash_inititialized := true;
...

Empty main form in GUI app converted from Delphi to Lazarus

I have converted my 2 GUI apps from Delphi to Lazarus.
Both apps compile for Win32 platform, i386 and with GUI.
Main form were converted using Lazarus tool and can be edited from IDE.
But when I run such application main form does not appear, only blank form without any controls.
I tried to debug this. It runs all code in initialization sections,
and runs code from .lpr project, but something wrong happens in CreateForm() because
it doesn't run code in the main form OnCreate event. In event log I can see all
texts I write to it with '<App.Run' appearing after I close this empty form.
Code in .lpr project:
Application.Initialize;
AddToEventLogInfo('App.CreateForm');
Application.CreateForm(TfrmTst, frmTst);
AddToEventLogInfo('App.Run>');
Application.Run;
AddToEventLogInfo('<App.Run');
I checked that I am able to create simple GUI apps from the Lazarus, but both converted GUI
apps do not work as expected. What can be wrong? Have I missed something?
Maybe one of many warnings and hints Lazarus write is important?
When I run my app Lazarus writes this:
windres: warning: 14: "MAINICON": 1045: duplicate value
windres: warning: 16: 1: 1045: duplicate value
Project "Tst_fpc" successfully built. :)
EDIT:
Lazarus conversion tool converted .dfm -> .lfm, but has some problems with .pas file. I had to manually:
add Lazarus units to uses:
uses
{$IFDEF FPC}
LCLIntf, LResources,
{$ENDIF}
Conditional compile Delphi form {$R *.dfm}:
{$IFNDEF FPC}
{$R *.dfm}
{$ENDIF}
Add .lrs resource in initialization code:
initialization
{$IFDEF FPC} {$i myunit.lrs} {$ENDIF}
I suspect that the mainform unit (I assume it is called utest) doesn't have a {$I utest.lrs} in its initialization section. The .lrs is the lazarus resource file, created from the lfm (dfm) in delphi.
The empty form is the form of for the current project as you used the convert Delphi project from tools which means the current project is active.
Try this:
On the project option close the current project.
On the small main window named as project wizard, use the convert Delphi project option.
I'm sorry I can't give you a straight answer. From what I understand there's a problem a problem with the resource file. In delphi that's the *.res, I don't know what they look like in Lazarus. Use a program like resedit, http://www.resedit.net/, to open the resource file. I tried it and found a "folder" Icon where there was a post MAINICON. I'm guessing you have two. In that case remove one of them.

Resources