"Disabling" code-folding

Code-folding was introduced into Delphi 2005, and is a means whereby sections of your code can be "collapsed", eg from this:

Code Expanded

to this:

Code collapsed

Code-folding is switched on by default, and there appears to be no way to turn it off permanently.  For those (like me) that never use it, this can be annoying, especially when you click the node to collapse code when you wanted to click elsewhere in the gutter, or you just want to have a few extra pixels of space in your editor.

The hot-key sequence for turning off code-folding is Ctrl-Shift-K-O (KO.. knock-out.. stands to reason) . Unfortunately this doesn’t turn it off permanently as it is not saved between sessions. Fortunately, the setting *is* saved in desktop settings, so if you turn off code-folding and then save the desktop (View|Desktops|Save desktop…) the setting will persist for that desktop. That means you will need to turn it off in each desktop you want it saved to, and save that desktop, too.

Thanks go to Alexander Tereshchenko for the suggestion, which he made in CodeGear’s newsgroups.

Posted by Dave Nottage on September 15th, 2008 under Uncategorized | 2 Comments »


Taskbar/Task Manager/Vista issues in applications built with Delphi 2007

There has been a bit of discussion in the CodeGear newsgroups recently regarding some issues to do with applications built with Delphi 2007, and how it affects appearance on the Windows taskbar, the task manager list, and Vista.

Some solutions suggest making some modifications to Forms.pas, however this doesn’t help those like me who build a number of applications using runtime packages.

As soon as I was aware of the issues, I set about finding the solutions, and like some people, found the newsgroups a valuable resource. I also needed to do a little experimenting in order to make things behave as they should, and the following is the result.

When creating a new application in Delphi 2007, the following appears in the project source:

program Project1;

uses
  Forms,
  Unit1 in ‘Unit1.pas’ {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

Note the new
MainFormOnTaskbar property of the Application object. This means that what you see on the taskbar is the icon and caption of the main form (when it appears). So how about if you have a splash screen, like I often use, and if the splash screen is created and shown before the main form is even created? eg:

  Application.Initialize;
  Application.MainFormOnTaskbar := True;

  frmSplash := TfrmSplash.Create(nil);
  frmSplash.Show;
  frmSplash.Update;

  Application.CreateForm(TfrmMain, frmMain);

  frmSplash.Free;
 
  Application.Run;

Without further modification, when the application runs and the splash screen is showing, there is no window on the taskbar. To solve this, I override the CreateParams method of TfrmSplash:

procedure TfrmSplash.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.ExStyle := Params.ExStyle and not WS_EX_TOOLWINDOW or WS_EX_APPWINDOW;
end;

This causes the a window to appear in the taskbar. That solves one issue, however it raises another: there’s no caption in my splash screen, and therefore no caption in the window on the taskbar, so I set the application title in the project options, and override the Create method in TfrmSplash:

constructor TfrmSplash.Create(AOwner: TComponent);
begin
  inherited;
  // Fix the taskbar/splash issue
  Caption := Application.Title;
end;

Note that changing the application title in the project options will insert the line just before
Application.CreateForm, so I move it to just before the call to Application.MainFormOnTaskbar := True so that the splash screen has the right value for the title.

Now we have a window appearing in the taskbar, and it has a caption, however there is one more issue: under operating systems prior to Vista, the application doesn’t appear in the task manager applications list. The solution is to make the following call:

  if (Win32MajorVersion < 6) then
    SetWindowText(Application.Handle, PChar(Application.Title));

I could add the call to , however if I chose to remove the splash screen and just use the main form, I’d end up with the same problem. Since I’ll always be using the main form, I add it to TfrmMain.Create:

constructor TfrmMain.Create(AOwner: TComponent);
begin
  inherited;
  Caption := Application.Title;
  // Fix the task list issue for non-Vista
  if (Win32MajorVersion < 6) then
    SetWindowText(Application.Handle, PChar(Application.Title));
  // Simulate the app doing something while the splash screen is showing
  Sleep(6000);
end;

There was another issue under discussion, which is the appearance of the application in the taskbar thumbnail and Flip3D. Unfortunately, I don’t have an Aero-capable PC with Vista installed at the moment.

Full source for the example application is available here.

Posted by Dave Nottage on April 3rd, 2007 under Delphi stuff | Comment now »


try except madness

..or should I say “try and accept some madness”?

Today I came across this little gem inside of a CloseQuery event handler of a form:

  try
    CanClose := bIsInitialisationsOver;
  except
    on E: Exception do
    begin
      WriteErrorToLog(’Error.Exception - ‘ + E.Message);
    end;
  end;

CanClose is a boolean variable that is part of the handler. bIsInitialisationsOver is also a boolean variable. One just has to question what some people are thinking when they feel they need to capture an exception of assignment of a boolean to another boolean. Incidentally, this wasn’t an isolated example; there were other instances of similar coding style.

Posted by Dave Nottage on January 23rd, 2006 under Delphi stuff | Comment now »


Going forward

What is it with using the phrase “going forward”? You’ll hear a lot of execs (and maybe even some non-execs) use the phrase in relation to their business plans, but what is the point of saying it? I wouldn’t expect anyone talk about their business plan in relation to doing something that is “going backward”.

Enough of the digression, let us (going forward?) talk about our favourite subject: Delphi :-)

