不规则的form怎么做???(100分)

  • 主题发起人 主题发起人 babyboom
  • 开始时间 开始时间
B

babyboom

Unregistered / Unconfirmed
GUEST, unregistred user!
象www.tingba.com 的haka那种不规则界面怎么做
form不是矩形的,是又很多圆和矩形组合在一起的。中间还有一部分是空心的
空心的部分能看到后面的图形。
这个怎么做?????
 
有控件可用
 
2000年看到一篇文章做的演示代码,可以根据位图做出漂亮的不规则FORM,大家可以下载演示程序研究一下,包含DELPHI版和VC版。




unit Unit1;

interface

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

type
TForm1 = class(TForm)
Image1: TImage;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
function CreateRegion(wMask: TBitmap; wColor: TColor;
hControl: THandle): HRGN;
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

function Tform1.CreateRegion(wMask:TBitmap;wColor:TColor;hControl:THandle): HRGN;
var
dc, dc_c: HDC;
rgn: HRGN;
x, y: integer;
coord: TPoint;
line: boolean;
color: TColor;
begin
dc := GetWindowDC(hControl);
dc_c := CreateCompatibleDC(dc);
SelectObject(dc_c, wMask.Handle);
BeginPath(dc);
for x:=0 to wMask.Width-1 do
begin
line := false;
for y:=0 to wMask.Height-1 do
begin
color := GetPixel(dc_c, x, y);
if not (color = wColor) then
begin
if not line then
begin
line := true;
coord.x := x;
coord.y := y;
end;
end;
if (color = wColor) or (y=wMask.Height-1) then
begin
if line then
begin
line := false;
MoveToEx(dc, coord.x, coord.y, nil);
LineTo(dc, coord.x, y);
LineTo(dc, coord.x + 1, y);
LineTo(dc, coord.x + 1, coord.y);
CloseFigure(dc);
end;
end;
end;
end;
EndPath(dc);
rgn := PathToRegion(dc);
ReleaseDC(hControl, dc);
Result := rgn;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
w1:TBitmap;
w2:TColor;
rgn: HRGN;
begin
w1:=TBitmap.Create;
w1.Assign(image1.Picture.Bitmap);
w2:=w1.Canvas.Pixels[0,0];
rgn := CreateRegion(w1,w2,Handle);
if rgn<>0 then
begin
SetWindowRgn(Handle, rgn, true);
end;
w1.Free;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
SendMessage(Handle, WM_SYSCOMMAND, $F012, 0);
end;

end.


快将分数发给我,我用过可以

用BMP图象将界面;十分方便,你的图像制作如果强的话,那制作出精品界面很ESAY的
 
学习!up
 
你可以去下载第三方控件http://www.softshape.com/activeskin/
可以自己设计窗体的外形,再用配套的控件将设计好的外形添加进DELPHI中
 
还是用第三方的控件好,如1stclass等[:D]
 
我写的一个不规则,呵呵,纯自己瞎琢磨的。
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, GIFImage,shellapi, Menus;
const
ICON_ID = 1;
lovecursor = 5 ;
MI_ICONEVENT = WM_USER + 1;
type
TForm1 = class(TForm)
Image1: TImage;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure installIcon;
procedure uninstallIcon;
procedure IconOnClick(var message:Tmessage); message MI_ICONEVENT;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
procedure wmnchittest(var msg:twmnchittest);message wm_nchittest;

public
{ Public declarations }
end;

var
Form1: TForm1;
BackColor:TColor;

implementation

{$R *.DFM}
{$R Icon.res}
procedure TForm1.FormCreate(Sender: TObject);
begin
BackColor:=Image1.Canvas.Pixels[2,2];
SetWindowLong(Application.Handle,GWL_ExStyle,WS_EX_Toolwindow);
screen.Cursors[lovecursor]:=loadcursor(hInstance,'newcursor');
cursor:=lovecursor;
installIcon;
end;

