How does TMemo handle the enter (CRLF) issue on Mac? - delphi

This is related to a previous question: TMemo cannot handle Unix text (LF as line ending) correctly.
On Delphi XE, TMemo can only handle Windows formatted text (CRLF as enter).
For example this text:
test1+ LF+ test2
is treated/shown as a single line of text: test1test2
instead of:
test1
test2
I realize this is a bigger problem so I am curious how/if they fix this problem in Delphi XE2 (which I think has Mac support). There is a property similar to TMemo.Lines.TextLineBreakStyle (Lazarus)?
(I only own a Delphi XE license.)

As David says, Mac applications in Delphi are only supported using the new FireMonkey framework, as opposed to the VCL controls in previous versions of Delphi. You can still use VCL in XE2 (and later), but only for developing Windows applications. FireMonkey can be used for developing both Mac and Windows applications.
FireMonkey has a memo control, just as the VCL does, and this also has a Text property, so this line of code would be perfectly valid in both a VCL and a FireMonkey (FMX) application:
Memo1.Text := 'Line 1'#10'Line 2'#10'Line 3'#13#10'Final Line';
Where Memo1 is a VCL or FMX Memo control.
However, the VCL control (as of XE4 at least) still does not properly support the #10 (LF) line breaks, but the FMX control does, on both Windows and Mac so although the code above can be used in both VCL and FMX applications, the results will be different.
In VCL (Windows) you will get the following content in the memo:
Line 1Line 2Line 3
Line
Where as with FireMonkey on Windows and/or Mac you will get:
Line 1
Line 2
Line 3
Final Line
So the answer is that FMX behaves differently than the VCL and respects both #10 and #13#10 line break sequences, irrespective of platform where-as the VCL memo behaviour remains unchanged and is only supported on Windows.

Related

Can we use Popupmenu in FMX?

I am developing a mobile app in FMX where i need Popupmenu but it is showing disable in Tool Palette i cant use it but in VCL its enabled in Tool Palette and can use it. I just want to know if Firemonkey supports Popupmenu or my installation is having problems or we have to use other tools instead of Popupmenu in FMX? or what else can I do?
and actually i opened one VCL project and copied popupmenu from there to FMX and wrote code on one button and that code is
procedure TFRM_Party.BTN_Party_OptionClick(Sender: TObject);
begin
PopupMenu1.Popup(10,10);
PopupMenu1.Parent := Self;
end;
this code is not showing any error and also not performing also.
what to do? anybody having idea?
The short answer to your question is "Yes", you ought to be able to use the FMX version of TPopupMenu in a project created from File | New |Multi-Device Application in the IDE. If you can't find the FMX TPopupMenu on the Component Palette, something must be wrong with your Delphi install. I'm not quite sure what you mean when you say that it's "disabled" - components are usually either on the Component Palette or not, I don't recall seeing one looking disabled there.
You don't say in your question which version of Delphi you are using, but if it has FireMonkey at all, AFAIK it definitely ought to have the FMX version of TPopupMenu.
In Delphi 10.2 Seattle, for example, the FMX TPopupMenu appears on the "Standard" tab of the component palette, and is contained in the source unit FMX.Menus along with TMenuBar and TMainMenu, amongst others.
If you go to Component | Install packages in the IDE, the pop-up should show Embarcadero FMX Standard Components in the list, which is the file dclfmxstd250.bpl in the bin folder of your Delphi install. If that package isn't listed, that explains why you can't find the FMX TPopupMenu, but if that's the case for you, your Delphi ought to be lacking a lot more FMC components besides TPopupMenu. However, it should be easily solved by installing the .bpl file (or equivalent in your Delphi version). If the package is there, clicking the Components button to the bottom right of the pop-up should bring up the entire list of FXM standard components (which in my case does include TPopupMenu).
If your Delphi does include the Embarcadero FMX Standard Components but is still lacking TPopupMenu, you might try creating a new Package, adding FMX.Menus.pas to it and compiling and installing it in the IDE.
BTW, although it is possible to set up a combined FMX + VCL project (Google for how), just because you might be able to put a VCL TPopupMenu on an FMX Form doesn't mean that it's going to work.
Components are Grayed if you can't use its on current OS(your current choice in top combobox)

How to convert TStringGrid from Delphi 7 to Delphi XE

