[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 926
  • Last Modified:

Adding a Winamp style Skin to Delphi App

Does anyone have any information on chaging the interface in a Delphi application similar to WinAmp skins?
0
jbinns
Asked:
jbinns
  • 3
  • 3
  • 3
  • +5
1 Solution
 
TheNeilCommented:
You can't just change the appearance of any old existing Delphi application (well not without the source code anyway). You need to specifically code your app so that it CAN load new layouts etc. It's not a difficult job but it can mean a lot of data as you're having to load the positions and sizes of EVERYTHING

The Neil
0
 
jbinnsAuthor Commented:
Perhaps I should explain, a bit more clearly.  

We are developing a simple Windows utility and would like to change the waty the interface looks, our programmer knows how to cutomise buttons etc, but we are looking for a way of changing the  size, shape and position of items like scrollbars, and the Windows title bar, something similar to Winamp.

Any ideas??
0
 
TheNeilCommented:
I do actually. What you need to dois forget about using the standard Windows components and either get a third party set of components or use images. I'd sugegst that you use the second approach as it's far more customisable.

I won't go into great detail as you might not want to go down this route but basically for the 'components' you utilise the MouseDown, MouseMove, and MouseUp events and code the controls yourself. I have done an awful lot of this in the past so if you want more info, just ask. There are loads of ways to change window shape, get rid of caption bars etc. so decide what you want and then just ask

The Neil
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
MoonCalfCommented:
I agree with Neil.  This is something that is a bit arsey to do though.  It's just a lot of code for a little effect, but the end result can be nice, especially if it means the user can make your app look however they want!

Neil is obviously an expert in the field of Skin Manufacture and has been Skinning up for years now.

Stick with him and you'll find the answers to the universe.

MoonCalf.
0
 
TheNeilCommented:
I would just like to clarify that 'skinning up' in no sense means drugs. I have nothing to do with them, want nothing to do with them, and know no blokes in pubs called 'Dave' who can 'Do ya a good deal on a packet ov da white stuff'...of course anybody wanting to meet me in a car park to swap brown paper packages is another thing altogether

The Neil
0
 
nricoCommented:
Oh, you're talking harddrugs? But how about a joint?

Ah, about the skin:
Draw it yourself in the OnPaint event, or override the Paint method.
Use the Device Context. A nice effect gives (from the top of my head, I could be wrong in the names):

  DC:=GetDC(Handle);
  PaintDesktop(DC);
  ReleaseDC(DC);
0
 
ckanetaCommented:
I have a component(freeware, I think) that will set the shape of a form to any old bitmap you have lying around.
once you do this, its just a matter of
setting the positions of all the components on the form.
There are actually a number of components out there that would do this, I can send you the one I have or you can look at your favorite delphi component site for some.
0
 
intheCommented:
hello,
with this below you can make your form any cool shape you want:

http://www.lawrenz.com/coolform/

Regards Barry
0
 
SteveWaiteCommented:
I think this may be what you are looking for. Drop an image on a form and the form takes the shape of the image. From Madshi over here!

Creating A Skin Component
By Brendan Delumpa

Awhile back, I wrote an article about creating weirdly shaped forms that used WinAPI regions. They could create virtually any shape of form you wanted—rounded rectangles, ellipses, stars, or a combination of other shapes using the CombineRgn call. By recent standards this method was pretty low grade, but at the time, it was considered fairly fancy. Today, many programs utilize "skins" to change the appearance and shape of forms(think WinAmp). When I first saw WinAmp, I thought to myself, "They must be using regions to fit the form borders around a bitmap." But exactly how that was done was way beyond me. Well, thanks to Madshi over at the Experts Exchange (http://www.experts-exchange.com), I learned the mechanics of fitting a form's borders around a bitmap, and the solution is pretty slick! Below is code for a TImage descendant that you can drop on a form, and at runtime the form will become "transparent" except where the portions of the bitmap are shown. Take a look:
unit SkinImage;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics,
Controls, Forms, Dialogs,
  ExtCtrls;

type
  TSkinImage = class(TImage)
  private

  protected
    { Protected declarations }
    function BitmapToRegion(bmp: TBitmap) : dword;
    procedure OwnerShow(Sender : TObject);
  public
    constructor Create(AOwner : TComponent); override;
  published
    { Published declarations }
  end;

procedure Register;

var
  Ready : Boolean;

implementation

procedure Register;
begin
  RegisterComponents('BD', [TSkinImage]);
end;

{ TSkinImage }

constructor TSkinImage.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  if NOT (csDesigning in ComponentState) then
    with TForm(AOwner) do
    begin
      BorderStyle := bsNone;
      Self.Top := 0;
      Self.Left := 0;
      OnShow := OwnerShow;
    end;
end;

function TSkinImage.BitmapToRegion(bmp: TBitmap) : dword;
var ix,iy : integer;    // loop variables
    tc    : TColor;     // transparentColor
    b1    : boolean;    // am looking through "real"
pixels (no transparent pixels)
    c1    : cardinal;   // region helper variable
    i1    : integer;    // first position of real pixel
begin
  Result := 0;
  i1 := 0;
  // memory transparent color
  tc := bmp.transparentColor and $FFFFFF;
  with bmp.canvas do
    // scan through all lines
    for iy := 0 to bmp.height - 1 do
    begin
      b1 := False;
      // scan through all pixels in this line
      for ix:=0 to bmp.Width - 1 do
        // did we find the first/last real pixel in a row
        if (pixels[ix, iy] and $FFFFFF <> tc) <> b1 then begin
          // yes, and it was the last pixel,
          //so we can add a line style region...
          if b1 then begin
            c1:=CreateRectRgn(i1,iy,ix,iy+1);
            if result<>0 then
              begin
                // it's not the first region
                CombineRgn(Result, Result, c1, RGN_OR);
                DeleteObject(c1);
                // it's the first region
              end
            else
              Result := c1;
          end else i1 := ix;
          // change mode, looking for the first or last real pixel?
          b1:=not b1;
        end;
      // was the last pixel in this row a real pixel?
      if b1 then begin
        c1:=CreateRectRgn(i1, iy, bmp.width-1, iy+1);
        if (Result <> 0) then
          begin
            CombineRgn(Result, Result, c1, RGN_OR);
            DeleteObject(c1);
          end
        else
          Result := c1;
      end;
    end;
end;

procedure TSkinImage.OwnerShow(Sender: TObject);
var
  Region : HRGN;
begin
  if NOT Ready then
  begin
    Ready := True;
    Region := BitmapToRegion(Picture.Bitmap);
    SetWindowRgn(TForm(Owner).Handle, Region, True);
    DeleteObject(Region);
  end;
end;

initialization
  Ready := False;
end.

Notice that the workhorse of the component is the BitmapToRegion method. This method was developed by Madshi and kindly lent to me. In his own words, this is what the method does:

"Let's say the first line of our bitmap looks like this:
000XXXXX00XXXXX000000XXXX000
0 -> transparent pixel;   X -> colored pixel

Now my function goes through this line and creates a window region for each row of pixels. In the example, we would get 3 regions (4-8, 11-15, 22-25). Then I OR all the regions, and get a region for the complete pixel line. I do the same for all the other lines in the bitmap, and OR all those regions, and finally I end up with quite a complicated region that is something like the 'mask' of the bitmap. Now we have that region, the only thing left to do is to install it by calling SetWindowRgn."

Very cool. Try it out!    Other 10-Minute Solutions
 
 Trapping Messages Sent to an Application
 Getting the Number of Records From a Fixed-Length ASCII File
 Performing Incremental Searches with a TListbox
 Resizing the Drop-down List of a TComboBo
 Disabling the System Keys from Your Application
 Making A Secondary Form Independent of the Main Form
 Creating a System Tray Application
 Opening and Closing a CD Tray
 Hiding an Application from Windows
 Make a List Box Track the Mouse
 Running a Program at Startup
 Creating A Skin Component
 
 

0
 
intheCommented:
And this is basically same as what coolform does ...
0
 
SteveWaiteCommented:
Oops, sorry, Not trying to tread on your toes inthe. I did know it, I just had that example to hand so posted it for the matter of interest.

Nice to 'meet' you though..
Steve
0
 
intheCommented:
it is a good example so no dont matter ,Brendan has some good stuff on his site doesnt he ;-)
0
 
SteveWaiteCommented:
Theres some smart people around..;-)
0
 
lingxinCommented:
hi inthe
please give me a example.
my email :os@8848.net
thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 3
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now