Showing posts with label Berlin. Show all posts
Showing posts with label Berlin. Show all posts

Thursday, 28 June 2018

Delphi features that I was not aware of

The other day I came across a feature of Delphi that in my 18+ years of using Delphi have never used, it is the 'Hide Non-Visual Components' (Ctrl+H) when design a form. I came across this because another Developer pointed out to me that he could not see the menu controls on a form. I thought there might be an option somewhere and on the right click menu was the option.

I have never used this feature and it got me thinking what other features are there that I am not aware of (Delphi Berlin) and are there any that I might use. Here are 2 lists of features I have since discovered, one list is for ones that I think are pointless and I would never use and the other for features that I believe are useful.

Features I've found that I think I will never use:
  1. Quick Icon - right click menu option in the form designer.
  2. Quick Edit - right click menu option in the form designer.
  3. Flip Children - right click menu option in the form designer. I think I'v seen this before, but have never used it and cannot think of when I would.
  4. Lock Controls - main menu > edit. This feature locks some controls on forms from resizing and moving. This feature has strange behaviour as it sometimes locks the resize, but not the ability to move the control, try locking the controls, closing the form and opening it again and the size of the controls cannot be changed but the positions can. Clearly never been through QA.
  5. Scale - main menu option > edit. This gives the developer the feature to scale a form and it's controls be a percentage. 

Features I've found that could be useful:
  1. Surround > Region - right click menu option in the code editor. 
  2. Search for Usages - right click menu option in the code editor.  
This is just a brief list of features that I have found over the last couple of day that I was not aware of, most of which I will never use. There are most likely other features in Delphi I have yet to discover that are of some use. 

Thursday, 21 December 2017

Auto create forms and data modules does not quite work

I've recently moved to Delphi 10.1 Berlin Update 2 from using XE and XE5. One thing that caught me out was that I forgot to turn off the 'Auto create forms and data modules' in the 'Form Designer' options. This setting means that when you add a form or data module to a project it gets auto-created at run-time.



The problem with this setting is that it does not fully work. I have a project where I do not want to auto create any forms or data modules, I have a class that is responsible for doing the initial creation of the required forms and objects, but if I add a form or data module to the project it always gets added to the auto create list in the project. This option assumes you want just one form in the list, once one is added it does not add anymore.

This problem could occur in all versions of XE and the now the more recent versions (DX), I plan to check this with XE and will hopefully soon be updating to the latest version of Delphi.

Tuesday, 25 July 2017

Windows 10 Notification

Here is a quick and simple example of a notification procedure. On a form I added a 'TNotificationCenter' component from the 'System' tool palette.

procedure TForm.DoNotification(aName, aTitle, aBody: string);
var
    appNotification: TNotification;
begin
    appNotification := NotificationCenter1.CreateNotification;
    try
        appNotification.Name := aName;
        appNotification.Title := aTitle;
        appNotification.AlertBody := aBody;
        NotificationCenter1.PresentNotification(appNotification);
    finally
        appNotification.Free;
    end;
end;

procedure TForm.ShowTestNotification;
begin
    DoNotification('Test Name', 'Test Title', 'This is an example');
end;

There is an event in the NotificationCenter component called 'OnReceiveLocalNotification', which is useful if you want to display a notification and when a user clicks on the notification the software performs an operation. 

I did this example in Delphi 10.1 Berlin, it is a very limited example due to Delphi being very limited with what can be done with Windows Notifications. Looking at the documentation you can do more with iOS, I am not sure why they have made it so limited. I have briefly looked at some C# examples and you can do more with notifications like custom sounds, icons, images and actions. 

One thing I have noticed is that when I run this example the notification is shown and then when it goes away it is automatically removed from the action centre. One thing I would require is that if the user does not acknowledge the notification, it should stay in the Action Centre list. For me it would be really useful to have the following:
  • Custom image.
  • Custom sound.
  • FireDate to work in Windows 10.
  • Option for the notification to stay in the Action Centre.

I would like to see Embarcadero expand on what these notifications can do, obviously they are limited to what the OS can do. If they could persist in the Action Centre until clicked then I can think of multiple uses for notifications.  

Monday, 24 July 2017

Delphi 10.1 Berlin fix for issue when opening older project

I recently had an issue with a project that had been updated from XE to Delphi 10.1 Berlin. The issue was when opening the project it could not find some components on the main form (3rd party), however the correct packages are installed and if I started a new project I could add the components from the tool palette without any issues.

One work-around I found was having adding these components to another project, then when I opened Delphi 10.1 Berlin I opened this project and then closed it before opening the project that had problems with the components, and it all worked fine.

In the end the solution I found was the following:

  1. In the package itself, find the unit with the 'Register' procedure.
  2. Check 'DesignInf' is in the uses clause.
  3. At the top of the 'Register' procedure add 'ForceDemandLoadState(dlDisable);' 
  4. Install the package again.
What this does is disables the IDE from using the smart loading of installed packages, this means when the IDE starts it always loads the installed packages.