Just for test how hard to convert my Delphi 7 program to Delphi XE 5 i wrote simple application on Delphi 7 - placed TStringGrid on Form, and added code on form create:
procedure TFMain.FormCreate(Sender: TObject);
begin
With StringGrid1 do
begin
Cells[0,0]:='čęжэ€';
end;
end;
(actually it wrote as Cells[0,0]:='ce??€', but i expected that). Compile, build, run, no Unicode, of cause. Then reopened project in Delphi XE 5, changed line again to Cells[0,0]:='čęжэ€', compile, build, run - and no Unicode (got something like čę|||) ! That was strange to me. New project build from zero on Delphi Xe 5 with the same code, same TStringGrid is working as expected. I know here is some simple trick, maybe some change in project settings, but i can't google it... Maybe someone can help ?
Best regards.
The default font used by Delphi 7 is MS Sans Serif. When you use this font under Unicode Delphi, the string grid control appears not to draw text correctly with that font. Many other controls will draw your text correctly in that font. But for some reason the string grid control cannot manage to do so.
When you upgrade an old project to XE5 you inherit that Delphi 7 default. When you create a new project in XE5 the default font is different, Tahoma I think, and the string grid painting correctly shows your Cyrillic in that font.
You can work around this problem by using a different font like Tahoma or Segoe UI. You surely don't want to be using MS Sans Serif anyway. A list view in report view style would be another good option. Not least because it is the native platform control.
I must admit that I do not really understand why the string grid control is not behaving better. It would be great if somebody else could shed some light on this.
As David mentions, the issue is the font used in your string grid. However, it is not strictly accurate to say that the default font in Delphi is MS Sans Serif. It used to be MS Sans Serif but was changed (in Delphi 2006) to Tahoma.
You can see how a particular version of Delphi chooses the default font by inspecting the source of the Graphics unit in the RTL source of that particular Delphi version (since the IDE is built using that code). Specifically the InitDefFontData procedure (and, in older versions of Delphi, the DefFontData record).
As of (at least) Delphi XE4 the default Tahoma font will be replaced by any setting for a font substitution for a value identified as MS Shell Dlg 2, as set in the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes\
NB - from inspecting the code in XE4 it is possible that if this key does not exist or cannot be accessed, or if there is no substitution entry for MS Shell Dlg 2 font, then MS Sans Serif will still be used. It is hard to tell since this is the behaviour when "CLR" is defined, which should not be the case any more since Delphi no longer supports .NET and the IDE is presumably not compiled with CLR defined, but there is no way to be certain simply from inspecting the code what conditional defines might be applied when the IDE is compiled.
However, whichever font the IDE is using and however it is choosing that font, this affects only new forms created in the IDE.
For existing forms, as in this case, the issue is not with TStringGrid as such but rather the fact that you created the project in a version of Delphi which applied a default font which did/does not support Unicode.
The act of opening the project in the newer version of Delphi did not change the font used in your form(s), so the form saved in Delphi 7 using the MS Sans Serif font is still using that font when opened in Delphi XE5.
The TStringGrid control is then using the MS Sans Serif font because this is the font set on the form, and the default for controls on a form is to use their parent control font.
i.e. This specific instance of TStringGrid is using MS Sans Serif because the form on which it is placed is (still) using MS Sans Serif.
In such cases you should change the form font to Tahoma or a. n. other suitable, Unicode enabled font.
All controls on the form still set to use their parent control's font will then adopt this font also. When performing this on an actual application you may find some controls with ParentFont set FALSE which will need to be addressed individually and that even where font settings are being "inherited" your form designs may need further work to tidy things up due to changes in appearance resulting from the change of font.
Note that even this change to Tahoma has been overtaken by changes in Windows itself, and if you wish to apply some other default font (in new forms/projects) you may find useful information here.

Delphi Xe2 VCL style and webbrowser

Win7 x64, Delphi Xe2 update2
Prompt:
The new project, compile as x32, are applied visual (vcl) styles in the project options, by default one is chosen
On the form the button1 and WebBrowser1
In the button we write WebBrowser1.Navigate ('http://google.com');
We start, we press the button - in a browser we see a site google.com, all ок
We compile as x64, it is started ок, by button pressing we receive an error "float division on zerro".
Questions:
At all so (error)? And as with it to struggle? (in x64 mode)
How to apply visual style to strips of scrolling WebBrowser1? (in x32 mode)
:( a native component could not skin, but AlphaControls Skin system - work ok, and webbrowser scrolling lines skinned normal
p.s. update3 yet did not put
p.s.s. bad english: on
This can be done subclassing the TWebBrowser component and handling these events
OnDocumentComplete
OnNavigateComplete2
OnBeforeNavigate2
OnCommandStateChange
OnProgressChange
plus the WM_SIZE windows message.
The key is use the TScrollbar component and a Twincontrol as container to overlap the original webbrowser scrollbars.
I just wrote an article which explains in depth how this can be implemented Delphi Vcl Styles and TWebBrowser
VCL styles cannot be applied to TWebBrowser AFAIK. Its UI is controlled by Internet Explorer, not the VCL.

Delphi: Win7 side effect with forms

Win7/x64, Delphi 6 Prof.
Win7 drives me crazy with his side effect. I describe it:
When I force the suggestion with Ctrl+Space, or Delphi do this automatically, the Delphi don't show the suggestion dropdown listbox, he is only bring my all opened forms to front, one by one.
This causes that what I typing is not going to editor window: it is going to any property of the active form, of the active control.
For example.
Ctrl+Space+"ShowMes..."
I don't got ShowMessage with suggestion listbox, I type ShowMess into my main form's caption.
Many times I need to make update pack's because the buttons, caption, etc got "ShowMes" or "Excep" or other property, because I type into these windows...
This function is sometimes broken on win7.
May I can restore the normal working mode without "bring all opened form to front"?
Thanks:
dd
You can disable UAC in Windows 7, see here:
http://www.petri.co.il/disable-uac-in-windows-7.htm
Also running Delphi 6 in Windows XP compatibility mode should do the trick.
See this discussion on the embarcadero forums, it's about Delphi 7, but it's the same issue:
https://forums.codegear.com/thread.jspa?messageID=204928&tstart=0
Finally see here how to run a program in XP compatibility mode:
See: http://www.w7forums.com/application-compatibility-mode-t314.html
Or: http://www.sevenforums.com/tutorials/316-compatibility-mode.html

How do I get TAnimate's Common AVIs to work on Vista and Win7?

I have a Delphi 2007 application that has a TAnimate control with a FindFile Common AVI. It works perfectly when the application is run on Windows XP, but nothing ever appears on Windows 7. I've heard it now requires its own thread, but I am not certain.
Does anyone know how to get TAnimate's Common AVI control to work on Windows 7 (or Vista)?
You must add the unit ShellAnimations to you project or add the component TShellResources from the Win32 tab of the component palette. (Tested in Windows Vista- Delphi 2007)
uses
ShellAnimations;
this unit adds the following replacement animation resources to your executable:
FindFolder.res
FindFile.res
FindComputer.res
CopyFiles.res
CopyFile.res
RecycleFile.res
EmptyRecycle.res
DeleteFile.res
Bye.

Resources