procedure TForm1.FormShow(Sender: TObject);
var
MyRgn, ClientRgn, ButtonRgn,bmpRgn: THandle;
Margin, X, Y: Integer;
p : Tpoint;
begin
Margin := (Width - ClientWidth) div 2;
MyRgn := CreateRectRgn(0, 0, Width, Height);
X := Margin;
Y := Height - ClientHeight - Margin;
ClientRgn := CreateRectRgn(X, Y, X + ClientWidth, Y + ClientHeight);
CombineRgn(MyRgn, MyRgn, ClientRgn, RGN_XOR);
//X := X + Button1.Left;
// Y := Y + Button1.Top;
// ButtonRgn := CreateRectRgn(X, Y, X + Button1.Width, Y + Button1.Height);
//-----------!!-----------
//Insert your additional controls here!
// CombineRgn(MyRgn, MyRgn, ButtonRgn, RGN_XOR);

//Image1.Picture.LoadFromFile('c:/ts1.bmp');
for x:=0 to Image1.width-1 do
for y:=0 to Image1.height-1 do
begin
if Image1.Canvas.Pixels[x,y]<> BackColor then
begin
bmpRgn:= CreateRectRgn(x,y,x+1,y+1);
CombineRgn(MyRgn,MyRgn,bmpRgn,RGN_XOR);
end;
end;

SetWindowRgn(Handle, MyRgn, True);

end;

procedure TForm1.installIcon;
var
IconData:TNotifyIconData;
Icon:TIcon;
begin
Icon:=TIcon.Create;
Icon.Handle:=loadIcon(hInstance,'I1');
IconData.cbSize := SizeOf( IconData );
IconData.Wnd := Handle;
IconData.uID := ICON_ID;
IconData.uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;
IconData.uCallBackMessage := MI_ICONEVENT;
IconData.hIcon:=Icon.handle;
IconData.szTip := 'transparentformexercise';
Shell_NotifyIcon(NIM_ADD,@IconData);


end;

procedure TForm1.uninstallIcon;
var
IconData:TNotifyIconData;
begin
IconData.cbSize:=sizeof(IconData);
IconData.uID:=Icon_ID;
IconData.Wnd:=Handle;
Shell_NotifyIcon(NIM_Delete,@IconData);

end;

procedure TForm1.IconOnClick(var message: Tmessage);
var
pos:TPoint;
begin
if message.LParam = WM_RBUTTONDOWN then
begin
Close;
end;

end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
uninstallIcon;
end;

procedure TForm1.wmnchittest(var msg: twmnchittest);
begin
inherited;
if (htclient=msg.result) then msg.result:=htcaption;

end;

end.