Working on this project in Singapore, I had reason to look for UTC related functions in the VCL, and I came across the file SvrHTTP.pas. It has some rather interesting declarations in the implementation section, including this one:

function LocalTimeToUTCTime(DateTime: TDateTime): TDateTime; forward;

Note the forward directive. There are several declarations like that, that follow the one above. It reminded me that I haven’t seen the forward directive used in ages. These days it seems there’s not much use for it, because you can just declare a method that is called by another method, prior to the declaration of the caller. In the case of SvrHTTP.pas they could have done just that, so it is puzzling as to why they bothered to use forward.

There is a case for using forward, however. From the help:

  “Besides letting you organize your code more flexibly, forward declarations are sometimes necessary for mutual recursions.”

..and for those who are wondering, mutual recursions does not mean swearing at each other. :-)

Posted by Dave Nottage on January 20th, 2006 under Delphi stuff | 1 Comment »


Initialization, where are you?

Working on this project in Singapore, I came across something similar to this:

unit SomeUnit;

implementation

begin
 
DoSomeCodeHere;

end.

No, it wasn’t exactly the code above; it’s just to illustrate that I had forgotten this was possible. So how does Delphi treat the above code? The answer in BDS 2006 is that the code is compiled as an initialization section.

There’s some discoveries I’ve come across that I’m going to share later..

Posted by Dave Nottage on January 12th, 2006 under Delphi stuff | 2 Comments »


Software Installers part 2

Well it has been a while since I started using it, however I thoroughly recommend InnoSetup.

I also recommend using ISTool to at least create scripts (easy enough to edit with a text editor later). It can be downloaded via links from the InnoSetup site.

Posted by Dave Nottage on January 11th, 2006 under Software development | Comment now »


Just what do you think you’re doing, Dave?

I’m asked that question quite often ;-) In this case, I’ve started a new blog. I’m keeping a blog separate from my TeamB blog, as I didn’t want to pollute this one with my general ramblings. I’ll stick to subjects about Borland, Delphi, and programming in general on this blog.

Posted by Dave Nottage on January 11th, 2006 under General | Comment now »


Software installers

Software installers.. There seems to be a huge gap between the commercial and well.. the other end of the scale. I‘ve tried a few and that’s at least the impression that I have.

Borland Delphi 7 ships with InstallShield Express (Borland Limited Edition) v3.5 Service Pack 4. As far as I’m concerned, it’s great.. for the most part. It allows you to easily (and mostly intuitively) create install programs for your software. No messing with install scripts where you have to learn the install script language.

