Thursday, January 26, 2006

Converting a MDI form to SDI

In the Form itself:
  1. Change FormStyle property to fsNormal;
  2. Change Visible property to False;
  3. Remove the line "Action := caFree;" from OnClose event;
  4. Change property Position to poDesktopCenter or something else (optional);
  5. Override CreateParams to add extra funcionality, like make it have a button on taskbar or make it become indepent from the main form (optional);

In the caller Forms:
  1. Change "Application.CreateForm(FormClass,FormName)" to FormName.Show;

In the Project Options, tab "Forms":
  1. Move the Form from "Available" list to "Auto-create" list (if needed);
That's it.

Tuesday, January 17, 2006

MDI x SDI

My project has several MDI forms. Right now I'm studying the conversion of all MDI forms to SDI, not only because Lazarus does not support MDI, but also for usability issues. I've read several sources basically stating that MDI is harmful - and for what I see in daily basis, I agree. Here I quote Joel Spolsky (from the www.joelonsoftware.com site):

Here are the usability problems people have with MDI:

* They accidentally minimize a child window, e.g. by double clicking it's title bar, and don't know what they've done. Then they think the other windows are lost.

* They get into a state where the child windows are not even visible because the main window is too small or scrolled away, and don't know what they've done. Then they think the window is lost, and choosing it from the Window list does nothing.

* They close the app when they meant to close a child window because the X's icons are so close.

There are a whole range of other pathologies. Programmers are very logical people and understand MDI quickly. Most end users just don't get it and usability on these apps is terrible.

Joel Spolsky
Wednesday, January 16, 2002

What can I say? He's damn right: been there, done that. Porting my project to Lazarus will be a hell of a excuse to get rid of MDI for good.

Wednesday, January 04, 2006

FPC 2.0.2 and postgresql3dyn

The Win32 binary installation of FPC 2.0.2 does not have the postgresql3dyn unit. This unit is not needed in order to compile Lazarus itself, but it IS needed by sqldb. Once Lazarus needs the FPC sources for some features, and most people have them, it's easy to solve this problem.

Considering the FPC binaries AND sources are in C:\FPC\2.0.2:

1. mkdir C:\FPC\2.0.2\units\i386-win32\postgres
2. cd C:\FPC\2.0.2\packages\base\postgres
3. make
4. copy units\i386-win32\* C:\FPC\2.0.2\units\i386-win32\postgres

Thanks giantm from #lazarus-ide channel for the help. If the step 3 does not work, probably the Delphi's make is being called instead of GNU's - if Delphi was installed BEFORE Lazarus, its bin directory is in Windows PATH environment variable. To solve it, I renamed make.exe from Delphi to make_delphi.exe; other way to do the same is using:

3. C:\FPC\2.0.2\bin\i386-win32\make.exe

As usual, YMMV.