Sunday, May 13, 2012

Plan Ahead When It Comes To FireMonkey & iOS

I don't intend to move to XE2 or XE(next) anytime soon, I have my hands full just porting over my old applications from D5 to D2010. However, I would like to take advantage of FireMonkey and the iOS market when the time is right so I'm planning ahead and so can you.

I am currently working on adding Inifile support to my application to keep track of window sizes and position. I asked on StackOverflow if FireMonkey has anything similar to GetSystemMetrics. Whiler posted a snice snippet of code that uses FX.Platform. (Merci Beaucoup Whiler)

My first thought was it's too bad I can't use this piece of code today. Then I had one of those aha moments. I thought to myself,
"Why not add this as a comment in your Delphi code."
So that's what I did.

Begin Code Snippet
FireMonkey Consideration:
Question asked on stackoverflow:
I'm rewriting an old application using Delphi 2010 and I'd like
to put placeholders in my code for when I port it over to XE2.
Just curious if FireMonkey has an equivilent to GetSystemMetrics.
I'm specifically interested in:

If you just need the main monitor size, and not the desktop size
(n monitors sum), you can use this:

uses ..., FMX.Platform;

var   p: TPointF;
  p := Platform.GetScreenSize;
  ShowMessage(Format('X: %f' + LineFeed + 'Y: %f', [p.X, p.Y]));

From: Whiler
unit IniFileStuff;


  Windows, SysUtils, Forms, IniFiles;

  TScreenType  = (MainScreen, PreviewScreen);

Procedure InitializeIniFile();
Procedure ResetScreenSection(ScreenType:TScreenType);
Function WindowStateToInt(WSType:TWindowState):integer;
Function IntToWindowState(WSInt:integer):TWindowState;
End Code Snippet

So, even though I'm not using FireMonkey today, I've documented my code so when I do go to use FireMonkey I'll have a decent head start.

Don't keep it - Pass it on.
Semper Fi - Gunny Mike


  1. Plan ahead for iOS... learn Objective-C and Cocoa.

    I have heard rumours that all is not well in the FireMonkey enclosure at the Embarcadero Zoo. You might not want to be relying on it for any serious future non-Windows plans you may have right now.

  2. I would be interested in hearing those rumours as well. They would surprise me! Firemonkey is not yet perfect, but in general I think it's a good framework...

  3. Don't care about rumors ... Firemonkey is Firemonkey and companies are companies. The quality of Firemonkey is not the point I think, maybe Apple, maybe budgets, maybe changes people organization ... who knows.

    All in all, if someone builds apps on iOS and Apple is well known for lock in consider wisely.