object Form1: TForm1
Left = 272
Top = 228
AutoSize = True
BorderStyle = bsNone
Caption = 'Form1'
ClientHeight = 76
ClientWidth = 100
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
FormStyle = fsStayOnTop
OldCreateOrder = False
OnClose = FormClose
OnCreate = FormCreate
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
object Image1: TImage
Left = 0
Top = 0
Width = 53
Height = 76
AutoSize = True
Picture.Data = {
07544269746D6170D6140000424DD61400000000000036040000280000003500
00004C0000000100080000000000A01000000000000000000000000100000000
00000404040000306400D04400003000DC0010649800FF78300074747400F8A0
04007C7C7C002C64FF00949494005888CC002098CC009C9C9C00B8B8B80090B0
E400C0C0C000C8C8C80054CCFF00D0D0D000BCDCF800E8E8E800F0F0F000F4F4
F400F8F8F800FFFFFF00888888008C8C8C00C4C4C400ECECEC00000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000191919191919191919191919191901010101010119191919191919191919
1919191919191919191919191919191919191919191919000000191919191919
19191919191919010404040404010101011919191919191919191B1B1B1B1B19
1919191919191919191919191919190000001919191919191919191919190104
040C0C040404040101010119191919191B1B11171710111B1B19191919191919
1919191919191900000019191919191919191919191901040C15120C04040408
08081B1B1B19191B1110171717171010111B1919190101010101191919191900
00001919191919191919191919191901040C0C0C0C08081010101010111B1B11
101717171717101010111B0101040C0C04040119191919000000191919191919
1919191919191919010104040810171717171717101008101017171717171710
10100804040C15120C0404011919190000001919191919191919191919191919
1919010810171717171717171717100810171717171717101010080804040C0C
04040401191919000000191919191919191919191919191919191B1017171717
1717171717171710081717171717171010100810080404040404011919191900
0000191919191919191919191919191919191B10171717171717171717171717
1010171717171710100810101008080401011919191919000000191919191919
191919191919191919191B101717171717171717171717171710171717171710
10081010101010081B1919191919190000001919191919191919191919191919
191B110817171717171717171717171717171017171717101008101010101010
1B19191919191900000019191919191919191919191919191B17100810171717
1717171717171717171717171717171008101010101010111B19191919191900
000019191919191919191919191919191B081710101717171717171717171717
1717171717171710081010081010101B19191919191919000000191919191919
191919191919191B110817171017171717171717171717171717171717171710
101008100810101B191919191919190000001901011919191919191919191B17
081008171710171717171717171717171717171717171710101008101008111B
191919191919190000000104040101011919191919191B170810081017171717
171717171717171710171717171717081010081008101B191919191919191900
0000190101040404010101191919010101011008171717171717171717171717
17101017171710081008101008101B1919191919191919000000191919010101
0404040101010B010B0101081017171717171717171717171717081010171008
100810080810111B191919191919190000001919191919190101010404010F0B
0F010B010817171717171717171717171717170810100810100817080808101B
191919191919190000001919191919191919190101011414140B0F0101061717
170101011515151515150E1708100810081017080808101B191A191919191900
00001919191919191A19191919010F1414141401041506060103030301080808
0808080E0E080810081710080808101B1A1C1A1919191900000019191919191A
1D1A1919191B01010F140F01010E1501030301030301171710081008080E0808
101710080808100806151A1919191900000019191919191A151C1A19191B1710
0101011010080E01030903010301171717100817100806081717080808081008
06151A1919191900000019191919191A1C151A19191B17171717171010080801
0915090303011717171708171710080817170808010101080E151A1919191900
00001919191919191A151D1A191B171717171717100810170109030301171717
1717101717171008101701010B0F0B010E151A19191A1900000019191A191919
1A15151D1A1B1017171717170808101717010101171717171717171717171010
08010B010101140B01151A191A1C1A000000191A1D1A19191A1C151515060817
17171710080810171717171717171717171717041717101008010F010F14140F
01151A191A151A000000191A1C1D1A19191A1515151508101717170810081010
1717171717171717171717041717101008010F010101140F01151A191A151A00
000019191A151D1A191A1C151515080810171008101004101008080808080810
1717170404101008101701010F140F0115151A191A151A00000019191A1C151C
1A191A1515150810171710171004040808101010101010080810170404101008
101717100101011515151A1A1C151A0000001919191A15151A191A1C15150E08
10171717040408101017171717101010100808040C0408101010171717100815
1515060615151A0000001919191A1C151D1A191A15151508081017040C041017
1717171717171710101010040C041010171010080808041515150606151C1A00
0000191919191A15151D1A1A0E151508101717040C0417010101010101010101
101010040C04101010171710080C0415150E060E151A19000000191919191A1C
151515060615150E0817040C040101040B0F0F0F0F0B0B040101100412041010
101008080C0C0415150E0615151A1900000019191919191A1D151515060E1515
08100412010B0F14141414140F0F0F0F0B04010412041010101008120C0C0415
150606150E1A190000001919191919191A15151515061515150804010B141414
0F0B141414140F0F0F0B04041204101010080C120C0C041515060E151C1A1900
00001919191919191A1C1515151506151515010B14141414141414140202150B
0B0F0B041204010808040C120C0C04150E0615151A1919000000191919191919
191A15151515150E1515010F1414141414141402070502150B0B0B0412041401
01040C120C0C0415061515151A19190000001919191919191A1A1A1C15151515
1515011414021514141414020005020E0B0B0B0412040F140B010C0C0C0C040E
1515151C1A19190000001919191919191919191A151515151515040F02071514
14140F001502020000040B0412040B0B140F010C040C04151515151A19191900
000019191919191919191A1A1A1C15151504040F02000E0F140F0F000000000B
04040B041204041414141401040C041515151C1A1A1919000000191919191919
19191919191A1C150404040F0015000B0F040B0B00000B0404040B040C040401
0B0F141401040415150E1A191919190000001919191919191919191919191A04
040C040B0B000B010B0B010404040B04040B0B040C040C040101010104040415
1C1A1A1A191919000000191919191919191919191919040C041204010B0B040B
0B040C0401010412040B04040C040C040C040C0C04041C1A1A19191919191900
000019191919191919191904191904120412040B0104040B0B0412040B0B0412
04040C04040C0C040C040C0C04041A1919191919191919000000191919191919
1919190419040C1204140C04040C040B040C12040B040C1204041204040C0C04
0C0C0C0404041919191919191919190000001919191919191919040C04041212
04150C040414040B041214040B041212040412040C0C0C040C0C0C0404041919
191919191919190000001919191919191919041204041214040C140404150C04
041215040B041412040C1204140C040C120C0C040C0419191919191919191900
0000191919191919191904120C040C140C04120C04140C0404121504040C150C
04140C12140C040C120C0C040C04191919191919191919000000191919191919
191904121204041514040C12040C120C04121404041415040C150C15120C040C
120C0C0C0C041919191919191919190000001919191919191919040C1412040C
1212040C1204120C0C12120412151404141412150C040C12120C120C0C041919
1919191919191900000019191919191919191904151412041212120C0C120C0C
0C12120C12141204141214120C041212120C120C0C0419191919191919191900
000019191919191919191904141514120C1212120C0C0C0C0C0C121214120C12
1212140C040C1212120C120C0C04191919191919191919000000191919191919
191919190415121212121212120C0C0C0C0C12121212121212120C0C04121214
1212120C041919191919191919191900000019191919191919191919040C1412
121212120C0C0C0C04040C1212121212120C0C040C1214121214120C04191919
1919191919191900000019191919191919191919190412121212121212120C04
040C04040C1212120C0C0C041212151214120C0C041919191919191919191900
00001919191919191919191919190412121212121204040C12120C0C04040C0C
0C0C040C1215141514120C041919191919191919191919000000191919191919
19191919191919040C12120C040C1412120C0C0C0C0C040404040C1214141514
120C0C0419191919191919191919190000001919191919191919191919191919
04040404121212121212120C0C0C0C0C0C0C0C0C121414120C0C041919191919
1919191919191900000019191919191919191919191919191919040C12121414
12120C0C040C0C0C0C0C121212120C0C0C041919191919191919191919191900
0000191919191919191919191919191919191904040C12141412120C0C040C0C
0C0C0C0C0C0C0C04041919191919191919191919191919000000191919191919
1919191919191919191919191904040C1212120C0C0C0C0C0C0C0C0C0C040419
1919191919191919191919191919190000001919191919191919191919191919
19191919191919040C0C0C1515151515150C0C0C041919191919191919191919
1919191919191900000019191919191919191919191919191919191919190C0C
1212120C0C0C0C0C0C1D15150C19191919191919191919191919191919191900
0000191919191919191919191919191919191919190C12120C0C0C1919191919
190C0C0C1D0C1919191919191919191919191919191919000000191919191919
1919191919191919191919190C120C0C1919191919191919191919190C120C19
1919191919191919191919191919190000001919191919191919191919191919
1919190C120C1919191919191919191919191919190C120C1919191919191919
19191919191919000000191919191919191919191919191919190C120C191919
191919191919191919191919190C120C19191919191919191919191919191900
00001919191919191919191919191919190C120C191919191919191919191919
19191919190C120C191919191919191919191919191919000000191919191919
1919191919191919190C120C191919191919191919191919191919190C120C19
1919191919191919191919191919190000001919191919191919191919191919
190C120C1919191919191919191919191919190C120C19191919191919191919
19191919191919000000191919191919191919191919191919190C120C191919
1919191919191919190C0C120C19191919191919191919191919191919191900
000019191919191919191919191919191919190C1D0C0C0C1919191919190C0C
0C12120C19191919191919191919191919191919191919000000191919191919
1919191919191919191919190C1D151D0C0C0C0C0C0C1212120C0C1919191919
1919191919191919191919191919190000001919191919191919191919191919
19191919190C0C0C1D151515151D0C0C0C191919191919191919191919191919
1919191919191900000019191919191919191919191919191919191919191919
0C0C0C0C0C0C1919191919191919191919191919191919191919191919191900
0000}
end
end
 
