Archive for the 'Windows 7' Category

Published by Derek Moore on 27 Jul 2009

The Windows API makers have lost their minds, part 17

I am now fully underway in the rewrite of 7stacks v1.5. This new 7stacks, unlike v1.2, eschews Windows controls of any kind. Now, for reasons of both speed and appearance, I will be drawing everything myself.

The primary tool I’m using to do this is something I’ve used a lot lately .. the Graphics32 library. It’s a Delphi library that allows you to draw fully alpha-blended 32-bit graphics at speeds much faster than a standard canvas. I used Graphics32 in 7stacks v1.0 to draw text and preview graphics. One of the tricks I’ve learned when doing this is how to make Graphics32 combine with Aero Glass to make awesome effects like 7stack’s text possible.

So, to take use of this, I’d like to retrieve 256×256 full-sized icons. Using the backend library that I’m using now, the MPCommonLibrary from MustangPeak (which itself is a translation of that part of the Windows API into Delphi), this is simple to do. Using 2 lines of code (using the function SHGetImageList with the parameter SHIL_JUMBO), I can retreieve a big ol’ icon, and put it into a Graphics32 bitmap, ready for use. But wait, that’s too easy!

As it turns out, not all icons are 256×256. And I can completely understand that. But, certainly in cases where there is no full-sized icon, the API could inform you about this, and let you make alternate plans (say, retrieving the 48×48 icon, instead)? Perhaps telling you how big the real icon is? Or just returning no icon at all? But no. It turns out that the Microsoft API team apparently gets its jollies from toying w/ developers, rather than helping them. In these cases, where no big icon is available, it simply slaps a 48×48 (or sometimes 32×32 or 16×16) icon onto a mostly blank 256×256 icon. AND, it doesn’t tell you how big the icon actually is! Hooray! So, imaine the fun I had of looking at this tiny little icon on this HUGE space, and trying to ask a computer to look at how big it really is.

Fortunately, Graphics32 is just too awesome, and led me to what we’ll call a “workaround”. I created the following 2 functions. The first function, TrueIconSize, scans the icon’s alpha channel, starting from the bottom-right to the top-left. If it finds anything, it says “aha! There’s the icon!”. The 2nd function, RoundToIntInList, simply rounds up to the nearest available icon size.

function TrueIconSize(Bitmap : TBitmap32) : integer;
  TestPoints = 20;
  PointsBlank : integer;
  X,Y, I : integer;
  IconSizes : TIntegerArray;

  IconSizes[0] := 16;
  IconSizes[1] := 32;
  IconSizes[2] := 48;
  IconSizes[3] := 128;
  IconSizes[4] := 256;

  Result := Bitmap.Width;
    PointsBlank := 0;
    for I := 1 to TestPoints do begin
      X := RandomRange(0, Result);
      Y := RandomRange(0, Result);
      if (AlphaComponent(Bitmap.PixelS[X,Result]) = 0) and (AlphaComponent(Bitmap.PixelS[Result,Y]) = 0) then Inc(PointsBlank);
    until (Result <= 16) or (PointsBlank <= TestPoints-1);
    Result := RoundToIntInList(Result, IconSizes);

function RoundToIntInList(Amount : integer; IntArray : TIntegerArray) : integer;
  I : integer;
  HiIndex, LoIndex : integer;
  IsFound : boolean;
  I := 0;
  IsFound := FALSE;
  while (not IsFound) and (I <= Length(IntArray)-2) do begin
    IsFound := (Amount > IntArray[I]) and (Amount < IntArray[I+1]);
  LoIndex := I-1;
  HiIndex := I;

  if Frac(Amount / (IntArray[HiIndex] - IntArray[LoIndex])) > 0.5 then
    Result := IntArray[HiIndex]
    Result := IntArray[LoIndex];

There may be approx. 4 people who ever need these functions, but there’s no reason to reinvent the wheel.

And just remember the moral of our story … don’t let your son or daughter grow up and say, “I want to be a Windows programmer!”

Published by Derek Moore on 13 Jan 2009

Why doesn’t Windows 7 have docklets?

When I use XP, I simply cannot use it on a day-to-day basis without ObjectDock.  I use it primarily for both my main apps, and for quick access to certain folders.  It’s handy to be able to just fling my mouse over to the side of the screen, and have a large target to click, rather than picking out a tiny little button in the QuickLaunch toolbar.