Problem number 1 is that the installer it creates won’t do updates, ie if you create an installer for a later version of your software, the users must uninstall the previous version first. Problem 2 is that XP SP2 breaks the registry modification section. You can’t create installers that create or modify registry settings, and there appears to be no fix for this.

I’ve also worked with InnoSetup. I can’t understand why some think it’s so great. Don’t get me wrong; if you’re into learning install script language, it is a great tool, but to my mind, creating install programs should be relatively painless. Same goes for NSIS (from NullSoft), which I’ve just started using. It seems to be the easier of those two to learn, but it’s still a pain to learn the script language.

Shouldn’t creating install programs be (close to) this easy?:

Select the files that are to be installed, the destination(s) to which they are to go to, write some configuration settings, select some fancy install splash screens, and that’s about it. If the install program creator wants to create a script, it can do so, which can be “tweaked” if necessary.

Perhaps I just haven’t looked hard enough.. someone please tell me I’m wrong! Meanwhile, I’m sticking with NSIS and contemplating writing a script wizard for it.

Posted by Dave Nottage on November 22nd, 2005 under Software development | 5 Comments »


TeamB meeting note: Distinctions between CoreSDP and BDS

Every year, some TeamB members have meetings with Borland staff, and today included meetings with some Borland execs.

One of our meetings was with Boz Elloy, Senior Vice President of Software Products, and a subject we talked about was what Core SDP is, and why Delphi isn’t included in it. He advised that what he said is public knowledge, so we (TeamB) have permission to repeat it, so here it is:

Core SDP (Software Delivery Platform) is a product aimed at enterprises, typically companies that have more than 20 developers, however that number can, and is, sometimes much larger. Core SDP comprises tools for Enterprises, and it embeds products such as CalibreRM server, and StarTeam server. Core SDP can’t exist without these. The development platform in Core SDP is Java, and there are plans to include .NET development, but not Delphi for .NET because, we were told, Enterprises don’t choose Delphi for .NET.

At the same time, BDS ie Borland Developer Studio, which includes Delphi, Delphi for .NET and C#Builder, and integrates Together, CalibreRM and StarTeam, is aimed at to SMB’s (Small to Medium Businesses). SMB’s typically have less than 20 developers, however of course that number can be larger.

That’s all I have for now.. stay tuned later for any other news that I can divulge.

Posted by Dave Nottage on November 12th, 2005 under Delphi stuff | 4 Comments »


DevCon environment update and other misc stuff

Fortunately, the lab problem has been resolved, with power strips and extra desks being provided.. Thanks Borland and support staff! Unfortunately, the issue of repeat sessions lingers, with some lamenting that they were not able to make sessions (including myself) and absolutely no repeats were available.

Considering the circumstances, this has been a good DevCon. As above, Borland and support staff have been great. The repeat sessions issue is probably something that can be ironed out for next year, and a little birdie tells me that the Camtasia recordings of sessions may be available to (at least) attendees on DVD later. I especially look forward to reviewing the ASP.NET sessions, if possible.

My apologies for not providing blog entries for sessions I attended today and for the WPF session yesterday afternoon. I had some issues to deal with, including lack of sleep.

On a brighter note, I can again recommend for anyone who liked the movie Saw, to go and see Saw 2. The more I think about it, the more I liked it; it’s a great follow up to a brilliant movie, though probably not for the squeamish :-) Someone (I can’t remember who, but thanks) mentioned if you liked Seven, you’d like these movies.. and I tend to agree.

Since it’s 3.35am (aka 10.05pm in my home town), I’ll be signing off for now til later this morning.

Posted by Dave Nottage on November 10th, 2005 under DevCon 2005 | 1 Comment »



Server Response from: BLOGS2

 
Copyright© 1994 - 2010 Embarcadero Technologies, Inc. All rights reserved. Contact Us   Legal Notices   Privacy Policy   Report Software Piracy