views:

168

answers:

2

I always wondered how software such as iTunes, Winamp etc is able to create its own UI.

How is this accomplished under the Windows platform? Is there any code on the web explaining how one would create their own custom GUI?

+1  A: 

I'm assuming that you mean creating a GUI application as opposed to a GUI framework.

There are lots of GUI frameworks available for Windows.

Some are

  • wxWidgets (www.wxwidgets.org)
  • Qt (http://qt.nokia.com/products)
  • And of course the venerable MFC framework (http://msdn.microsoft.com/en-us/library/d06h2x6e%28VS.90%29.aspx)

If you want a more complete list, look at the Wikipedia article for MFC (http://msdn.microsoft.com/en-us/library/d06h2x6e%28VS.90%29.aspx) and scroll to the bottom.

Each of these GUI frameworks is amply documented on the web.

kmontgom
no, i mean GUI framework
Luca Matteis
Check out those links, they are GUI frameworks, so you can pick up some ideas on how they handle it and go from there. Examples are an excellent learning tool. ;)
peachykeen
+2  A: 

WinAmp doesn't usually supply its own GUI at all -- it delegates that to a "skin". You can download dozens of examples and unless memory fails me particularly badly, documentation is pretty easily available as well.

From the looks of things, I'd guess iTunes uses some sort of translation layer to let what's basically written as a native Mac UI run on Windows (the same kind of thing that Apple recently decided was so evil that they're now forbidden on the iPhone and apparently the iPad).

Since saying anything that could possibly be construed as negative about Apple is often treated as heresy, I'll point to all the .xib files that are included with iTunes for Windows. An .XIB file (at least normally) is produced by Apple's Interface Builder to hold resources for OS/X programs, and compiled to a .NIB file prior to deployment. Windows doesn't normally use either .XIB or .NIB files at all, and it appears likely to me that Apple includes a compatibility layer to use them on Windows (though I've never spent any time looking to figure out what file it's stored in or anything like that).

Edit: (response to Mattias's latest comment). Rendering it is tedious but fairly straightforward. You basically take the input from the skin (for example) and create an owner draw control (e.g. a button) and render the button based on that input.

The easiest way to do this is to have fixed positions for your controls, and require the user to draw/include bitmaps for the background and controls. In this case, you just load the background bitmap and display it covering the entire client area of your application (and you'll probably use a borderless window, so that's all that shows). You'll specify all your controls as owner-drawn, and for each you'll load their bitmap and blit it to the screen for that control. Since there won't (usually) be a visible title bar, you'll often need to handle WM_NCHITTEST (or equivalent on other systems) to let the user drag the window around.

If you want to get a bit more complex, you can add things like allowing them to also specify a size and position for each control, as well as possibly specifying that some controls won't show up at all. Again, this isn't really terribly difficult to manage -- under Windows, for example, most controls are windows, and you can specify a size and position when you create a window. If the user loads a different skin at run-time, you can call MoveWindow to move/resize each control as needed.

Jerry Coffin
I don't mean to turn this into a debate, but I think you are right about iTunes on Windows being equivalent to Flash or other cross-platform code on the iPhone! However, also note how seamless iTunes is on a Mac, but so terribly awkward and out-of-place it is on Windows. Consider it a demonstration!
mbmcavoy
what do you mean by 'it delegates that to a "skin"' ? my question wasn't specific to Winamp and iTunes, but to how some applications are able to render personalized UI. it would still be interesting to know how they render it through the 'skin'.
Luca Matteis
@Luca: WinAmp's skin development documentation is at: http://dev.winamp.com/skin-developers
Jerry Coffin
@Jerry: argh, this isn't what I want. My question was inherent to HOW they are actually able to render that stuff.
Luca Matteis