Friday, April 24, 2009

Task Manager needs the GPU



Here is a screen capture of the Windows 7 Task Manager. I would really like to see a graph of the GPU. The ATI utility has something like what I'm asking for, but I've got NVIDIA video cards. Anyway, just my little wish for the day.

Wednesday, April 8, 2009

Google Chrome



I've been using Google Chrome since it game out and I really like it.

I like how you can drag the tabs around easily and create a new window by just dragging the tab off the window.

I like how each tab is run in it's own process.

I like the performance.

I find the user interface a little unconventional but it works. The simplicity of it is really nice.

I like the search at the top vs at the bottom like Firefox.

Thursday, April 2, 2009

Delphi Tips and Tricks: Quickly Switching Between Chunks of Code

I learned this trick from Chuck Jazdzewski so it's a goodie but oldie and real simple.

If you are working on two chunks of code that you need to go between you can use a comment like this:


{Exit(0); //}Exit(1);

Remove the first curly brace and instantly and easily your code changes:
  
Exit(0); //}Exit(1);

There is also a version of this for C++:

//*
return 0;
/*/
return 1;
//*/


Remove the first slash and instantly and easily your code changes:

/*
return 0;
/*/

return 1;
//*/

April Photos of the Month

I've been really bad with posting photos of the month lately so I'm going to post two. These are from Nā Pali Coast State Park on the island of Kauaʻi near the wettest spot on earth, Mount Waialeale.







These were taken with a Canon G10.

Tuesday, March 10, 2009

Delphi Performance Tip

Here's a small little Delphi performance tip that I'm not sure many people are aware of. Putting the $EXTERNALSYM after the symbol has better compiler performance than placing it before the symbol. The reason for this is pretty simple. When the compiler encounters a $EXTERNALSYM it looks for the symbol. If the symbol isn't found then it must be stored and dealt with later. If the symbol is found it is used immediately.

Here's a small example:


const
MAPVK_VK_TO_VSC = 0;
{$EXTERNALSYM MAPVK_VK_TO_VSC}
MAPVK_VSC_TO_VK = 1;
{$EXTERNALSYM MAPVK_VSC_TO_VK}
MAPVK_VK_TO_CHAR = 2;
{$EXTERNALSYM MAPVK_VK_TO_CHAR}
MAPVK_VSC_TO_VK_EX = 3;
{$EXTERNALSYM MAPVK_VSC_TO_VK_EX}
MAPVK_VK_TO_VSC_EX = 4;
{$EXTERNALSYM MAPVK_VK_TO_VSC_EX}

Tuesday, March 3, 2009

Happy Square Root Day!

I hope everyone is having a happy Square Root Day.

I have a photograph of a square root in Costa Rica but my photo library isn't available at the moment.

Friday, February 20, 2009

Delphi Live!




I just opened up a poll (you can view it on the sidebar), to see how many readers of this blog will be attending Delphi Live! I'll be there at least one day giving talks and milling around.

Thursday, February 19, 2009

New Embarcadero Website for All-Access



All-Access was launched yesterday and the Embarcadero website got a nice looking face lift. I feel like we are a whole lot hipper than before. It looks like we are a bunch of rock stars! Or we are going to start selling iPods.

The halls are buzzing with excitement with All-Access. This really is the tool chest for developers. It won't appeal to everyone but the people it does appeal to will really like it.

Saturday, February 14, 2009

Happy Valentines Day



Happy Valentines Day everyone. Oh, and Happy 14th Birthday Delphi!

Tuesday, February 3, 2009

Windows 7 on Mac

I've been running Windows 7 under VMWare Fusion on my Mac Pro without a problem for a few days now. VMWare doesn't give you the option for Windows 7, but choosing Vista from the install wizard worked just fine. I do run into one issue. When running Windows 7 and I eject the DVD-ROM drive with the eject button on the keyboard, the same button should suck the drive tray back in but it doesn't.

I think Windows 7 will be what Windows 95 was to Windows 3.1. The rumor mill has it that Windows 7 will ship before the August timeout date of the public beta. The beta is so rock solid it wouldn't surprise me.

If anyone is having any Windows 7 issues with Delphi 2009 or C++Builder 2009 please post a comment. I've been running without a hitch.

Friday, January 30, 2009

Delphi Object Inspector Tip of the Day

Did you know you can incremental search in the Object Inspector? Focus any item in the object inspector with your mouse or F11, press Tab the cursor will be brought to the name side of the object inspector, start typing, then press Tab again and the cursor will be back on the value side of the Object Inspector. Yeah, it probably should be more obvious.

Working with IStream in Delphi

At some point you might have to work with IStream. They are never fun to work with. Especially since you can't insert into a stream without overwriting. But that's streams.

I like to use the VCL wrappers, TOleStream and TStreamAdapter, and then use TMemoryStream. Use TOleStream to wrapping up an IStream making it look like a TStream and then use TIMemoryStream to make the TMemoryStream look like an IStream again.

Let's say for some reason we get a UTF-8 stream that needs to be saved as a file but it has no BOM. Here's a small example of how to add a BOM to the stream using Delphi:


uses ActiveX, AxCtrls, Classes;

function AddBomToStream(const Stream: IStream): IStream;
var
Bom: TBytes;
OleStream: TOleStream;
MemoryStream: TMemoryStream;
Temp: Largeint;
begin
if Stream <> nil then
begin
MemoryStream := TMemoryStream.Create;
Bom := TEncoding.UTF8.GetPreamble;
MemoryStream.Write(Bom[0], Length(Bom));
Stream.Seek(0, STREAM_SEEK_SET, Temp);
OleStream := TOleStream.Create(Stream);

try
MemoryStream.CopyFrom(OleStream, OleStream.Size);
Result := TStreamAdapter.Create(MemoryStream, soOwned) as IStream;
finally
OleStream.Free;
end;
end;
end;