SkinEngine 就是很好的做界面的控件,使用又简单,建议你用它好了
 
to PFans
SkinEngine所支持的皮肤是*.uskn,*.kskn,*.xskn
用什么可以做这几种格式的皮肤呢?
 
to laohe:你贴的代码在delphi6和2000 server下没有效果哦!
 
我自己的机子就是delphi6和2000 server,我用它制作最中国新一代的多媒体软件,

最近要发布了,到时你再看看,能不能用;

98 ME 2000 XP都测试过了,全部可用,你再细细捡查一下
 
建议采用或修改第三方的控件!
 
DELPHI6自己就可以制作
在FORM中设置底图,然后设置透明颜色就可以了
 
还不结贴?再给你一个函数,我从1stClass那组控件中扣出来,Delphi5下可以用。
procedure CreateShapeForm(ahndForm: HWND; aBitmap: TBitmap;
clrTrans: TColor);
var
bmpTemp: TBitmap;
Rgn1, Rgn2: HRgn;
iCol, iStartCol, iRow: integer;
pbaLine: PByteArray;

function ColToColor(aiCol: integer): TColor;
const
BitMask: array[0..7] of byte = (128, 64, 32, 16, 8, 4, 2, 1);
begin
if bmpTemp.PixelFormat = Graphics.pf24bit then
Result := pbaLine[aiCol * 3] * 256 * 256 + pbaLine[aiCol * 3 + 1] * 256 + pbaLine[aiCol * 3 + 2]
else
begin
if ((pbaLine[aiCol div 8] and BitMask[aiCol mod 8]) <> 0) then
Result := TColor(clBlack)
else
Result := TColor(clWhite)
end;
end;
begin
if (ABitmap <> nil) and (ABitmap.Width = 0) or (ABitmap.Height = 0) then Exit;
Rgn1 := 0;