Now, OD, and other apps like it, are simply copying the OS X dock .. and that’s fine.  But guess what? So is Windows 7, in their new dock taskbar .. and that’s fine, too.  And that’s because its a good idea.  And good ideas should never be proprietary.  By combining running and non-running apps into the same space, you place the icons in the same order all the time, so that you always know where everything is.

But, there’s one other big use for docks: docklets.  There’s no such formal name in OS X, but in the Windows docks, docklets are miniature apps which run inside the dock itself.  In essence, they are basically widgets or gadgets that confine themselves to that dock’s icon, or an icon-sized window that the app author can paint however he likes.

For instance, I have a OD docklet that not only runs iTunes when I click it, but also displays the album cover of the song I’m listening to instead of the iTunes icon.  I also have a Thunderbird icon which doubles as an IMAP email checker.  There are thousands of docklets that give you weather updates, monitor RSS feeds, display system monitors, etc.

And this is where 7’s new taskbar is not doing it for me.  As a software author, I would love to be able to design an app that can change my app’s dock icon to whatever I want; whether its to draw a miniature calendar with upcoming appointments, or to display the iTunes album art instead of a static iTunes icon.

Adding such functionality into 7 shouldn’t be that difficult for Microsoft, given that their already extensive work into gadgets, and they’re existing partnership with Stardock (to create the Dreamscenes in Vista Ultimate).  In the end, giving programmers more control gives users a better experience down the line.

Published by Derek Moore on 13 Jan 2009

My Initial Windows 7 Thoughts

Story time, kids…  For Christmas, I got a new laptop.  I had needed one badly, and I managed to get a deal on Black Friday that was too good to pass up.  I mention this because, on the laptop was ..  Windows Vista.  Something which heretofore, I had never personally used.  Now, normally, as a computer geek, I would use the latest and greatest.  And as a programmer, I need to be on the forefront of this type of stuff.  But I had heard so much junk about Vista, that I was hesitant to use it, especially on my primary machine.

After using this laptop for over 6 weeks, I’ve been happy with Vista for the most part.  Despite all the naysayers out there, Vista isn’t that bad.  It’s definitely prettier, makes XP feel old.  But, it does come with a price…

Vista is a complete memory hog.  Even after I got rid of HP’s crapware on the laptop, the amount of Windows services that run in Vista is simply staggering.

So, during PDC in October ‘08, the new head of Windows, Steven Sinofsky, showed off a netbook running 7 … in 512 MB of RAM!  As soon as I saw this, I decided I had to try 7 as soon as it came out.

So, now that day is here.  In addition to installing it on a rusting bucket of bolts, I decided to also install it dual-boot on my main desktop PC.  For the record, my main desktop PC is only about 6 months old.  The parts in the case are these:

  • CPU: Core 2 Quad Q6600, overclocked to 3GHz (no more, because I like quiet+fast)
  • RAM: 2GB (2 x 1GB) PC2 6400
  • GPU: Geforce 8600GT (yea, I know .. “meh”)
  • HDD: 640GB SATA Western Digital

My initial impressions show Sinofsky to be right; the Core 2 Quad runs Win7 slightly faster than XP.  And post install, it also used up about the same amount of memory as XP.  Which is to say that 7 uses up far less memory than Vista.

Stay tuned.  I’ve also got some thoughts about the new Taskbar for my next post.

Published by Derek Moore on 03 Jan 2009

Windows 7

Like many others out there, I decided to try the newly released “unofficial” beta version of Windows 7 build 7000.  Based on what I’ve seen, I will be purchasing once it comes out.

Overall, I’m very impressed with the quality and completeness.   But where the rubber really meets the road is the speed…

Unlike everyone else who is trying this on the latest and greatest system, I decided to try Windows 7 on the slowest, crappiest computer I still had.  So, here’s the specs:

  • PC: Shuttle SK41G barebones
  • CPU: Athlon XP 2400
  • RAM: 1 GB (2×512 MB)
  • GPU: Geforce 6200 AGP
  • HDD: 160 GB IDE

Being purchased approx. March 2001, its marginally capable of running Ubuntu Intrepid or Windows XP.  It’s mostly been used to run Ubuntu over the years.  It was capable of running Compiz, but was woefully underpowered to run the “cube” effects of Compiz.  The best I could manage is the “wall” effects, which are much less taxing.

When I tried to install Windows 7, I was all but certain it would make the system choke.  But, imagine my surprise that Windows 7 not only booted up, but Aero worked!  And it worked fairly well, also.  Its at least as usable, and actually runs Firefox, IE, etc. fairly well.

So, kudos to MS.  Now that Allchin is out of there and Sinovsky is running things, perhaps they can make a decent OS.