bmpTemp := TBitmap.Create;

bmpTemp.Assign(ABitmap);

if bmpTemp.PixelFormat <> Graphics.pf24bit then
begin
bmpTemp.Mask(clrTrans);
clrTrans := clBlack;
end;

with bmpTemp do
begin
for iRow := 0 to bmpTemp.height-1 do
begin
pbaLine:= scanLine[iRow];

iCol := 0;
while iCol < bmpTemp.Width do
begin
while (iCol < bmpTemp.Width) and (ColToColor(iCol) = clrTrans) do inc(iCol);
if iCol >= bmpTemp.Width then Continue;

iStartCol := iCol;
while (iCol < bmpTemp.Width) and (ColToColor(iCol) <> clrTrans) do inc(iCol);
if iCol >= bmpTemp.Width then iCol := bmpTemp.Width;

if Rgn1 = 0 then Rgn1 := CreateRectRgn(iStartCol, iRow, iCol, iRow + 1)
else begin
Rgn2 := CreateRectRgn(iStartCol, iRow, iCol, iRow + 1);
if (Rgn2 <> 0) then CombineRgn(Rgn1,Rgn1,Rgn2,RGN_OR);
Deleteobject(Rgn2);
end;
end;
end;
end;
bmpTemp.Free;

SetWindowRgn(ahndForm, 0, False);
SetWindowRgn(ahndForm, Rgn1, True);
end;
 
使用控件完全可以实现!
详细情况可以跟我联系
 
后退
顶部